@@ -46,7 +46,6 @@ import { useDispatch } from 'react-redux';
46
46
import { updateModuleFeatureSupport } from './store/permission' ;
47
47
import { ROUTE_PATHS } from '@actiontech/shared/lib/data/routePaths' ;
48
48
import useSyncDmsCloudBeaverChannel from './hooks/useSyncDmsCloudBeaverChannel' ;
49
- import { cloneDeep } from 'lodash' ;
50
49
import './index.less' ;
51
50
52
51
dayjs . extend ( updateLocale ) ;
@@ -136,20 +135,25 @@ function App() {
136
135
const filterRoutesByPermission : (
137
136
routes : RouterConfigItem [ ]
138
137
) => RouterConfigItem [ ] = ( routes ) => {
139
- return routes . filter ( ( route ) => {
140
- if ( route . permission ) {
141
- return checkPagePermission ( route . permission ) ;
138
+ const verifiedRoutes : RouterConfigItem [ ] = [ ] ;
139
+ return routes . reduce ( ( acc , route ) => {
140
+ if ( route . permission && ! checkPagePermission ( route . permission ) ) {
141
+ return acc ;
142
142
}
143
-
144
143
if ( route . children ) {
145
- route . children = filterRoutesByPermission ( route . children ) ;
144
+ acc . push ( {
145
+ ...route ,
146
+ children : filterRoutesByPermission ( route . children )
147
+ } ) ;
148
+ return acc ;
146
149
}
147
-
148
- return true ;
149
- } ) ;
150
+ acc . push ( route ) ;
151
+ return acc ;
152
+ } , verifiedRoutes ) ;
150
153
} ;
154
+
151
155
if ( isUserInfoFetched && isFeatureSupportFetched ) {
152
- return filterRoutesByPermission ( cloneDeep ( AuthRouterConfig ) ) ;
156
+ return filterRoutesByPermission ( AuthRouterConfig ) ;
153
157
}
154
158
return AuthRouterConfig ;
155
159
} , [ checkPagePermission , isFeatureSupportFetched , isUserInfoFetched ] ) ;
0 commit comments