diff --git a/src/router/base.ts b/src/router/base.ts index a666697..9d566e7 100644 --- a/src/router/base.ts +++ b/src/router/base.ts @@ -27,23 +27,20 @@ export const ErrorPageRoute: AppRouteRecordRaw = { export const AboutPageRoute: AppRouteRecordRaw ={ - path: '/about', - name: 'about', + path: '/monitorJob', + name: 'monitorJob', component: Layout, meta: { sort: 12, isRoot: true, - activeMenu: 'about_index', - alwaysShow: true, icon: renderIcon(ProjectOutlined), }, children: [ { - path: 'index', - name: `about_index`, + path: 'log', + name: `monitorJob`, meta: { title: '关于项目', - activeMenu: 'about_index', }, component: () => import('@/views/about/index.vue'), }, diff --git a/src/router/generator-routers.ts b/src/router/generator-routers.ts index 44c3f0e..0bd5a19 100644 --- a/src/router/generator-routers.ts +++ b/src/router/generator-routers.ts @@ -20,22 +20,32 @@ LayoutMap.set('IFRAME', Iframe); */ export const routerGenerator = (routerMap, parent?): any[] => { return routerMap.map((item) => { + const names = /http(s)?:/.test(item.path)?item.path:item.path.replaceAll('/','') item.meta = { - title:item.name, + title:item.parentId==0 && item.children.length==0?'':item.name, icon:item.icon, sort:item.sort, permissions:item.permission, hidden: item.hide?true:false, + isRoot:item.parentId==0 && item.children.length==0?true:false, + alwaysShow: item.parentId==0 && item.children.length==0?true:false, + frameSrc: item.target==1?item.component:'', + } + let components = '' + if(item.parentId==0 && item.children.length==0) { + components ='LAYOUT' + } else if(item.target==0) { + components = item.component + } else if(item.target==1) { + components ='IFRAME' } - const components ='' - const names = /http(s)?:/.test(item.path)?item.path:item.path.replaceAll('/','') const currentRouter: any = { // 路由地址 动态拼接生成如 /dashboard/workplace - path: `${item.path}`, + path: item.target!=2?item.path:'', // 路由名称,建议唯一 name: names, // 该路由对应页面的 组件 - component: item.component, + component: components, // meta: 页面标题, 菜单图标, 页面权限(供指令权限用,可去掉) meta: { ...item.meta, @@ -44,9 +54,8 @@ export const routerGenerator = (routerMap, parent?): any[] => { permissions: item.meta.permissions || null, }, }; - // 为了防止出现后端返回结果不规范,处理有可能出现拼接出两个 反斜杠 - currentRouter.path = currentRouter.path.replace('//', '/'); + // currentRouter.path = currentRouter.path.replace('//', '/'); // 重定向 item.redirect && (currentRouter.redirect = item.redirect); // 是否有子菜单,并递归处理 @@ -55,6 +64,31 @@ export const routerGenerator = (routerMap, parent?): any[] => { !item.redirect && (currentRouter.redirect = `${item.children[0].path}`); // Recursion currentRouter.children = routerGenerator(item.children, currentRouter); + } else { + if(item.parentId==0 && item.children.length==0) { + currentRouter.children =[] + if(item.target==1){ + currentRouter.children.push({ + path: item.path, + name: names, + meta: { + title: item.name, + frameSrc: item.component, + }, + component: 'IFRAME', + }) + } else { + currentRouter.children.push({ + path: item.path, + name: names, + meta: { + title: item.name, + activeMenu: names, + }, + component: item.component, + }) + } + } } return currentRouter; }); @@ -69,6 +103,7 @@ export const generatorDynamicRouter = (): Promise => { adminMenus() .then((result) => { const routeList = routerGenerator(result); + console.log(routeList) asyncImportRoute(routeList); resolve(routeList); }) diff --git a/src/settings/projectSetting.ts b/src/settings/projectSetting.ts index 5479cb0..bda3a60 100644 --- a/src/settings/projectSetting.ts +++ b/src/settings/projectSetting.ts @@ -41,7 +41,7 @@ const setting = { //折叠 collapsed: false, //手风琴 - uniqueOpened: false, + uniqueOpened: true, }, //面包屑 crumbsSetting: { diff --git a/src/views/system/menu/edit.vue b/src/views/system/menu/edit.vue index aab45f8..a4f56f7 100644 --- a/src/views/system/menu/edit.vue +++ b/src/views/system/menu/edit.vue @@ -55,14 +55,15 @@
- - + 组件 + 内链 + 外链
选择外链,则新窗口打开页面 @@ -82,15 +83,15 @@ clearable />
- 访问的路由地址,如:`admin`,如外网地址需内链访问则以`http(s)://`开头 + 访问的路由地址
- 访问的组件路径,如:`permission/admin/index`,默认在`views`目录下 + 访问的组件路径,如:`permission/admin/index`,默认在`views`目录下,如外网地址需内链访问则以`http(s)://`开头