diff --git a/apps/web-antdv-next/src/router/access.ts b/apps/web-antdv-next/src/router/access.ts index 1592b08..787f3bc 100644 --- a/apps/web-antdv-next/src/router/access.ts +++ b/apps/web-antdv-next/src/router/access.ts @@ -16,7 +16,7 @@ const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue'); async function generateAccess(options: GenerateMenuAndRoutesOptions) { const pageMap: ComponentRecordType = { - ...import.meta.glob('../views/**/*.tsx'), + ...import.meta.glob(['../views/**/*.tsx', '!../views/**/*.spec.tsx']), ...import.meta.glob('../views/**/*.vue'), }; diff --git a/apps/web-antdv-next/src/router/routes/index.ts b/apps/web-antdv-next/src/router/routes/index.ts index 15f6e5f..0e8c46c 100644 --- a/apps/web-antdv-next/src/router/routes/index.ts +++ b/apps/web-antdv-next/src/router/routes/index.ts @@ -4,9 +4,12 @@ import { mergeRouteModules, traverseTreeValues } from '@vben/utils'; import { coreRoutes, fallbackNotFoundRoute } from './core'; -const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', { - eager: true, -}); +const dynamicRouteFiles = import.meta.glob( + ['./modules/**/*.ts', '!./modules/**/*.spec.ts'], + { + eager: true, + }, +); // 有需要可以自行打开注释,并创建文件夹 // const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true }); @@ -30,7 +33,7 @@ const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name); const accessRoutes = [...dynamicRoutes, ...staticRoutes]; const componentKeys: string[] = Object.keys({ - ...import.meta.glob('../../views/**/*.tsx'), + ...import.meta.glob(['../../views/**/*.tsx', '!../../views/**/*.spec.tsx']), ...import.meta.glob('../../views/**/*.vue'), }) .filter((item) => !item.includes('/modules/'))