perf: 登录逻辑调整
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
import { fetchEnterpriseInfo } from '@/api/all/login';
|
||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||
import { useUserStore } from '@/stores/modules/user';
|
||||
import { glsWithCatch, slsWithCatch, rlsWithCatch } from '@/utils/stroage';
|
||||
import { glsWithCatch, slsWithCatch } from '@/utils/stroage';
|
||||
|
||||
interface EnterpriseInfo {
|
||||
id: number | string;
|
||||
@ -11,6 +9,8 @@ interface EnterpriseInfo {
|
||||
sub_account_quota: number;
|
||||
used_sub_account_count: number;
|
||||
permissions: string[];
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface EnterpriseState {
|
||||
@ -21,6 +21,12 @@ export const useEnterpriseStore = defineStore('enterprise', {
|
||||
state: (): EnterpriseState => ({
|
||||
enterpriseInfo: (glsWithCatch('enterpriseInfo') && JSON.parse(glsWithCatch('enterpriseInfo') as string)) || null,
|
||||
}),
|
||||
getters: {
|
||||
// 企业已开通/试用中
|
||||
isOpenEnterprise(): boolean {
|
||||
return [1, 2].includes(this.enterpriseInfo?.subscribe_status);
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
setEnterpriseInfo(enterpriseInfo: EnterpriseInfo) {
|
||||
this.enterpriseInfo = enterpriseInfo;
|
||||
|
||||
@ -39,10 +39,6 @@ export const useUserStore = defineStore('user', {
|
||||
isLogin(): boolean {
|
||||
return !!this.token;
|
||||
},
|
||||
// 是否开通企业
|
||||
isOpenEnterprise(): boolean {
|
||||
return [1, 2].includes(this.userInfo?.primary_enterprise?.subscribe_status);
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
// 设置 Token
|
||||
|
||||
Reference in New Issue
Block a user