From b759ab60dbe04d240212ceb12eab043106d6603a Mon Sep 17 00:00:00 2001 From: bestlee Date: Fri, 9 Oct 2026 15:46:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E6=95=B0=E6=8D=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/global-header/components/user-avatar.vue | 2 +- src/store/modules/auth/index.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/layouts/modules/global-header/components/user-avatar.vue b/src/layouts/modules/global-header/components/user-avatar.vue index 18ecf49..0865dbb 100644 --- a/src/layouts/modules/global-header/components/user-avatar.vue +++ b/src/layouts/modules/global-header/components/user-avatar.vue @@ -59,7 +59,7 @@ function logout() { positiveText: '确定', negativeText: '取消', onPositiveClick: () => { - authStore.resetStore(); + authStore.logout(); } }); } diff --git a/src/store/modules/auth/index.ts b/src/store/modules/auth/index.ts index d7d046a..6fbc21b 100644 --- a/src/store/modules/auth/index.ts +++ b/src/store/modules/auth/index.ts @@ -38,6 +38,12 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => { /** Is login */ const isLogin = computed(() => Boolean(token.value)); + function logout() { + clearAuthStorage(); + localStg.clear(); + toLogin(); + } + /** Reset auth store */ async function resetStore() { recordUserId(); @@ -187,6 +193,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => { loginLoading, resetStore, login, - initUserInfo + initUserInfo, + logout }; });