自动登录调整

This commit is contained in:
joylink_cuiweidong 2019-11-28 18:45:37 +08:00
parent a77d9d0781
commit 0f5c3bc2e0
2 changed files with 17 additions and 3 deletions

View File

@ -35,7 +35,7 @@ export default {
this.$alert(this.$t('tip.logoutTips'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
callback: action => {
this.$store.dispatch('LogOut').then(resp => {
this.$store.dispatch('exit').then(resp => {
this.$router.push({path: loginInfo[getSessionStorage('project')].loginPath});
});
}
@ -53,13 +53,13 @@ export default {
window.addEventListener('unload', async e => {
gap_time = new Date().getTime() - beforeUnload_time;
if (gap_time <= 5) {
await this.$store.dispatch('LogOut');
await this.$store.dispatch('exit');
}
});
window.addEventListener('beforeunload', async e => {
beforeUnload_time = new Date().getTime();
if (isFireFox) {
await this.$store.dispatch('LogOut');
await this.$store.dispatch('exit');
}
});

View File

@ -165,6 +165,20 @@ const user = {
});
},
// 关闭页面
exit({ commit, dispatch }) {
const token = getToken();
return new Promise((resolve, reject) => {
dispatch('FedLogOut').then(resp => {
logout(token).then(() => {
resolve();
}).catch(error => {
reject(error);
});
});
});
},
SetAccount({ commit }, account) {
commit('SET_ACCOUNT', account);
},