更新 src/router/index.js

恢复原文件
This commit is contained in:
XiaoMo 2023-08-31 15:43:33 +00:00
parent 6151ed40d7
commit bcecd6833c

View File

@ -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)