Skip to content

Commit fc0b8d0

Browse files
authored
Merge pull request #384 from actiontech/main
Sync main to main-ee
2 parents 766797d + 9cd259d commit fc0b8d0

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

packages/base/src/App.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import { useDispatch } from 'react-redux';
4646
import { updateModuleFeatureSupport } from './store/permission';
4747
import { ROUTE_PATHS } from '@actiontech/shared/lib/data/routePaths';
4848
import useSyncDmsCloudBeaverChannel from './hooks/useSyncDmsCloudBeaverChannel';
49-
import { cloneDeep } from 'lodash';
5049
import './index.less';
5150

5251
dayjs.extend(updateLocale);
@@ -136,20 +135,25 @@ function App() {
136135
const filterRoutesByPermission: (
137136
routes: RouterConfigItem[]
138137
) => 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;
142142
}
143-
144143
if (route.children) {
145-
route.children = filterRoutesByPermission(route.children);
144+
acc.push({
145+
...route,
146+
children: filterRoutesByPermission(route.children)
147+
});
148+
return acc;
146149
}
147-
148-
return true;
149-
});
150+
acc.push(route);
151+
return acc;
152+
}, verifiedRoutes);
150153
};
154+
151155
if (isUserInfoFetched && isFeatureSupportFetched) {
152-
return filterRoutesByPermission(cloneDeep(AuthRouterConfig));
156+
return filterRoutesByPermission(AuthRouterConfig);
153157
}
154158
return AuthRouterConfig;
155159
}, [checkPagePermission, isFeatureSupportFetched, isUserInfoFetched]);

0 commit comments

Comments
 (0)