|
|
|
@ -54,7 +54,7 @@ function getPermission() { |
|
|
|
|
// 取得路由的值,使用addRouter添加进路由里
|
|
|
|
|
// 该项目的路由实际上做了两层处理,一层指向了默认的路由,对应模块,用于基础布局的nav,下面一层才是实际上的路由跳转,
|
|
|
|
|
// 所以需要默认进行赋值,实际操作时根据path去禁用掉对应的nav即可。
|
|
|
|
|
const arr = ['station', 'achievement','assessment','course',"evaluation",'information','match','project','setting','student','system']; |
|
|
|
|
const arr = ['achievement','assessment','course',"evaluation",'information','match','project','setting','student', 'station','system']; |
|
|
|
|
let permissionRouters = []; // 最后处理好的路由数组
|
|
|
|
|
|
|
|
|
|
let data = res.permissionMenu[0].children; |
|
|
|
@ -76,7 +76,6 @@ function getPermission() { |
|
|
|
|
let children = []; |
|
|
|
|
// 第二级是按钮级数据,一级归属当前页的同级页面,实际上一共就一级路由
|
|
|
|
|
if (e.children && e.children.length > 0) { |
|
|
|
|
console.log(e.children) |
|
|
|
|
e.children.forEach(i => { |
|
|
|
|
// 避免重复生成路由
|
|
|
|
|
if (i.path && permissionRouters[index] && !permissionRouters[index].children.some(e => i.path === e.path)) { |
|
|
|
@ -228,13 +227,23 @@ function getPermission() { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
console.log(permissionRouters, "处理好的"); |
|
|
|
|
const station = permissionRouters.findIndex(e => e.name === 'station') |
|
|
|
|
console.log(333, station) |
|
|
|
|
if (station) { |
|
|
|
|
permissionRouters[station].children.push({ |
|
|
|
|
name: `stationPreview`, |
|
|
|
|
path: `/station/preview`, |
|
|
|
|
component: () => import("@/pages/station/preview"), |
|
|
|
|
meta: { title: "实验台" } |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
// 把处理完成的路由,add到router里
|
|
|
|
|
// 记录一下路由的名称,用于nav
|
|
|
|
|
let nav = data.map(e => e.path); |
|
|
|
|
router.app.$options.store.commit("routers", nav); |
|
|
|
|
let redirect = [{ |
|
|
|
|
path: "/index", |
|
|
|
|
redirect: permissionRouters.find(e => e.name === 'station') ? '/station' : permissionRouters[0].path |
|
|
|
|
redirect: station ? '/station' : permissionRouters[0].path |
|
|
|
|
}]; |
|
|
|
|
router.addRoutes(redirect); |
|
|
|
|
router.addRoutes(permissionRouters); |
|
|
|
|