feat: support the dynamic introduction and sorting of routes
This commit is contained in:
@@ -1,24 +1,28 @@
|
||||
import { mergeRouteModules } from '@vben-core/helpers';
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import { essentialRoutes } from './_essential';
|
||||
import { nestedRoutes } from './modules/nested';
|
||||
import { outsideRoutes } from './modules/outside';
|
||||
import { rootRoutes } from './modules/root';
|
||||
import { vbenRoutes } from './modules/vben';
|
||||
|
||||
const dynamicRouteFiles = import.meta.glob('./dynamic/**/*.ts', {
|
||||
eager: true,
|
||||
});
|
||||
|
||||
const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true });
|
||||
|
||||
const externalRouteFiles = import.meta.glob('./external/**/*.ts', {
|
||||
eager: true,
|
||||
});
|
||||
|
||||
/** 动态路由 */
|
||||
const dynamicRoutes: RouteRecordRaw[] = [
|
||||
// 根路由
|
||||
...rootRoutes,
|
||||
...nestedRoutes,
|
||||
...outsideRoutes,
|
||||
...vbenRoutes,
|
||||
];
|
||||
|
||||
/** 排除在主框架外的路由,这些路由没有菜单和顶部及其他框架内容 */
|
||||
const externalRoutes: RouteRecordRaw[] = [];
|
||||
const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
|
||||
|
||||
/** 静态路由列表,访问这些页面可以不需要权限 */
|
||||
const staticRoutes: RouteRecordRaw[] = [...essentialRoutes];
|
||||
const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
|
||||
|
||||
export { dynamicRoutes, externalRoutes, staticRoutes };
|
||||
/** 排除在主框架外的路由,这些路由没有菜单和顶部及其他框架内容 */
|
||||
const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
|
||||
|
||||
/** 路由列表,由基本路由+静态路由组成 */
|
||||
const routes: RouteRecordRaw[] = [...essentialRoutes, ...staticRoutes];
|
||||
|
||||
export { dynamicRoutes, externalRoutes, routes };
|
||||
|
Reference in New Issue
Block a user