fix: 修复token过期后,疯狂打印token过期信息的bug

pull/409/head
xiaojunnuo 2025-04-24 23:54:09 +08:00
parent 7d96a57d73
commit 50a5fa15bb
3 changed files with 964 additions and 10 deletions

View File

@ -120,7 +120,7 @@ function createService() {
errorLog(error, error?.response?.config?.showErrorNotify); errorLog(error, error?.response?.config?.showErrorNotify);
if (status === 401) { if (status === 401) {
const userStore = useUserStore(); const userStore = useUserStore();
userStore.logout(); userStore.logout(true, true);
} }
if (error?.config?.onError) { if (error?.config?.onError) {

View File

@ -108,10 +108,12 @@ export const useUserStore = defineStore({
/** /**
* @description: logout * @description: logout
*/ */
async logout(goLogin = true) { async logout(goLogin = true, from401 = false) {
this.resetState(); this.resetState();
resetAllStores(); resetAllStores();
if (!from401) {
await UserApi.logout(); //主要是清空cookie await UserApi.logout(); //主要是清空cookie
}
goLogin && router.push("/login"); goLogin && router.push("/login");
mitter.emit("app.logout"); mitter.emit("app.logout");
}, },

File diff suppressed because it is too large Load Diff