77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
import type { ComponentItem } from 'open-data-v/designer'
|
|
|
|
import type { GroupType } from '@/enum'
|
|
import { ComponentGroupList } from '@/enum'
|
|
import { NothingLayout } from '@/layout'
|
|
import { camel2snake } from '@/utils/utils'
|
|
|
|
const getComponents = () => {
|
|
const componentDocs: Array<ComponentItem> = ComponentGroupList.map((el: GroupType) => {
|
|
return {
|
|
label: el.name,
|
|
key: el.key,
|
|
icon: el.icon,
|
|
children: []
|
|
}
|
|
})
|
|
const moduleFilesTs: any = import.meta.glob('../../resource/components/**/index.ts', {
|
|
eager: true
|
|
})
|
|
Object.keys(moduleFilesTs).forEach((key: string) => {
|
|
const componentOptions = moduleFilesTs[key]?.default
|
|
const componentInstance = new componentOptions.config()
|
|
const docs = componentDocs.filter((el) => el.key === componentInstance.group)
|
|
if (docs.length > 0) {
|
|
docs[0].children.push({
|
|
key: componentInstance.component,
|
|
label: componentInstance.name,
|
|
docs: componentOptions.docs ? componentOptions.docs : () => import('docs/Content/Empty.vue')
|
|
})
|
|
}
|
|
})
|
|
return componentDocs.map((ele) => {
|
|
return {
|
|
path: ele.key.toLocaleLowerCase(),
|
|
name: ele.key,
|
|
component: NothingLayout,
|
|
meta: {
|
|
title: ele.label,
|
|
icon: ele.icon,
|
|
ignoreAuth: true,
|
|
hideInMenu: true
|
|
},
|
|
children: ele.children.map((el) => {
|
|
return {
|
|
path: camel2snake(el.key),
|
|
name: el.key,
|
|
component: el.docs,
|
|
meta: {
|
|
title: el.label,
|
|
ignoreAuth: true,
|
|
hideInMenu: true
|
|
}
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
const basicRoutes = [
|
|
{
|
|
path: '/docs',
|
|
name: 'Docs',
|
|
component: () => import('docs/Site.vue'),
|
|
redirect: '/docs/quick-satrt/intro',
|
|
meta: {
|
|
title: '文档',
|
|
icon: 'docs',
|
|
ignoreAuth: true,
|
|
hideInMenu: true
|
|
},
|
|
children: [
|
|
|
|
]
|
|
}
|
|
]
|
|
export default basicRoutes
|