/** The routing of this file will not show the layout. It is an independent new page. the contents of the file still need to log in to access */ import { PageLayout } from '@eciol/layout'; import { mapTree } from '@eciol/shared'; import type { AppRouteModule } from '@eciol/types'; // import.meta.globEager() 直接引入所有的模块 Vite 独有的功能 const modules = import.meta.glob('./modules/demo/**/*.ts', { eager: true, }) as any; const routeModuleList: AppRouteModule[] = []; // 加入到路由集合中 Object.keys(modules).forEach((key) => { const mod = modules[key].default || {}; const modList = Array.isArray(mod) ? [...mod] : [mod]; routeModuleList.push(...modList); }); const _routeModuleList = mapTree( routeModuleList, (node) => { const result = { ...node, name: 'Doc' + node.name, path: node.path.replace(/^\//, '/doc-'), }; if (node.redirect) { result.redirect = (node.redirect as string).replace(/^\//, '/doc-'); } if (node.children?.length) { result.component = PageLayout; } return result; }, { children: 'children', }, ); // test // http:ip:port/main-out export const mainOutRoutes: AppRouteModule[] = [ { path: '/main-out', name: 'MainOut', component: () => import('@/views/demo/main-out/index.vue'), meta: { title: 'MainOut', ignoreAuth: true, }, }, // 文档使用,项目开发时请删除 ..._routeModuleList, ]; export const mainOutRouteNames = mainOutRoutes.map((item) => item.name);