From 71590645cdf0203e7fe8ebef862bb1b5cdf46ec3 Mon Sep 17 00:00:00 2001 From: Kven <2955163637@qq.com> Date: Tue, 17 Jun 2025 11:14:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor(@vben/web-antd):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20logout=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 logout函数的 redirect 参数 - 注释掉 redirect 相关的代码逻辑 - 更新调用 logout 函数的地方,移除参数传递 --- apps/web-antd/src/layouts/basic.vue | 3 ++- apps/web-antd/src/router/guard.ts | 10 +++++----- apps/web-antd/src/store/auth.ts | 12 ++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/web-antd/src/layouts/basic.vue b/apps/web-antd/src/layouts/basic.vue index 5e0f2a4..569acc4 100644 --- a/apps/web-antd/src/layouts/basic.vue +++ b/apps/web-antd/src/layouts/basic.vue @@ -13,6 +13,7 @@ import { } from '@vben/layouts'; import { preferences } from '@vben/preferences'; import { useAccessStore, useUserStore } from '@vben/stores'; + import { useAuthStore } from '#/store'; import LoginForm from '#/views/_core/authentication/login.vue'; @@ -66,7 +67,7 @@ const roleDescription = computed(() => { }); async function handleLogout() { - await authStore.logout(false); + await authStore.logout(); } function handleNoticeClear() { diff --git a/apps/web-antd/src/router/guard.ts b/apps/web-antd/src/router/guard.ts index 60f82d3..cd3794f 100644 --- a/apps/web-antd/src/router/guard.ts +++ b/apps/web-antd/src/router/guard.ts @@ -77,12 +77,12 @@ function setupAccessGuard(router: Router) { return { path: LOGIN_PATH, // 如不需要,直接删除 query - query: - to.fullPath === DEFAULT_HOME_PATH - ? {} - : { redirect: encodeURIComponent(to.fullPath) }, + // query: + // to.fullPath === DEFAULT_HOME_PATH + // ? {} + // : { redirect: encodeURIComponent(to.fullPath) }, // 携带当前跳转的页面,登录后重新跳转该页面 - replace: true, + // replace: true, }; } return to; diff --git a/apps/web-antd/src/store/auth.ts b/apps/web-antd/src/store/auth.ts index 2f40f74..f39af97 100644 --- a/apps/web-antd/src/store/auth.ts +++ b/apps/web-antd/src/store/auth.ts @@ -86,7 +86,7 @@ export const useAuthStore = defineStore('auth', () => { }; } - async function logout(redirect: boolean = true) { + async function logout() { try { await logoutApi(); } catch { @@ -98,11 +98,11 @@ export const useAuthStore = defineStore('auth', () => { // 回登录页带上当前路由地址 await router.replace({ path: LOGIN_PATH, - query: redirect - ? { - redirect: encodeURIComponent(router.currentRoute.value.fullPath), - } - : {}, + // query: redirect + // ? { + // redirect: encodeURIComponent(router.currentRoute.value.fullPath), + // } + // : {}, }); }