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.

31 lines
749 B

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