From a3a7eb6907f0c5063ea94418be2ce5badcf75b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Tue, 22 Mar 2022 22:52:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(router.ts):=20=E6=B7=BB=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=94=80=E6=97=B6=E9=87=8D=E7=BD=AE=E5=8A=A8=E6=80=81=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index cd7bfa38..730fbbef 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,4 +1,5 @@ import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router' +import useStore from "@/store"; export const Layout = () => import('@/layout/index.vue') @@ -42,9 +43,9 @@ export const constantRoutes: Array = [ name: 'Dashboard', meta: { title: 'dashboard', icon: 'dashboard', affix: true } } - ] + ] } - + // 外部链接 /*{ path: '/external-link', @@ -108,13 +109,13 @@ const router = createRouter({ // 重置路由 export function resetRouter() { - //TODO - /* router.getRoutes().forEach((route) => { + const { permission } = useStore() + permission.routes.forEach((route) => { const name = route.name - if (name) { - router.hasRoute(name) && router.removeRoute(name) + if (name && router.hasRoute(name)) { + router.removeRoute(name) } - }) */ + }) } export default router \ No newline at end of file