Commit e681d845 authored by 沈翠玲's avatar 沈翠玲

登录问题处理

parent dfa18029
......@@ -46,6 +46,14 @@ export const useUserStore = defineStore({
this.isTenant = false;
this.tenant = null;
},
async logoutPass() {
const socketStore = useSocketStore();
socketStore.closeWs();
this.token = '';
this.userInfo = null;
this.isTenant = false;
this.tenant = null;
},
},
persist: piniaPersistConfig('admin-user'),
});
......@@ -136,7 +136,9 @@ const useSocketStore = defineStore('socket', {
this.handClose = true;
this.clearTimer();
console.log('ws', this.ws);
if (this.ws && this.ws.close) {
this.ws.close();
}
},
},
});
......
......@@ -78,8 +78,9 @@ class RequestClient {
axiosCanceler.removePending(config);
const userStore = useUserStore();
if (data.code === 500 && data.message.includes('token')) {
userStore.setToken('');
router.replace(LOGIN_URL);
// if (data.code === 200) {
userStore.logoutPass();
window.location.href = LOGIN_URL
ElMessage({
message: '登录失效,请重新登录',
type: 'error',
......@@ -89,8 +90,8 @@ class RequestClient {
}
// 登录失效
if (data.code === 404) {
userStore.setToken('');
router.replace(LOGIN_URL);
userStore.logoutPass();
window.location.href = LOGIN_URL
ElMessage({
message: '登录失效,请重新登录',
type: 'error',
......
......@@ -115,8 +115,10 @@
keepAliveStore.setKeepAliveName([]);
// 4.跳转到首页
setTimeout(() => {
router.push(HOME_URL);
loginLoading.value = false;
}, 1000)
};
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment