You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
const Layout = () => import('@/layout/index.vue');
|
|
import { route } from '@/utils/tools';
|
|
const titleArr = [
|
|
{
|
|
key: 'jsx',
|
|
title: '使用jsx',
|
|
},
|
|
{
|
|
key: 'tools',
|
|
title: '工具方法',
|
|
},
|
|
{
|
|
key: 'importOrExportExcel',
|
|
title: '导入导出excel',
|
|
},
|
|
];
|
|
|
|
// @/views/demo/**/*.vue
|
|
/**
|
|
* (使用 ** 表示递归查找)
|
|
* 递归匹配views/demo目录下所有.vue文件
|
|
* 也包含/demo/jsx/components/index.vue 这种某个页面的子组件
|
|
*/
|
|
|
|
// @/views/demo/*.vue 第一层目录
|
|
// @/views/demo/*/*.vue 第二层目录
|
|
/**
|
|
* 第一层目录 => 匹配views/demo目录下所有.vue文件(第一层)
|
|
* 例如 /views/demo/index.vue
|
|
*
|
|
* 第二层目录 => 匹配views/demo目录下所有文件夹下的.vue文件(第二层)
|
|
* 例如 /views/demo/jsx/index.vue
|
|
*
|
|
* 不会匹配/views/demo/jsx/components/index.vue 这种某个页面的子组件
|
|
*/
|
|
|
|
const firstLevelComponents = import.meta.glob('@/views/demo/*.vue');
|
|
const secondLevelComponents = import.meta.glob('@/views/demo/*/*.vue');
|
|
const components = { ...firstLevelComponents, ...secondLevelComponents };
|
|
|
|
const demoRoutes = Object.keys(components).map((path) => {
|
|
const isHasIndex = path.includes('/index.vue');
|
|
let cptPath = path.replace(route.FILE_NAME_PREFIX, '');
|
|
cptPath = isHasIndex ? cptPath.replace('/index.vue', '') : path.replace('.vue', '');
|
|
return {
|
|
path: cptPath,
|
|
name: route.convertPathToName(cptPath),
|
|
component: components[path],
|
|
meta: {
|
|
title: route.getTitleFromPathStr(titleArr, cptPath),
|
|
},
|
|
};
|
|
});
|
|
|
|
export default {
|
|
path: '/demo',
|
|
name: 'Demo',
|
|
component: Layout,
|
|
redirect: '/demo/jsx',
|
|
meta: {
|
|
icon: 'ep:data-analysis',
|
|
title: '示例',
|
|
rank: 1,
|
|
},
|
|
children: [...demoRoutes],
|
|
} satisfies RouteConfigsTable;
|