| | |
| | | import { resetRouter, router } from '@/router'; |
| | | import { useTagsViewStoreHook } from './tagsView'; |
| | | import * as accountServices from '@/services/api/Account'; |
| | | import * as userServices from '@/services/api/User'; |
| | | import { usePermissionStoreHook } from './permission'; |
| | | import { getAccountInfoFromAccessToken, AccountInfo } from '@bole-core/core'; |
| | | import { useClearSubModule } from '@/hooks'; |
| | |
| | | // 用户登入 |
| | | loginByUsername(data: API.AccessRequestDto) { |
| | | return new Promise<void>((resolve, reject) => { |
| | | userServices |
| | | accountServices |
| | | .getTokenForWeb(data, { showLoading: false }) |
| | | .then((res) => { |
| | | if (res) { |
| | | console.log('res: ', res); |
| | | this.setToken(res.accessToken); |
| | | |
| | | const accountInfo = getAccountInfoFromAccessToken(res.accessToken); |
| | | |
| | | this.setName(accountInfo.name); |
| | | this.setAccountInfo(accountInfo); |
| | | |
| | | // 获取用户信息 |
| | | this.setUserInfo(res); |
| | | this.loginSuccess(res); |
| | | |
| | | resolve(); |
| | | } |
| | |
| | | }); |
| | | }, |
| | | |
| | | async twoFactorLoginSms(params: API.TwoFactorLoginSmsInput) { |
| | | try { |
| | | let res = await accountServices.twoFactorLoginSms(params, { showLoading: false }); |
| | | if (res) { |
| | | this.loginSuccess(res); |
| | | } |
| | | } catch (error) {} |
| | | }, |
| | | |
| | | loginSuccess(res: API.IdentityModelToken) { |
| | | this.setToken(res.accessToken); |
| | | |
| | | const accountInfo = getAccountInfoFromAccessToken(res.accessToken); |
| | | |
| | | this.setName(accountInfo.name); |
| | | this.setAccountInfo(accountInfo); |
| | | |
| | | // 获取用户信息 |
| | | this.setUserInfo(res); |
| | | }, |
| | | |
| | | // 登出 清空缓存 |
| | | logout(redirectPath = '/') { |
| | | return new Promise(async (resolve) => { |