|
@@ -53,16 +53,17 @@ router.beforeEach((to, from, next) => {
|
|
} else {
|
|
} else {
|
|
store.dispatch('GenerateRoutes', { roles }).then(() => {
|
|
store.dispatch('GenerateRoutes', { roles }).then(() => {
|
|
// 根据roles权限生成可访问的路由表
|
|
// 根据roles权限生成可访问的路由表
|
|
|
|
+ next({ ...to, replace: true })
|
|
// 动态添加可访问路由表
|
|
// 动态添加可访问路由表
|
|
// router.addRoutes(store.getters.addRouters)
|
|
// router.addRoutes(store.getters.addRouters)
|
|
- const redirect = decodeURIComponent(from.query.redirect || to.path)
|
|
|
|
- if (to.path === redirect) {
|
|
|
|
- // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
|
|
|
|
- next({ ...to, replace: true })
|
|
|
|
- } else {
|
|
|
|
- // 跳转到目的路由
|
|
|
|
- next({ path: redirect })
|
|
|
|
- }
|
|
|
|
|
|
+ // const redirect = decodeURIComponent(from.query.redirect || to.path)
|
|
|
|
+ // if (to.path === redirect) {
|
|
|
|
+ // // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
|
|
|
|
+ // next({ ...to, replace: true })
|
|
|
|
+ // } else {
|
|
|
|
+ // // 跳转到目的路由
|
|
|
|
+ // next({ path: redirect })
|
|
|
|
+ // }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -86,7 +87,8 @@ router.beforeEach((to, from, next) => {
|
|
// 在免登录白名单,直接进入
|
|
// 在免登录白名单,直接进入
|
|
next()
|
|
next()
|
|
} else {
|
|
} else {
|
|
- next({ path: '/user/login', query: { redirect: to.fullPath } })
|
|
|
|
|
|
+ // next({ path: '/user/login', query: { redirect: to.fullPath } })
|
|
|
|
+ next({ path: '/user/login' })
|
|
NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
|
|
NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
|
|
}
|
|
}
|
|
}
|
|
}
|