|
|
@ -4,6 +4,7 @@ import { getAccessToken, removeToken } from '@/utils/auth' |
|
|
|
import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
|
|
|
import { getInfo, loginOut } from '@/api/login' |
|
|
|
import { getUserProfile } from '@/api/system/user/profile' |
|
|
|
import { getClassTypeNoPage } from '@/api/eam/basic/classType' |
|
|
|
|
|
|
|
const { wsCache } = useCache() |
|
|
|
|
|
|
@ -17,7 +18,8 @@ interface UserInfoVO { |
|
|
|
roles: string[] |
|
|
|
isSetUser: boolean |
|
|
|
user: UserVO |
|
|
|
userSelfInfo:object |
|
|
|
userSelfInfo: object |
|
|
|
classType: object[] |
|
|
|
} |
|
|
|
|
|
|
|
export const useUserStore = defineStore('admin-user', { |
|
|
@ -30,7 +32,8 @@ export const useUserStore = defineStore('admin-user', { |
|
|
|
avatar: '', |
|
|
|
nickname: '' |
|
|
|
}, |
|
|
|
userSelfInfo:{} |
|
|
|
userSelfInfo: {}, |
|
|
|
classType: [] |
|
|
|
}), |
|
|
|
getters: { |
|
|
|
getPermissions(): string[] { |
|
|
@ -45,8 +48,11 @@ export const useUserStore = defineStore('admin-user', { |
|
|
|
getUser(): UserVO { |
|
|
|
return this.user |
|
|
|
}, |
|
|
|
getUserSelfInfo(): UserVO { |
|
|
|
getUserSelfInfo(): UserVO { |
|
|
|
return this.userSelfInfo |
|
|
|
}, |
|
|
|
getClassTypeInfo(): object[] { |
|
|
|
return this.classType |
|
|
|
} |
|
|
|
}, |
|
|
|
actions: { |
|
|
@ -64,6 +70,12 @@ export const useUserStore = defineStore('admin-user', { |
|
|
|
this.roles = userInfo.roles |
|
|
|
this.user = userInfo.user |
|
|
|
this.isSetUser = true |
|
|
|
this.classType = await getClassTypeNoPage({}); |
|
|
|
this.classType = this.classType.filter(item => { |
|
|
|
return this.userSelfInfo?.roles.some(role => { |
|
|
|
return role.id == item.workerRoleId || role.id == item.engineerRoleId; |
|
|
|
}); |
|
|
|
}); |
|
|
|
wsCache.set(CACHE_KEY.USER, userInfo) |
|
|
|
wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus) |
|
|
|
}, |
|
|
|