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.
|
|
|
import store from '@/store';
|
|
|
|
import router from '@/router';
|
|
|
|
import generateBtnPermission from '../auth/generateBtnPermission';
|
|
|
|
|
|
|
|
const newRoutes = []
|
|
|
|
|
|
|
|
function createMeta(item){
|
|
|
|
let meta = { title: item.name }
|
|
|
|
return meta
|
|
|
|
}
|
|
|
|
|
|
|
|
function createRoute(data){
|
|
|
|
data.map(e => {
|
|
|
|
if(e.menuUrl){
|
|
|
|
let meta = createMeta(e)
|
|
|
|
newRoutes.push({
|
|
|
|
name: e.menuUrl,
|
|
|
|
path: e.menuUrl,
|
|
|
|
meta
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// 递归生成路由集合
|
|
|
|
e.children && e.children.length && createRoute(e.children)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function(data,path){
|
|
|
|
generateBtnPermission(data)
|
|
|
|
createRoute(data)
|
|
|
|
store.dispatch('auth/addRoutes',newRoutes)
|
|
|
|
}
|