Skip to content

Commit

Permalink
fix(projects): fix(projects): fix login redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Sep 8, 2024
1 parent 75df11c commit 5ccdb17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/hooks/common/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions src/store/modules/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 5ccdb17

Please sign in to comment.