mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 14:47:28 +08:00
refactor: refactoring menu generation
This commit is contained in:
4
src/utils/helper/dynamicImport.ts
Normal file
4
src/utils/helper/dynamicImport.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export default function (id: string) {
|
||||
const dynamicImportModule: any = id;
|
||||
return dynamicImportModule;
|
||||
}
|
@@ -6,6 +6,8 @@ import { tabStore } from '/@/store/modules/tab';
|
||||
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||
import { toRaw } from 'vue';
|
||||
import { PAGE_LAYOUT_COMPONENT } from '/@/router/constant';
|
||||
// import { isDevMode } from '/@/utils/env';
|
||||
import dynamicImport from './dynamicImport';
|
||||
|
||||
let currentTo: RouteLocationNormalized | null = null;
|
||||
|
||||
@@ -45,12 +47,12 @@ export function genRouteModule(moduleList: AppRouteModule[]) {
|
||||
// TODO 错误写法
|
||||
function asyncImportRoute(routes: AppRouteRecordRaw[]) {
|
||||
routes.forEach((item) => {
|
||||
let { component } = item;
|
||||
const { component } = item;
|
||||
const { children } = item;
|
||||
if (component) {
|
||||
component = component.replace(/^\//, '');
|
||||
item.component = () => import(`/@/views/${component}`);
|
||||
item.component = dynamicImport(component);
|
||||
}
|
||||
|
||||
children && asyncImportRoute(children);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user