更新 src/router/index.js
恢复原文件
This commit is contained in:
parent
6151ed40d7
commit
bcecd6833c
@ -24,9 +24,9 @@ const routes_404 = {
|
|||||||
path: "/:pathMatch(.*)*",
|
path: "/:pathMatch(.*)*",
|
||||||
hidden: true,
|
hidden: true,
|
||||||
component: () =>
|
component: () =>
|
||||||
import( /* webpackChunkName: "404" */ '@/layout/other/404'),
|
import ( /* webpackChunkName: "404" */ '@/layout/other/404'),
|
||||||
}
|
}
|
||||||
let routes_404_r = () => { }
|
let routes_404_r = () => {}
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHashHistory(),
|
history: createWebHashHistory(),
|
||||||
routes: routes
|
routes: routes
|
||||||
@ -72,19 +72,6 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
api.system.index.get().then((response) => {
|
api.system.index.get().then((response) => {
|
||||||
if (response.code == 200) {
|
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) {
|
for (const key in response.data) {
|
||||||
tool.data.set(key, response.data[key]);
|
tool.data.set(key, response.data[key]);
|
||||||
if (key == 'layout') {
|
if (key == 'layout') {
|
||||||
@ -158,24 +145,22 @@ function filterAsyncRouter(routerMap) {
|
|||||||
function loadComponent(component) {
|
function loadComponent(component) {
|
||||||
if (component) {
|
if (component) {
|
||||||
return () =>
|
return () =>
|
||||||
import(`@/views/${component}`)
|
import (`@/views/${component}`)
|
||||||
} else {
|
} else {
|
||||||
return () =>
|
return () =>
|
||||||
import(`@/layout/other/empty`)
|
import (`@/layout/other/empty`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//路由扁平化
|
//路由扁平化
|
||||||
function flatAsyncRoutes(routes, breadcrumb = []) {
|
function flatAsyncRoutes(routes, breadcrumb = []) {
|
||||||
let res = []
|
let res = []
|
||||||
routes.forEach(route => {
|
routes.forEach(route => {
|
||||||
const tmp = {
|
const tmp = { ...route
|
||||||
...route
|
|
||||||
}
|
}
|
||||||
if (tmp.children) {
|
if (tmp.children) {
|
||||||
let childrenBreadcrumb = [...breadcrumb]
|
let childrenBreadcrumb = [...breadcrumb]
|
||||||
childrenBreadcrumb.push(route)
|
childrenBreadcrumb.push(route)
|
||||||
let tmpRoute = {
|
let tmpRoute = { ...route
|
||||||
...route
|
|
||||||
}
|
}
|
||||||
tmpRoute.meta.breadcrumb = childrenBreadcrumb
|
tmpRoute.meta.breadcrumb = childrenBreadcrumb
|
||||||
delete tmpRoute.children
|
delete tmpRoute.children
|
||||||
@ -195,8 +180,7 @@ function flatAsyncRoutes(routes, breadcrumb = []) {
|
|||||||
}
|
}
|
||||||
//过滤树
|
//过滤树
|
||||||
function treeFilter(tree, func) {
|
function treeFilter(tree, func) {
|
||||||
return tree.map(node => ({
|
return tree.map(node => ({ ...node
|
||||||
...node
|
|
||||||
})).filter(node => {
|
})).filter(node => {
|
||||||
node.children = node.children && treeFilter(node.children, func)
|
node.children = node.children && treeFilter(node.children, func)
|
||||||
return func(node) || (node.children && node.children.length)
|
return func(node) || (node.children && node.children.length)
|
||||||
|
Loading…
Reference in New Issue
Block a user