You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.5 KiB
70 lines
1.5 KiB
1 year ago
|
import Vue from "vue";
|
||
|
import Router from "vue-router";
|
||
|
import compX from "@/views/JiHeExpressway/components/compX.vue";
|
||
|
|
||
|
Vue.use(Router);
|
||
|
|
||
|
/* Layout */
|
||
|
import Layout from "@/layout";
|
||
|
import menuData from "@/common/menuData";
|
||
|
import { resolve } from "mathjs";
|
||
|
// 公共路由
|
||
|
|
||
|
import {constantRoutes} from "./index.js";
|
||
|
function processNode(node) {
|
||
|
let arr = [];
|
||
|
node.forEach((item) => {
|
||
|
let temp = {
|
||
|
path: item.path || "",
|
||
|
title: item.title,
|
||
|
name: item.name,
|
||
|
};
|
||
|
if (item.redirect) {
|
||
|
temp.redirect = {
|
||
|
name: item.redirect,
|
||
|
};
|
||
|
}
|
||
|
if (!item.component) {
|
||
|
temp.component = compX;
|
||
|
} else {
|
||
|
temp.component = (resolve) =>
|
||
|
require(["@/views/JiHeExpressway/pages/" + item.component], resolve); //views/visualization/pages/${item.component}
|
||
|
}
|
||
|
|
||
|
if (item.children && item.children.length > 0) {
|
||
|
temp.children = processNode(item.children);
|
||
|
}
|
||
|
arr.push(temp);
|
||
|
});
|
||
|
return arr;
|
||
|
}
|
||
|
|
||
|
let childrenRoutes = processNode(menuData);
|
||
|
let routes = [
|
||
|
{
|
||
|
path: "/index",
|
||
|
name: "index",
|
||
|
redirect:{
|
||
|
path:"/home"
|
||
|
},
|
||
|
component: () => import("@/views/JiHeExpressway/index"),
|
||
|
// children: childrenRoutes
|
||
|
children: childrenRoutes,
|
||
|
},
|
||
|
{
|
||
|
path: "/",
|
||
|
name: "index",
|
||
|
redirect:{
|
||
|
path:"/home"
|
||
|
}
|
||
|
},
|
||
|
...constantRoutes
|
||
|
];
|
||
|
export default new Router({
|
||
|
base: "/",
|
||
|
// mode: 'hash', // 去掉url中的#
|
||
|
mode: "history", // 去掉url中的#
|
||
|
scrollBehavior: () => ({ y: 0 }),
|
||
|
routes: routes,
|
||
|
});
|