提交 91e4191a 编写于 作者: 雪洛's avatar 雪洛

chore: add uni-id token valid

上级 93cb0214
......@@ -11,7 +11,8 @@ function getCurrentUserInfo () {
return {
uid: null,
role: [],
permission: []
permission: [],
tokenExpired: 0
}
}
let userInfo
......@@ -20,6 +21,9 @@ function getCurrentUserInfo () {
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000
delete userInfo.exp
delete userInfo.iat
return userInfo
}
......@@ -36,4 +40,10 @@ export function uniIdMixin (Vue) {
} = getCurrentUserInfo()
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
}
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo()
return tokenExpired > Date.now()
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册