parent
15f2ca9b49
commit
86457cbb21
7 changed files with 44 additions and 42 deletions
@ -1,28 +1,29 @@ |
|||||||
import store from '@/store' |
import store from '@/store'; |
||||||
import generateBtnPermission from '../auth/generateBtnPermission' |
import generateBtnPermission from '../auth/generateBtnPermission'; |
||||||
|
|
||||||
const newRoutes = [] |
const newRoutes = [] |
||||||
|
|
||||||
function createMeta(item) { |
function createMeta (item) { |
||||||
let meta = { title: item.name } |
let meta = { title: item.name } |
||||||
return meta |
return meta |
||||||
} |
} |
||||||
|
|
||||||
function createRoute(data) { |
function createRoute (data) { |
||||||
data.map(e => { |
data.map(e => { |
||||||
const { url } = e |
if (e.path) { |
||||||
// 有path则添加到路由里
|
let meta = createMeta(e) |
||||||
url && newRoutes.push({ |
newRoutes.push({ |
||||||
path: url, |
path: e.path, |
||||||
meta: createMeta(e) |
meta |
||||||
}) |
}) |
||||||
|
} |
||||||
// 递归生成路由集合
|
// 递归生成路由集合
|
||||||
e.children && e.children.length && createRoute(e.children) |
e.children && e.children.length && createRoute(e.children) |
||||||
}) |
}) |
||||||
} |
} |
||||||
|
|
||||||
export default function(data, path) { |
export default function (data, path) { |
||||||
generateBtnPermission(data) |
generateBtnPermission(data) |
||||||
// createRoute(data)
|
// createRoute(data)
|
||||||
// store.commit('auth/addRoutes', newRoutes)
|
// store.commit('addRoutes', newRoutes)
|
||||||
} |
} |
Loading…
Reference in new issue