|
|
|
@ -15,7 +15,13 @@ import { h } from 'vue'
|
|
|
|
|
import { Storage } from '/@/utils/Storage'
|
|
|
|
|
import { CurrentUserViewModel, LoginParams } from '/@/api/common/Model'
|
|
|
|
|
|
|
|
|
|
import { getUserInfo, login, userLogout, getCollectWarningCount } from '/@/api/common'
|
|
|
|
|
import {
|
|
|
|
|
getUserInfo,
|
|
|
|
|
login,
|
|
|
|
|
userLogout,
|
|
|
|
|
getCollectWarningCount,
|
|
|
|
|
UserRefreshToken,
|
|
|
|
|
} from '/@/api/common'
|
|
|
|
|
import { DataResult } from '/@/api/model/baseModel'
|
|
|
|
|
import { initDictOptions } from '/@/utils/dictUtil'
|
|
|
|
|
import { getThermometryWarningCount } from '/@/api/security/hkopen'
|
|
|
|
@ -101,12 +107,14 @@ export const useUserStore = defineStore({
|
|
|
|
|
if (res !== undefined) {
|
|
|
|
|
const token = res?.data
|
|
|
|
|
this.setToken(token)
|
|
|
|
|
|
|
|
|
|
return this.afterLoginAction(true)
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return Promise.reject(error)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async afterLoginAction(goHome?: boolean): Promise<CurrentUserViewModel | null> {
|
|
|
|
|
if (!this.getToken) return null
|
|
|
|
|
// get user info
|
|
|
|
@ -138,6 +146,14 @@ export const useUserStore = defineStore({
|
|
|
|
|
if (!this.getToken) return null
|
|
|
|
|
const response = await getUserInfo()
|
|
|
|
|
const userInfo = response.data
|
|
|
|
|
//获取 用户信息后 开启计时器 重置 token
|
|
|
|
|
setTimeout(async () => {
|
|
|
|
|
const Refres = await UserRefreshToken(userInfo)
|
|
|
|
|
if (Refres.succeeded) {
|
|
|
|
|
this.setToken(Refres.data.accessToken)
|
|
|
|
|
this.setUserInfo({ refreshToken: Refres.data.refreshToken })
|
|
|
|
|
}
|
|
|
|
|
}, 6600000)
|
|
|
|
|
/**
|
|
|
|
|
* 初始化字典选项
|
|
|
|
|
*/
|
|
|
|
@ -150,6 +166,8 @@ export const useUserStore = defineStore({
|
|
|
|
|
// userInfo.roles = []
|
|
|
|
|
// this.setRoleList([])
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
console.log('用户信息', userInfo)
|
|
|
|
|
this.setUserInfo(userInfo)
|
|
|
|
|
return userInfo
|
|
|
|
|