File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import type {
6
6
Router
7
7
} from 'vue-router' ;
8
8
import type { RouteKey , RoutePath } from '@elegant-router/types' ;
9
+ import { getRouteName } from '@/router/elegant/transform' ;
9
10
import { useAuthStore } from '@/store/modules/auth' ;
10
11
import { useRouteStore } from '@/store/modules/route' ;
11
12
import { localStg } from '@/utils/storage' ;
@@ -150,8 +151,16 @@ async function initRoute(to: RouteLocationNormalized): Promise<RouteLocationRaw
150
151
if ( ! isLogin ) {
151
152
const loginRoute : RouteKey = 'login' ;
152
153
const redirect = to . fullPath ;
154
+ const [ redirectPath , redirectQuery ] = redirect . split ( '?' ) ;
155
+ const redirectName = getRouteName ( redirectPath as RoutePath ) ;
153
156
154
- const query : LocationQueryRaw = to . name !== loginRoute ? { redirect } : { } ;
157
+ const isRedirectHome = routeStore . routeHome === redirectName || import . meta. env . VITE_ROUTE_HOME === redirectName ;
158
+
159
+ const query : LocationQueryRaw = to . name !== loginRoute && ! isRedirectHome ? { redirect } : { } ;
160
+
161
+ if ( isRedirectHome && redirectQuery ) {
162
+ query . redirect = `/?${ redirectQuery } ` ;
163
+ }
155
164
156
165
const location : RouteLocationRaw = {
157
166
name : loginRoute ,
You can’t perform that action at this time.
0 commit comments