修复 可能的 token 到期错误
This commit is contained in:
parent
cb7c8a193c
commit
05ef481f0a
@ -41,20 +41,17 @@ export const useUserStore = defineStore("user", {
|
||||
this.user.id = idTokenPayload.sub;
|
||||
this.logined = true;
|
||||
},
|
||||
setupTimer() {
|
||||
timer = setInterval(() => {
|
||||
if (this.logined) {
|
||||
if (this.expired_at - Date.now() < 60000) {
|
||||
this.refresh();
|
||||
} else {
|
||||
// 显示还有多长时间过期
|
||||
// console.log(
|
||||
// "Token will expire in " +
|
||||
// (this.expired_at - Date.now()) / 1000 +
|
||||
// " seconds"
|
||||
// );
|
||||
}
|
||||
checkAndRefresh() {
|
||||
if (this.logined) {
|
||||
if (this.expired_at - Date.now() < 60000) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
},
|
||||
setupTimer() {
|
||||
this.checkAndRefresh();
|
||||
timer = setInterval(() => {
|
||||
this.checkAndRefresh();
|
||||
}, 10 * 1000);
|
||||
},
|
||||
async refresh() {
|
||||
|
Loading…
Reference in New Issue
Block a user