From c7d4cc344003659d51bdf759cd7bd409b9948aa2 Mon Sep 17 00:00:00 2001 From: panqihua Date: Sat, 28 Jan 2023 22:24:08 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AE=8C=E5=96=84=E6=9D=83=E9=99=90=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8A=A8=E6=80=81=E8=B7=AF=E7=94=B1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/permission.js b/src/permission.js index 37fa9a9..6318528 100644 --- a/src/permission.js +++ b/src/permission.js @@ -28,12 +28,13 @@ router.beforeEach((to, from, next) => { // 自动跳转到根路由 let root = accessRoutes.find(item => item.path === '/') let _to - if (root && root.children.find(item => item.path.endsWith('index'))) { + if (to.fullPath === '/' && root && root.children.find(item => item.path.endsWith('index'))) { root.redirect = root.children.find(item => item.path.endsWith('/index')).path _to = { ...to, replace: true, path: root.redirect } } else { _to = { ...to, replace: true } } + // 根据roles权限生成可访问的路由表 router.addRoutes(accessRoutes) // 动态添加可访问路由表 next(_to) // hack方法 确保addRoutes已完成