将 curAccount 存到 storage 里

This commit is contained in:
BTMuli
2023-06-02 21:20:47 +08:00
parent bc49749195
commit 6714a94502
4 changed files with 33 additions and 32 deletions

View File

@@ -18,6 +18,7 @@ export const useUserStore = defineStore(
uid: "",
desc: "",
} as TGApp.App.Account.BriefInfo);
const account = ref({} as TGApp.Sqlite.Account.Game);
const cookie = ref({} as Record<string, string>);
function setBriefInfo (info: TGApp.App.Account.BriefInfo): void {
@@ -28,6 +29,14 @@ export const useUserStore = defineStore(
return briefInfo.value;
}
function setCurAccount (user: TGApp.Sqlite.Account.Game) {
account.value = user;
}
function getCurAccount (): TGApp.Sqlite.Account.Game {
return account.value;
}
function getCookieItem (key: string): string {
return cookie.value[key] || "";
}
@@ -67,12 +76,16 @@ export const useUserStore = defineStore(
cookie.value = ck;
}
}
return {
briefInfo,
cookie,
account,
getBriefInfo,
setBriefInfo,
getCookieItem,
setCurAccount,
getCurAccount,
getCookieGroup1,
getCookieGroup2,
getCookieGroup3,
@@ -89,6 +102,10 @@ export const useUserStore = defineStore(
key: "briefInfo",
storage: window.localStorage,
paths: ["briefInfo"],
}, {
key: "account",
storage: window.localStorage,
paths: ["account"],
}],
},
);