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 }; });