File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change
1
+ import type { RouterContextType } from '@/features/router' ;
2
+ import { useInitAuthRoutes } from '@/features/router' ;
3
+
4
+ const { VITE_AUTH_ROUTE_MODE , VITE_STATIC_SUPER_ROLE } = import . meta. env ;
5
+
1
6
export function useInitAuth ( ) {
2
- if ( authRouteMode === 'static' ) {
3
- dispatch ( initStaticAuthRoute ( ) ) ;
4
- } else {
5
- await dispatch ( initDynamicAuthRoute ( ) ) ;
6
- }
7
- const routeHomeName = getRouteHome ( getState ( ) ) ;
7
+ const { initAuthRoutes } = useInitAuthRoutes ( ) ;
8
8
9
- const homeRoute = router . getRouteByName ( routeHomeName ) ;
9
+ function initAuth ( roles : string [ ] , addRoutes : RouterContextType [ 'addRoutes' ] ) {
10
+ const isStaticSuper = VITE_AUTH_ROUTE_MODE === 'static' && roles . includes ( VITE_STATIC_SUPER_ROLE ) ;
11
+
12
+ if ( isStaticSuper ) {
13
+ initAuthRoutes ( isStaticSuper , roles , addRoutes ) ;
14
+ }
15
+ }
10
16
11
- if ( homeRoute ) dispatch ( initHomeTab ( { homeRouteName : routeHomeName as LastLevelRouteKey , route : homeRoute } ) ) ;
17
+ return {
18
+ initAuth
19
+ } ;
12
20
}
You can’t perform that action at this time.
0 commit comments