|
|
|
|
@ -0,0 +1,60 @@
|
|
|
|
|
import { route } from '@/utils/tools';
|
|
|
|
|
const titleArr = [
|
|
|
|
|
{
|
|
|
|
|
key: 'init',
|
|
|
|
|
title: '初始化环境和工程',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// @/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/python/*.vue');
|
|
|
|
|
const secondLevelComponents = import.meta.glob('@/views/python/*/*.vue');
|
|
|
|
|
const components = { ...firstLevelComponents, ...secondLevelComponents };
|
|
|
|
|
|
|
|
|
|
const pythonRoutes = 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', '') : cptPath.replace('.vue', '');
|
|
|
|
|
cptPath = route.mergeDuplicatePathSegments(cptPath);
|
|
|
|
|
return {
|
|
|
|
|
path: cptPath,
|
|
|
|
|
name: route.convertPathToName(cptPath),
|
|
|
|
|
component: components[path],
|
|
|
|
|
meta: {
|
|
|
|
|
title: route.getTitleFromPathStr(titleArr, cptPath, '/python/'),
|
|
|
|
|
rank: route.getRankFromPathStr(titleArr, cptPath, '/python/'),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 子菜单自己实现排序,根据rank字段,默认值99
|
|
|
|
|
pythonRoutes.sort((a, b) => Number(a.meta.rank) - Number(b.meta.rank));
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
path: '/python',
|
|
|
|
|
redirect: '/python/init',
|
|
|
|
|
meta: {
|
|
|
|
|
icon: 'ep:data-analysis',
|
|
|
|
|
title: 'python示例',
|
|
|
|
|
rank: 1,
|
|
|
|
|
},
|
|
|
|
|
children: [...pythonRoutes],
|
|
|
|
|
} satisfies RouteConfigsTable;
|