优化登录逻辑

This commit is contained in:
RockYang
2023-04-08 10:57:46 +08:00
parent df9e587300
commit 208655af5e
5 changed files with 80 additions and 17 deletions

View File

@@ -3,13 +3,23 @@
* storage handler
*/
const SessionIdKey = 'ChatGPT_SESSION_ID';
const SessionUserKey = 'LOGIN_USER';
export const Global = {}
export function getSessionId() {
return sessionStorage.getItem(SessionIdKey)
const user = getLoginUser();
return user ? user['session_id'] : '';
}
export function setSessionId(value) {
sessionStorage.setItem(SessionIdKey, value)
export function getLoginUser() {
const value = sessionStorage.getItem(SessionUserKey);
if (value) {
return JSON.parse(value);
} else {
return null;
}
}
export function setLoginUser(value) {
sessionStorage.setItem(SessionUserKey, JSON.stringify(value))
}