From 5ccdb17e0d8a7fbf21a6013bce0dd1365c5eaeaf Mon Sep 17 00:00:00 2001 From: Soybean Date: Sun, 8 Sep 2024 18:21:31 +0800 Subject: [PATCH] fix(projects): fix(projects): fix login redirect --- src/hooks/common/router.ts | 10 +++++++--- src/store/modules/auth/index.ts | 4 +--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/hooks/common/router.ts b/src/hooks/common/router.ts index f95a25a..4a43342 100644 --- a/src/hooks/common/router.ts +++ b/src/hooks/common/router.ts @@ -93,11 +93,15 @@ export function useRouterPush(inSetup = true) { return routerPushByKey('login', { query, params: { module } }); } - /** Redirect from login */ - async function redirectFromLogin() { + /** + * Redirect from login + * + * @param [needRedirect=true] Whether to redirect after login. Default is `true` + */ + async function redirectFromLogin(needRedirect = true) { const redirect = route.value.query?.redirect as string; - if (redirect) { + if (needRedirect && redirect) { routerPush(redirect); } else { toHome(); diff --git a/src/store/modules/auth/index.ts b/src/store/modules/auth/index.ts index 4ac33a9..14aabe9 100644 --- a/src/store/modules/auth/index.ts +++ b/src/store/modules/auth/index.ts @@ -71,9 +71,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => { if (pass) { await routeStore.initAuthRoute(); - if (redirect) { - await redirectFromLogin(); - } + await redirectFromLogin(redirect); if (routeStore.isInitAuthRoute) { window.$notification?.success({