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