fix(router.ts): 添加注销时重置动态路由方法

This commit is contained in:
郝先瑞
2022-03-22 22:52:08 +08:00
parent 5f7728d094
commit a3a7eb6907

View File

@@ -1,4 +1,5 @@
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router' import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import useStore from "@/store";
export const Layout = () => import('@/layout/index.vue') export const Layout = () => import('@/layout/index.vue')
@@ -42,9 +43,9 @@ export const constantRoutes: Array<RouteRecordRaw> = [
name: 'Dashboard', name: 'Dashboard',
meta: { title: 'dashboard', icon: 'dashboard', affix: true } meta: { title: 'dashboard', icon: 'dashboard', affix: true }
} }
] ]
} }
// 外部链接 // 外部链接
/*{ /*{
path: '/external-link', path: '/external-link',
@@ -108,13 +109,13 @@ const router = createRouter({
// 重置路由 // 重置路由
export function resetRouter() { export function resetRouter() {
//TODO const { permission } = useStore()
/* router.getRoutes().forEach((route) => { permission.routes.forEach((route) => {
const name = route.name const name = route.name
if (name) { if (name && router.hasRoute(name)) {
router.hasRoute(name) && router.removeRoute(name) router.removeRoute(name)
} }
}) */ })
} }
export default router export default router