fix: 新用户第一次未设置角色无法登录 bug
This commit is contained in:
parent
c3560a52e2
commit
cbeee0f744
@ -55,7 +55,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
const res = await listSimpleDictDataApi()
|
||||
dictStore.setDictMap(res)
|
||||
}
|
||||
if (userStore.getRoles.length === 0) {
|
||||
if (!userStore.getIsSetUser) {
|
||||
isRelogin.show = true
|
||||
const res = await getInfoApi()
|
||||
await userStore.setUserInfoAction(res)
|
||||
|
@ -13,6 +13,7 @@ interface UserVO {
|
||||
interface UserInfoVO {
|
||||
permissions: string[]
|
||||
roles: string[]
|
||||
isSetUser: boolean
|
||||
user: UserVO
|
||||
}
|
||||
|
||||
@ -20,6 +21,7 @@ export const useUserStore = defineStore('admin-user', {
|
||||
state: (): UserInfoVO => ({
|
||||
permissions: [],
|
||||
roles: [],
|
||||
isSetUser: false,
|
||||
user: {
|
||||
id: 0,
|
||||
avatar: '',
|
||||
@ -33,6 +35,9 @@ export const useUserStore = defineStore('admin-user', {
|
||||
getRoles(): string[] {
|
||||
return this.roles
|
||||
},
|
||||
getIsSetUser(): boolean {
|
||||
return this.isSetUser
|
||||
},
|
||||
getUser(): UserVO {
|
||||
return this.user
|
||||
}
|
||||
@ -46,6 +51,7 @@ export const useUserStore = defineStore('admin-user', {
|
||||
this.permissions = userInfo.permissions
|
||||
this.roles = userInfo.roles
|
||||
this.user = userInfo.user
|
||||
this.isSetUser = true
|
||||
wsCache.set(CACHE_KEY.USER, userInfo)
|
||||
},
|
||||
loginOut() {
|
||||
@ -56,6 +62,7 @@ export const useUserStore = defineStore('admin-user', {
|
||||
resetState() {
|
||||
this.permissions = []
|
||||
this.roles = []
|
||||
this.isSetUser = false
|
||||
this.user = {
|
||||
id: 0,
|
||||
avatar: '',
|
||||
|
Loading…
Reference in New Issue
Block a user