|
@ -3,6 +3,7 @@ import { defineStore } from 'pinia' |
|
|
import { getAccessToken, removeToken } from '@/utils/auth' |
|
|
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' |
|
|
|
|
|
|
|
|
const { wsCache } = useCache() |
|
|
const { wsCache } = useCache() |
|
|
|
|
|
|
|
@ -16,6 +17,7 @@ interface UserInfoVO { |
|
|
roles: string[] |
|
|
roles: string[] |
|
|
isSetUser: boolean |
|
|
isSetUser: boolean |
|
|
user: UserVO |
|
|
user: UserVO |
|
|
|
|
|
userSelfInfo:object |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export const useUserStore = defineStore('admin-user', { |
|
|
export const useUserStore = defineStore('admin-user', { |
|
@ -27,7 +29,8 @@ export const useUserStore = defineStore('admin-user', { |
|
|
id: 0, |
|
|
id: 0, |
|
|
avatar: '', |
|
|
avatar: '', |
|
|
nickname: '' |
|
|
nickname: '' |
|
|
} |
|
|
}, |
|
|
|
|
|
userSelfInfo:{} |
|
|
}), |
|
|
}), |
|
|
getters: { |
|
|
getters: { |
|
|
getPermissions(): string[] { |
|
|
getPermissions(): string[] { |
|
@ -41,6 +44,9 @@ export const useUserStore = defineStore('admin-user', { |
|
|
}, |
|
|
}, |
|
|
getUser(): UserVO { |
|
|
getUser(): UserVO { |
|
|
return this.user |
|
|
return this.user |
|
|
|
|
|
}, |
|
|
|
|
|
getUserSelfInfo(): UserVO { |
|
|
|
|
|
return this.userSelfInfo |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
actions: { |
|
|
actions: { |
|
@ -53,6 +59,12 @@ export const useUserStore = defineStore('admin-user', { |
|
|
if (!userInfo) { |
|
|
if (!userInfo) { |
|
|
userInfo = await getInfo() |
|
|
userInfo = await getInfo() |
|
|
} |
|
|
} |
|
|
|
|
|
this.userSelfInfo = await getUserProfile() |
|
|
|
|
|
// userInfo = await getInfo()
|
|
|
|
|
|
console.log(4); |
|
|
|
|
|
console.log(this.userSelfInfo); |
|
|
|
|
|
console.log(4); |
|
|
|
|
|
|
|
|
this.permissions = userInfo.permissions |
|
|
this.permissions = userInfo.permissions |
|
|
this.roles = userInfo.roles |
|
|
this.roles = userInfo.roles |
|
|
this.user = userInfo.user |
|
|
this.user = userInfo.user |
|
|