refactor: 超时退出修改

This commit is contained in:
Captain.B 2021-06-02 17:59:57 +08:00 committed by 刘瑞斌
parent 5bd43ab695
commit 55fe8c0352
1 changed files with 16 additions and 1 deletions

View File

@ -106,13 +106,28 @@ export default {
initSessionTimer() {
this.$get('/system/timeout')
.then(response => {
let timeout = response.data.data;
this.initTimer(timeout);
window.addEventListener('click', () => {
this.currentTime(response.data.data);
this.currentTime(timeout);
});
})
.catch(() => {
});
},
initTimer(timeout) {
setTimeout(() => {
this.$get("/isLogin")
.then(response => {
if (!response.data.success) {
this.$refs.headerUser.logout();
}
})
.catch(() => {
window.location.href = "/login";
});
}, 1000 * (timeout + 10));
},
currentTime(timeout) { // 退
if (timer) {
window.clearTimeout(timer);