| | |
| | | state: (): UserInfosState => ({ |
| | | userInfos: { |
| | | userName: '', |
| | | code:'', |
| | | photo: '', |
| | | time: 0, |
| | | roles: [], |
| | | authBtnList: [], |
| | | clientCode:'', |
| | | clientName:'' |
| | | clientName:'', |
| | | clientInfos:[], |
| | | }, |
| | | }), |
| | | actions: { |
| | |
| | | console.log('Session里没有userInfo') |
| | | const userInfos = <UserInfos>await this.getApiUserInfo(); |
| | | this.userInfos = userInfos; |
| | | console.log('完成了') |
| | | } |
| | | }, |
| | | // 模拟接口数据 |
| | |
| | | setTimeout(() => { |
| | | // 模拟数据,请求接口时,记得删除多余代码及对应依赖的引入 |
| | | const userName = userRet.userName |
| | | const userCode = userRet.code |
| | | // 模拟数据 |
| | | let defaultRoles: Array<string> = []; |
| | | let defClients:Array<object>=[]; |
| | | let defaultAuthBtnList: Array<string> = []; |
| | | // admin 页面权限标识,对应路由 meta.roles,用于控制路由的显示/隐藏 |
| | | let adminRoles: Array<string> = ['admin']; |
| | |
| | | if (isadmin) { |
| | | defaultRoles = adminRoles; |
| | | defaultAuthBtnList = adminAuthBtnList; |
| | | defClients=userRet?.管理员能看到的客户列表 |
| | | |
| | | } else { |
| | | defaultRoles = testRoles; |
| | | defaultAuthBtnList = testAuthBtnList; |
| | | defClients=userRet.clientInfos |
| | | |
| | | } |
| | | // 用户信息模拟数据 |
| | | const userInfos = { |
| | | userName: userName, |
| | | code:userCode, |
| | | photo:userRet.userAvatar==='' |
| | | ? 'https://img2.baidu.com/it/u=1978192862,2048448374&fm=253&fmt=auto&app=138&f=JPEG?w=504&h=500' |
| | | : userRet.userAvatar, |
| | |
| | | authBtnList: defaultAuthBtnList, |
| | | clientCode:userRet.currentClientInfo.code, |
| | | clientName:userRet.currentClientInfo.clientName, |
| | | clientInfos:defClients |
| | | }; |
| | | console.log('-----------------2222------------------------------') |
| | | console.log(userInfos) |
| | | // Session.set('userInfo', userInfos); |
| | | resolve(userInfos); |
| | | }, 0); |
| | | }); |
| | | }, |
| | | async setUserCilent(client:clientInfo){ |
| | | this.userInfos.clientCode=client.code |
| | | this.userInfos.clientName=client.clientName |
| | | } |
| | | }, |
| | | }); |