From bcecd6833c196006463ffdb387251e19b86a4a52 Mon Sep 17 00:00:00 2001 From: XiaoMo Date: Thu, 31 Aug 2023 15:43:33 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20src/router/index.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 恢复原文件 --- src/router/index.js | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 2fbd18e..5e770b4 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -24,9 +24,9 @@ const routes_404 = { path: "/:pathMatch(.*)*", hidden: true, component: () => - import( /* webpackChunkName: "404" */ '@/layout/other/404'), + import ( /* webpackChunkName: "404" */ '@/layout/other/404'), } -let routes_404_r = () => { } +let routes_404_r = () => {} const router = createRouter({ history: createWebHashHistory(), routes: routes @@ -72,19 +72,6 @@ router.beforeEach(async (to, from, next) => { api.system.index.get().then((response) => { if (response.code == 200) { // 缓存 - // console.log(response.data) - response.data.menu[1].children.push({ - component: "system/application", - meta:{ type: "application", icon: "x-icon-chrome-filled", title: "应用插件管理", app: "admin" }, - app:"admin", - icon:"x-icon-code", - title:"应用插件管理", - type:"application", - name:"systemapplication", - path:"/system/application", - redirect:"" - }) - for (const key in response.data) { tool.data.set(key, response.data[key]); if (key == 'layout') { @@ -158,24 +145,22 @@ function filterAsyncRouter(routerMap) { function loadComponent(component) { if (component) { return () => - import(`@/views/${component}`) + import (`@/views/${component}`) } else { return () => - import(`@/layout/other/empty`) + import (`@/layout/other/empty`) } } //路由扁平化 function flatAsyncRoutes(routes, breadcrumb = []) { let res = [] routes.forEach(route => { - const tmp = { - ...route + const tmp = { ...route } if (tmp.children) { let childrenBreadcrumb = [...breadcrumb] childrenBreadcrumb.push(route) - let tmpRoute = { - ...route + let tmpRoute = { ...route } tmpRoute.meta.breadcrumb = childrenBreadcrumb delete tmpRoute.children @@ -195,8 +180,7 @@ function flatAsyncRoutes(routes, breadcrumb = []) { } //过滤树 function treeFilter(tree, func) { - return tree.map(node => ({ - ...node + return tree.map(node => ({ ...node })).filter(node => { node.children = node.children && treeFilter(node.children, func) return func(node) || (node.children && node.children.length)