File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { router } from '/@/router';
1414import { usePermissionStore } from '/@/store/modules/permission' ;
1515import { RouteRecordRaw } from 'vue-router' ;
1616import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic' ;
17+ import { isArray } from '/@/utils/is' ;
1718
1819interface UserState {
1920 userInfo : Nullable < UserInfo > ;
@@ -118,10 +119,15 @@ export const useUserStore = defineStore({
118119 } ,
119120 async getUserInfoAction ( ) : Promise < UserInfo > {
120121 const userInfo = await getUserInfo ( ) ;
121- const { roles } = userInfo ;
122- const roleList = roles . map ( ( item ) => item . value ) as RoleEnum [ ] ;
122+ const { roles = [ ] } = userInfo ;
123+ if ( isArray ( roles ) ) {
124+ const roleList = roles . map ( ( item ) => item . value ) as RoleEnum [ ] ;
125+ this . setRoleList ( roleList ) ;
126+ } else {
127+ userInfo . roles = [ ] ;
128+ this . setRoleList ( [ ] ) ;
129+ }
123130 this . setUserInfo ( userInfo ) ;
124- this . setRoleList ( roleList ) ;
125131 return userInfo ;
126132 } ,
127133 /**
You can’t perform that action at this time.
0 commit comments