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.

30 lines
630 B

3 years ago
import store from '@/store'
import generateBtnPermission from '../auth/generateBtnPermission'
4 years ago
3 years ago
const newRoutes = []
4 years ago
4 years ago
function createMeta(item) {
3 years ago
let meta = { title: item.name }
return meta
4 years ago
}
4 years ago
function createRoute(data) {
3 years ago
data.map(e => {
const { path } = e
if (path) {
let meta = createMeta(e)
newRoutes.push({
path,
meta
})
}
// 递归生成路由集合
e.children && e.children.length && createRoute(e.children);
})
4 years ago
}
4 years ago
export default function(data, path) {
generateBtnPermission(data);
createRoute(data);
store.dispatch("auth/addRoutes", newRoutes);
4 years ago
}