Browse Source

登录后调整获取菜单逻辑,不再重复请求getMenu

main
piexlmax 3 years ago
parent
commit
9d8e6f08de
  1. 5
      web/src/permission.js

5
web/src/permission.js

@ -38,7 +38,7 @@ router.beforeEach(async(to, from, next) => {
document.title = getPageTitle(to.meta.title) document.title = getPageTitle(to.meta.title)
if (whiteList.indexOf(to.name) > -1) { if (whiteList.indexOf(to.name) > -1) {
if (token) { if (token) {
if (!asyncRouterFlag) {
if (!asyncRouterFlag && whiteList.indexOf(from.name) < 0) {
asyncRouterFlag++ asyncRouterFlag++
await getRouter() await getRouter()
} }
@ -50,10 +50,9 @@ router.beforeEach(async(to, from, next) => {
// 不在白名单中并且已经登陆的时候 // 不在白名单中并且已经登陆的时候
if (token) { if (token) {
// 添加flag防止多次获取动态路由和栈溢出 // 添加flag防止多次获取动态路由和栈溢出
if (!asyncRouterFlag) {
if (!asyncRouterFlag && whiteList.indexOf(from.name) < 0) {
asyncRouterFlag++ asyncRouterFlag++
await getRouter() await getRouter()
next({...to, replace: true }) next({...to, replace: true })
} else { } else {
if (to.matched.length) { if (to.matched.length) {

Loading…
Cancel
Save