From 42c4f6c346b9e8b0af826909b680a59ff5185819 Mon Sep 17 00:00:00 2001 From: hooray <304327508@qq.com> Date: Wed, 24 Nov 2021 14:51:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=88=98=E7=95=A5=E5=90=88?= =?UTF-8?q?=E4=BD=9C=E5=AF=BC=E8=88=AA=E6=A0=8F=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/icons/sidebar-cooperation.svg | 1 + src/router/index.js | 14 +++++++++++++- src/router/modules/cooperation.example.js | 8 ++++++++ src/store/modules/menu.js | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/assets/icons/sidebar-cooperation.svg create mode 100644 src/router/modules/cooperation.example.js diff --git a/src/assets/icons/sidebar-cooperation.svg b/src/assets/icons/sidebar-cooperation.svg new file mode 100644 index 00000000..a951dccf --- /dev/null +++ b/src/assets/icons/sidebar-cooperation.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index c9b2f271..4d69a392 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -67,6 +67,7 @@ import PermissionExample from './modules/permission.example' import MockExample from './modules/mock.example' import ExternalLinkExample from './modules/external.link.example' import VideosExample from './modules/videos.example' +import CooperationExample from './modules/cooperation.example' // 动态路由(异步路由、导航栏路由) const asyncRoutes = [ @@ -94,6 +95,15 @@ const asyncRoutes = [ children: [ ...VideosExample ] + }, + { + meta: { + title: '战略合作', + icon: 'sidebar-cooperation' + }, + children: [ + ...CooperationExample + ] } ] @@ -158,7 +168,9 @@ router.beforeEach(async(to, from, next) => { accessRoutes.push(lastRoute) let removeRoutes = [] accessRoutes.forEach(route => { - removeRoutes.push(router.addRoute(route)) + if (!/^(https?:|mailto:|tel:)/.test(route.path)) { + removeRoutes.push(router.addRoute(route)) + } }) // 记录的 accessRoutes 路由数据,在登出时会使用到,不使用 router.removeRoute 是考虑配置的路由可能不一定有设置 name ,则通过调用 router.addRoute() 返回的回调进行删除 store.commit('menu/setCurrentRemoveRoutes', removeRoutes) diff --git a/src/router/modules/cooperation.example.js b/src/router/modules/cooperation.example.js new file mode 100644 index 00000000..94e317ce --- /dev/null +++ b/src/router/modules/cooperation.example.js @@ -0,0 +1,8 @@ +export default [ + { + path: 'https://www.vform666.com', + meta: { + title: 'VForm 低代码表单' + } + } +] diff --git a/src/store/modules/menu.js b/src/store/modules/menu.js index 669b4951..139c3532 100644 --- a/src/store/modules/menu.js +++ b/src/store/modules/menu.js @@ -252,7 +252,7 @@ const mutations = { let defaultOpenedPaths = [] routes.map(item => { item.meta.defaultOpened && defaultOpenedPaths.push(item.path) - item.children.map(child => { + item.children && item.children.map(child => { child.meta.defaultOpened && defaultOpenedPaths.push(path.resolve(item.path, child.path)) }) })