From 5b7fd4888e02a5f4b84c113e18e5c3c68e3f48bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Fri, 3 Jun 2022 23:03:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=98=E5=8C=96:=20?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=B9=BE=E5=9D=A4=E5=89=8D=E7=AB=AF=E5=BE=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/package.json | 1 + web/src/App.vue | 2 + web/src/router/index.js | 9 +++ web/src/router/routes.js | 121 +-------------------------------------- 4 files changed, 13 insertions(+), 120 deletions(-) diff --git a/web/package.json b/web/package.json index be3729b..ee65673 100644 --- a/web/package.json +++ b/web/package.json @@ -36,6 +36,7 @@ "lodash": "^4.17.15", "lowdb": "^1.0.0", "nprogress": "^0.2.0", + "qiankun": "^2.7.2", "screenfull": "^5.0.2", "sortablejs": "^1.10.1", "ua-parser-js": "^0.7.20", diff --git a/web/src/App.vue b/web/src/App.vue index 7f3c9c6..7c3db52 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -1,6 +1,8 @@ diff --git a/web/src/router/index.js b/web/src/router/index.js index b237907..6d19422 100644 --- a/web/src/router/index.js +++ b/web/src/router/index.js @@ -75,6 +75,15 @@ router.beforeEach(async (to, from, next) => { }) } else { next() + const childrenPath = window.qiankunActiveRule || [] + if (to.name) { + // 有 name 属性,说明是主应用的路由 + next() + } else if (childrenPath.some((item) => to.path.includes(item))) { + next() + } else { + next({ name: '404' }) + } } } else { // 没有登录的时候跳转到登录界面 diff --git a/web/src/router/routes.js b/web/src/router/routes.js index 7d9b192..7e03791 100644 --- a/web/src/router/routes.js +++ b/web/src/router/routes.js @@ -29,34 +29,6 @@ const frameIn = [{ }, component: () => import('@/layout/header-aside/components/header-user/userinfo') }, - // 演示页面 - { - path: 'page1', - name: 'page1', - meta: { - title: '页面 1', - auth: true - }, - component: _import('demo/page1') - }, - { - path: 'page2', - name: 'page2', - meta: { - title: '页面 2', - auth: true - }, - component: _import('demo/page2') - }, - { - path: 'page3', - name: 'page3', - meta: { - title: '页面 3', - auth: true - }, - component: _import('demo/page3') - }, // dashboard 工作台 { path: 'workbench', @@ -67,97 +39,6 @@ const frameIn = [{ }, component: _import('dashboard/workbench') }, - // // 系统 菜单 - // { - // path: 'menu', - // name: 'menu', - // meta: { - // title: '菜单', - // auth: true - // }, - // component: _import('system/menu') - // }, - // // 系统 用户 - // { - // path: 'user', - // name: 'user', - // meta: { - // title: '用户', - // auth: true - // }, - // component: _import('system/user') - // }, - // // 系统 按钮配置 - // { - // path: 'button', - // name: 'button', - // meta: { - // title: '按钮', - // auth: true - // }, - // component: _import('system/button') - // }, - // // // 系统 菜单权限 - // { - // path: 'menuButton/:id', - // name: 'menuButton', - // meta: { - // title: '菜单按钮', - // auth: true - // }, - // component: _import('system/menuButton') - // }, - // // 系统 角色管理 - // { - // path: 'role', - // name: 'role', - // meta: { - // title: '角色', - // auth: true - // }, - // component: _import('system/role') - // }, - // // 系统 角色权限 - // { - // path: 'rolePermission', - // name: 'rolePermission', - // meta: { - // title: '权限管理', - // auth: true - // }, - // component: _import('system/rolePermission') - // }, - - // // 系统 角色管理 - // { - // path: 'dept', - // name: 'dept', - // meta: { - // title: '部门', - // auth: true - // }, - // component: _import('system/dept') - // }, - // // 系统 操作日志 - // { - // path: 'operationLog', - // name: 'operationLog', - // meta: { - // title: '操作日志', - // auth: true - // }, - // component: _import('system/log/operationLog') - // }, - // 系统 前端日志 - // { - // path: 'frontendLog', - // name: 'frontendLog', - // meta: { - // title: '前端日志', - // auth: true - // }, - // component: _import('system/log/frontendLog') - // }, // 刷新页面 必须保留 { path: 'refresh', @@ -201,7 +82,7 @@ if (pluginsType) { * 错误页面 */ const errorPage = [{ - path: '*', + path: '/404', name: '404', component: _import('system/error/404') }]