修复 可能的 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.user.id = idTokenPayload.sub;
|
||||||
this.logined = true;
|
this.logined = true;
|
||||||
},
|
},
|
||||||
setupTimer() {
|
checkAndRefresh() {
|
||||||
timer = setInterval(() => {
|
|
||||||
if (this.logined) {
|
if (this.logined) {
|
||||||
if (this.expired_at - Date.now() < 60000) {
|
if (this.expired_at - Date.now() < 60000) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
} else {
|
|
||||||
// 显示还有多长时间过期
|
|
||||||
// console.log(
|
|
||||||
// "Token will expire in " +
|
|
||||||
// (this.expired_at - Date.now()) / 1000 +
|
|
||||||
// " seconds"
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
setupTimer() {
|
||||||
|
this.checkAndRefresh();
|
||||||
|
timer = setInterval(() => {
|
||||||
|
this.checkAndRefresh();
|
||||||
}, 10 * 1000);
|
}, 10 * 1000);
|
||||||
},
|
},
|
||||||
async refresh() {
|
async refresh() {
|
||||||
|
Loading…
Reference in New Issue
Block a user