catchAdmin/resources/admin/router/constantRoutes.ts

20 lines
685 B
TypeScript
Raw Normal View History

2022-12-05 23:01:12 +08:00
import { RouteRecordRaw } from 'vue-router'
2023-01-11 17:21:16 +08:00
import { isUndefined } from '/admin/support/helper'
2022-12-05 23:01:12 +08:00
// @ts-ignore
2022-12-10 18:29:42 +08:00
export function getModuleRoutes() {
const modules = import.meta.glob('@/module/**/views/router.ts', { eager: true })
let moduleRoutes: RouteRecordRaw[] = []
2022-12-05 23:01:12 +08:00
2022-12-10 18:29:42 +08:00
Object.keys(modules).forEach(routePath => {
2023-01-11 17:21:16 +08:00
if (!isUndefined(modules[routePath].default)) {
moduleRoutes = moduleRoutes.concat(modules[routePath].default)
}
2022-12-10 18:29:42 +08:00
})
return moduleRoutes
}
export function getModuleViewComponents() {
return import.meta.glob(['@/module/**/views/**/*.vue', '@/module/!User/views/**/*.vue', '@/module/!Develop/views/**/*.vue', '@/module/!Options/views/**/*.vue'])
}