|
|
|
@ -14,6 +14,7 @@ import * as roleApi from '@/api/roleApi.js'
|
|
|
|
import * as Auth from '@/libs/wechat';
|
|
|
|
import * as Auth from '@/libs/wechat';
|
|
|
|
import {formatRoutes} from '@/utils/parsing'
|
|
|
|
import {formatRoutes} from '@/utils/parsing'
|
|
|
|
import Layout from '@/layout'
|
|
|
|
import Layout from '@/layout'
|
|
|
|
|
|
|
|
import ParentView from '@/components/ParentView'
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Filter asynchronous routing tables by recursion
|
|
|
|
* Filter asynchronous routing tables by recursion
|
|
|
|
@ -66,10 +67,10 @@ const actions = {
|
|
|
|
// const routes = menusToRoutes(menusAll);
|
|
|
|
// const routes = menusToRoutes(menusAll);
|
|
|
|
const routes = copyRoutes(tempRoutes);
|
|
|
|
const routes = copyRoutes(tempRoutes);
|
|
|
|
const newRoutes = findRoutes(menusAll);
|
|
|
|
const newRoutes = findRoutes(menusAll);
|
|
|
|
// console.log('newRoutes',newRoutes);
|
|
|
|
console.log('newRoutes',newRoutes);
|
|
|
|
combineRoutes(routes, newRoutes);
|
|
|
|
combineRoutes(routes, newRoutes);
|
|
|
|
router.addRoutes(routes); // 动态添加可访问路由表
|
|
|
|
router.addRoutes(routes); // 动态添加可访问路由表
|
|
|
|
// console.log('routes-end',routes);
|
|
|
|
console.log('routes-end',routes);
|
|
|
|
menusAll = formatRoutes(menusAll)
|
|
|
|
menusAll = formatRoutes(menusAll)
|
|
|
|
|
|
|
|
|
|
|
|
const _routerResult = comRouter(menusAll, asyncRoutes)
|
|
|
|
const _routerResult = comRouter(menusAll, asyncRoutes)
|
|
|
|
@ -150,12 +151,19 @@ function findRoutes(menus, level = 0, prePath = '/') {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (menu.childList && menu.childList.length > 0) {
|
|
|
|
if (menu.childList && menu.childList.length > 0) {
|
|
|
|
route.children = findRoutes(menu.childList, level + 1, newPath + '/');
|
|
|
|
route.children = findRoutes(menu.childList, level + 1, prePath + path + '/');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tempRoute.component &&level > 0 && route.children && route.children.length > 0) {
|
|
|
|
|
|
|
|
route.component = ParentView;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!tempRoute.path || (route.children && route.children.length > 0)) {
|
|
|
|
if (!tempRoute.path || (route.children && route.children.length > 0)) {
|
|
|
|
accessedRoutes.push(route)
|
|
|
|
accessedRoutes.push(route)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tempRoute.path) {
|
|
|
|
|
|
|
|
// FIXME: 这是个新路由,这里去修改menu的访问路径,临时方案
|
|
|
|
|
|
|
|
menu.component = prePath + path;
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return accessedRoutes
|
|
|
|
return accessedRoutes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|