mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 02:08:43 +08:00 
			
		
		
		
	fix: 新用户第一次未设置角色无法登录 bug
This commit is contained in:
		| @@ -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: '', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 xingyu4j
					xingyu4j