|
|
@@ -40,6 +40,21 @@ const permission = {
|
|
|
})
|
|
|
const sdata = JSON.parse(JSON.stringify(res.data))
|
|
|
const rdata = JSON.parse(JSON.stringify(res.data))
|
|
|
+ for(let i=0;i<rdata.length;i++){
|
|
|
+ let item=rdata[i]
|
|
|
+ if(!item.children && item.component.includes("/")){
|
|
|
+ //如果一级是菜单
|
|
|
+ rdata[i]={
|
|
|
+ path: item.path,
|
|
|
+ name:item.name,
|
|
|
+ component: "Layout",
|
|
|
+ redirect: 'noRedirect',
|
|
|
+ children: [
|
|
|
+ item
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
const sidebarRoutes = filterAsyncRouter(sdata)
|
|
|
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
|
|
|
const asyncRoutes = filterDynamicRoutes(dynamicRoutes);
|
|
|
@@ -50,7 +65,6 @@ const permission = {
|
|
|
commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
|
|
|
commit('SET_DEFAULT_ROUTES', sidebarRoutes)
|
|
|
commit('SET_TOPBAR_ROUTES', sidebarRoutes)
|
|
|
- console.log(rewriteRoutes,'rewriteRoutes')
|
|
|
resolve(rewriteRoutes)
|
|
|
})
|
|
|
//前端模拟数据
|
|
|
@@ -75,10 +89,11 @@ const permission = {
|
|
|
|
|
|
// 遍历后台传来的路由字符串,转换为组件对象
|
|
|
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
|
|
|
- return asyncRouterMap.filter(route => {
|
|
|
+ return asyncRouterMap.filter(route => {
|
|
|
if (type && route.children) {
|
|
|
route.children = filterChildren(route.children)
|
|
|
}
|
|
|
+
|
|
|
if (route.component) {
|
|
|
// Layout ParentView 组件特殊处理
|
|
|
if (route.component === 'Layout') {
|
|
|
@@ -137,7 +152,8 @@ export function filterDynamicRoutes(routes) {
|
|
|
if (auth.hasRoleOr(route.roles)) {
|
|
|
res.push(route)
|
|
|
}
|
|
|
- }else{
|
|
|
+ }
|
|
|
+ else{
|
|
|
res.push(route)
|
|
|
}
|
|
|
})
|