Commit 20cf2398 authored by 张伯涛's avatar 张伯涛

修改

parent 74967b44
...@@ -31,24 +31,6 @@ router.beforeEach((to, from, next) => { ...@@ -31,24 +31,6 @@ router.beforeEach((to, from, next) => {
store.dispatch('GenerateRoutes', res).then((routers) => { store.dispatch('GenerateRoutes', res).then((routers) => {
// 判断用户是否有路由 // 判断用户是否有路由
if (routers.accessedRoutes && routers.accessedRoutes.length > 0 && routers.getRouters && routers.getRouters.length > 0) { if (routers.accessedRoutes && routers.accessedRoutes.length > 0 && routers.getRouters && routers.getRouters.length > 0) {
// 测试 默认静态页面
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// 根据roles权限生成可访问的路由表
// 配置选中父项
// routers.accessedRoutes.forEach(item => {
// if ('children' in item) {
// item.children.forEach(item1 => {
// if (item1.path === '/productionInfo/ModelDetailsNew' || item1.path === '/productionInfo/ModelDetailsEdit') {
// item1.meta.activeMenu = '/productionInfo/ProductionModel'
// }
// if (item1.path === '/ProductionProcess/ModelDetails') {
// item1.meta.activeMenu = '/ProductionProcess/workOrder'
// }
// })
// }
// })
// eslint-disable-next-line no-debugger
debugger
console.log('routers', routers) console.log('routers', routers)
if (routers.accessedRoutes[0].path === '/entry') { if (routers.accessedRoutes[0].path === '/entry') {
router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表 router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表
...@@ -57,7 +39,23 @@ router.beforeEach((to, from, next) => { ...@@ -57,7 +39,23 @@ router.beforeEach((to, from, next) => {
router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表 router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表
next({ path: routers.accessedRoutes[0].children[0].path, replace: true }) // 没有首页,自动切换跳转到下一级 next({ path: routers.accessedRoutes[0].children[0].path, replace: true }) // 没有首页,自动切换跳转到下一级
} }
// next({ path: routers.accessedRoutes[0].children[0].path, replace: true }) // 没有首页,自动切换跳转到下一级 // 测试 默认静态页面
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// 根据roles权限生成可访问的路由表
// 配置选中父项
routers.accessedRoutes.forEach(item => {
if ('children' in item) {
item.children.forEach(item1 => {
if (item1.path === '/productionInfo/ModelDetailsNew' || item1.path === '/productionInfo/ModelDetailsEdit') {
item1.meta.activeMenu = '/productionInfo/ProductionModel'
}
if (item1.path === '/ProductionProcess/ModelDetails') {
item1.meta.activeMenu = '/ProductionProcess/workOrder'
}
})
}
})
// router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表
// next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
} else { } else {
Message.error('用户无权限') Message.error('用户无权限')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment