diff --git a/src/router/componentRegistry.js b/src/router/componentRegistry.js index 1cdce8a..14c8381 100644 --- a/src/router/componentRegistry.js +++ b/src/router/componentRegistry.js @@ -6,5 +6,18 @@ export const routePathComponentMap = { '/system/org': 'system/org/OrgList', '/system/permission': 'system/permission/PermissionList', '/base-config/channel': 'base-config/channel/ChannelList', - '/base-config/manager': 'base-config/manager/ManagerList' + '/base-config/manager': 'base-config/manager/ManagerList', + '/customer/personal': 'customer/personal/PersonalList', + '/customer/enterprise': 'customer/enterprise/EnterpriseList' } + +// 新增/编辑/查看等表单页不是后端菜单节点(不出现在侧边栏),但仍需要注册为 +// MainLayout 下的可访问路由,由列表页通过 router.push 跳转进入。 +export const extraChildRoutes = [ + { path: 'customer/personal/create', name: 'customer-personal-create', component: 'customer/personal/PersonalForm' }, + { path: 'customer/personal/edit', name: 'customer-personal-edit', component: 'customer/personal/PersonalForm' }, + { path: 'customer/personal/detail', name: 'customer-personal-detail', component: 'customer/personal/PersonalForm' }, + { path: 'customer/enterprise/create', name: 'customer-enterprise-create', component: 'customer/enterprise/EnterpriseForm' }, + { path: 'customer/enterprise/edit', name: 'customer-enterprise-edit', component: 'customer/enterprise/EnterpriseForm' }, + { path: 'customer/enterprise/detail', name: 'customer-enterprise-detail', component: 'customer/enterprise/EnterpriseForm' } +] diff --git a/src/router/dynamic.js b/src/router/dynamic.js index acd4563..6e874f9 100644 --- a/src/router/dynamic.js +++ b/src/router/dynamic.js @@ -1,5 +1,5 @@ import MainLayout from '@/layouts/MainLayout.vue' -import { routePathComponentMap } from './componentRegistry' +import { routePathComponentMap, extraChildRoutes } from './componentRegistry' const componentModules = import.meta.glob('@/views/**/*.vue') @@ -48,6 +48,13 @@ export function buildRouteRecords(menuTree) { export function installDynamicRoutes(router, menuTree) { const children = buildRouteRecords(menuTree) + extraChildRoutes.forEach((route) => { + children.push({ + path: route.path, + name: route.name, + component: resolveComponent(route.component) + }) + }) router.addRoute({ path: '/', component: MainLayout,