diff --git a/config/config.ts b/config/config.ts index 12835484..d4209c29 100644 --- a/config/config.ts +++ b/config/config.ts @@ -113,6 +113,15 @@ export default { icon: 'crown', component: './Admin', authority: ['admin'], + routes: [ + { + path: '/admin/sub-page', + name: 'sub-page', + icon: 'smile', + component: './Welcome', + authority: ['admin'], + }, + ], }, { component: './404', diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 82e14a32..9ba73c20 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -30,11 +30,15 @@ export const getPageQuery = () => parse(window.location.href.split('?')[1]); * @param router [{}] * @param pathname string */ -export const getAuthorityFromRouter = ( +export const getAuthorityFromRouter = ( router: T[] = [], pathname: string, ): T | undefined => { - const authority = router.find(({ path }) => path && pathRegexp(path).exec(pathname)); + const authority = router.find( + ({ routes, path = '/' }) => + (path && pathRegexp(path).exec(pathname)) || + (routes && getAuthorityFromRouter(routes, pathname)), + ); if (authority) return authority; return undefined; };