Commit ccdf9625 authored by zhangyichen's avatar zhangyichen
parents f1a11709 8a7a2011
...@@ -31,7 +31,6 @@ router.beforeEach((to, from, next) => { ...@@ -31,7 +31,6 @@ router.beforeEach((to, from, next) => {
// const roles = res.data.roles // const roles = res.data.roles
store.dispatch('GenerateRoutes', res).then((routers) => { store.dispatch('GenerateRoutes', res).then((routers) => {
// 判断用户是否有路由 // 判断用户是否有路由
console.log('判断用户是否有路由', 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 => { // store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
...@@ -49,6 +48,7 @@ router.beforeEach((to, from, next) => { ...@@ -49,6 +48,7 @@ router.beforeEach((to, from, next) => {
}) })
} }
}) })
console.log('routers', routers)
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({ ...to, replace: true }) // hack方法 确保addRoutes已完成 // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
......
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