|
@@ -45,7 +45,9 @@ router.beforeEach(async (to, from, next) => {
|
|
|
|
|
|
// 设置路由
|
|
|
var newRoutes = [];
|
|
|
+
|
|
|
for (var route of store.getters.menus) {
|
|
|
+
|
|
|
const item = buildRootRoute(route);
|
|
|
newRoutes.push(item);
|
|
|
}
|
|
@@ -111,25 +113,26 @@ router.afterEach(() => {
|
|
|
});
|
|
|
|
|
|
// 遍历后台传来的路由字符串,转换为组件对象
|
|
|
-function filterAsyncRouter(asyncRouterMap) {
|
|
|
- const accessedRouters = asyncRouterMap.filter((route) => {
|
|
|
- console.log(route);
|
|
|
- if (route.component) {
|
|
|
- if (route.component === "Layout") {
|
|
|
- route.component = Layout;
|
|
|
- } else {
|
|
|
- route.component = _import(route.component); // 导入组件
|
|
|
- }
|
|
|
- }
|
|
|
- if (route.children && route.children.length) {
|
|
|
- route.children = filterAsyncRouter(route.children);
|
|
|
- }
|
|
|
- return true;
|
|
|
- });
|
|
|
- return accessedRouters;
|
|
|
-}
|
|
|
+// function filterAsyncRouter(asyncRouterMap) {
|
|
|
+// const accessedRouters = asyncRouterMap.filter((route) => {
|
|
|
+// console.log(route);
|
|
|
+// if (route.component) {
|
|
|
+// if (route.component === "Layout") {
|
|
|
+// route.component = Layout;
|
|
|
+// } else {
|
|
|
+// route.component = _import(route.component); // 导入组件
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (route.children && route.children.length) {
|
|
|
+// route.children = filterAsyncRouter(route.children);
|
|
|
+// }
|
|
|
+// return true;
|
|
|
+// });
|
|
|
+// return accessedRouters;
|
|
|
+// }
|
|
|
|
|
|
function buildRootRoute(route) {
|
|
|
+ // console.log(route,1111);
|
|
|
const { url, icon, moduleName, moduleId, code, type } = route;
|
|
|
var item = {};
|
|
|
item.path = url;
|
|
@@ -183,7 +186,9 @@ function buildRootRoute(route) {
|
|
|
code == "notice" ||
|
|
|
code == "index"
|
|
|
) {
|
|
|
+
|
|
|
for (var child of route.children) {
|
|
|
+
|
|
|
item.children.push(buildRoute(child, url));
|
|
|
}
|
|
|
}
|
|
@@ -191,7 +196,8 @@ function buildRootRoute(route) {
|
|
|
}
|
|
|
|
|
|
function buildRoute(route, p_url) {
|
|
|
- const { url, moduleName, icon, moduleId, code, type, hidden } = route;
|
|
|
+ // console.log(route,2222);
|
|
|
+ const { url, moduleName, icon, moduleId, code, type, hidden,fullUrl } = route;
|
|
|
var item = {};
|
|
|
if (url.substr(0, 1) == "/") {
|
|
|
item.path = url.substr(1);
|
|
@@ -204,7 +210,14 @@ function buildRoute(route, p_url) {
|
|
|
item.component = (resolve) =>
|
|
|
require(["@/views" + `${url}/index`], resolve);
|
|
|
} else {
|
|
|
- item.component = _import(`${p_url}${url}`);
|
|
|
+
|
|
|
+ if (fullUrl) {
|
|
|
+ item.component = _import(`${fullUrl}`);
|
|
|
+ }else{
|
|
|
+ item.component = _import(`${p_url}${url}`);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
@@ -232,15 +245,23 @@ function buildRoute(route, p_url) {
|
|
|
}
|
|
|
|
|
|
function buildThirdRoute(route, p_url) {
|
|
|
- const { url, moduleName, icon, moduleId, code, hidden, type } = route;
|
|
|
+
|
|
|
+ const { url, moduleName, icon, moduleId, code, hidden, type ,fullUrl } = route;
|
|
|
+ // console.log(fullUrl,'7878');
|
|
|
var item = {};
|
|
|
if (url.substr(0, 1) == "/") {
|
|
|
+ // console.log(url.substr(1),p_url,url);
|
|
|
item.path = url.substr(1);
|
|
|
} else {
|
|
|
tem.path = url;
|
|
|
}
|
|
|
try {
|
|
|
- item.component = _import(`${p_url}${url}`);
|
|
|
+ if (fullUrl) {
|
|
|
+ item.component = _import(`${fullUrl}`);
|
|
|
+ }else{
|
|
|
+ item.component = _import(`${p_url}${url}`);
|
|
|
+ }
|
|
|
+
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
}
|