From bda7e396bb9ecbad5262e10e9e0703c2c3f2804b Mon Sep 17 00:00:00 2001 From: d3george Date: Thu, 25 Apr 2024 17:00:34 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=96=B0=E5=A2=9E=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=9B=9E=E9=9D=99=E6=80=81=E8=B7=AF=E7=94=B1=E7=9A=84=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/hooks/use-permission-routes.tsx | 5 +++++ src/router/routes/menu-routes.tsx | 4 ++-- src/router/utils.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/router/hooks/use-permission-routes.tsx b/src/router/hooks/use-permission-routes.tsx index b3e0fc63..303fad29 100644 --- a/src/router/hooks/use-permission-routes.tsx +++ b/src/router/hooks/use-permission-routes.tsx @@ -32,6 +32,11 @@ function resolveComponent(path: string) { * return routes about permission */ export function usePermissionRoutes() { + // 切换回静态路由 + // return useMemo(() => { + // return getRoutesFromModules(); + // }, []); + const permissions = useUserPermission(); return useMemo(() => { diff --git a/src/router/routes/menu-routes.tsx b/src/router/routes/menu-routes.tsx index fa9126e3..69e1089f 100644 --- a/src/router/routes/menu-routes.tsx +++ b/src/router/routes/menu-routes.tsx @@ -3,11 +3,11 @@ import { Navigate } from 'react-router-dom'; import DashboardLayout from '@/layouts/dashboard'; import AuthGuard from '../components/auth-guard'; -import { getMenuModules } from '../utils'; +import { getRoutesFromModules } from '../utils'; import { AppRouteObject } from '#/router'; -const menuModuleRoutes = getMenuModules(); +const menuModuleRoutes = getRoutesFromModules(); const { VITE_APP_HOMEPAGE: HOMEPAGE } = import.meta.env; diff --git a/src/router/utils.ts b/src/router/utils.ts index 4e96f4e6..fd7bfa8b 100644 --- a/src/router/utils.ts +++ b/src/router/utils.ts @@ -20,7 +20,7 @@ export const menuFilter = (items: AppRouteObject[]) => { /** * 基于 src/router/routes/modules 文件结构动态生成路由 */ -export function getMenuModules() { +export function getRoutesFromModules() { const menuModules: AppRouteObject[] = []; const modules = import.meta.glob('./routes/modules/**/*.tsx', { eager: true });