This commit is contained in:
xiaojunnuo
2024-10-03 01:29:12 +08:00
parent aeed24e87d
commit c9d18f6d8a
17 changed files with 100 additions and 34 deletions
@@ -23,6 +23,7 @@ interface PlusInfo {
vipType: string;
expireTime: number;
isPlus: boolean;
isComm: boolean;
}
const USER_INFO_KEY = "USER_INFO";
@@ -46,10 +47,21 @@ export const useUserStore = defineStore({
return this.token || LocalStorage.get(TOKEN_KEY);
},
isAdmin(): boolean {
return this.getUserInfo?.id === 1;
return this.getUserInfo.id === 1 || this.getUserInfo.roles?.includes(1);
},
isPlus(): boolean {
return this.plusInfo?.isPlus && this.plusInfo?.expireTime > new Date().getTime();
},
isComm(): boolean {
return this.plusInfo?.isComm && this.plusInfo?.expireTime > new Date().getTime();
},
vipLabel(): string {
const vipLabelMap: any = {
free: "免费版",
vip: "专业版",
comm: "商业版"
};
return vipLabelMap[this.plusInfo?.vipType];
}
},
actions: {