|
|
|
@ -12,7 +12,7 @@ NProgress.configure({ showSpinner: false }) |
|
|
|
const whiteList = ['/login', '/lblh'] |
|
|
|
|
|
|
|
const isWhiteList = (path) => { |
|
|
|
return whiteList.some(pattern => isPathMatch(pattern, path)) |
|
|
|
return whiteList.some((pattern) => isPathMatch(pattern, path)) |
|
|
|
} |
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
@ -28,21 +28,41 @@ router.beforeEach((to, from, next) => { |
|
|
|
} else { |
|
|
|
if (store.getters.roles.length === 0) { |
|
|
|
isRelogin.show = true |
|
|
|
|
|
|
|
//业务菜单角标
|
|
|
|
store |
|
|
|
.dispatch('GetMenuCount') |
|
|
|
.then(() => {}) |
|
|
|
.catch((error) => { |
|
|
|
console.log('GetMenuCount出错:' + (error.msg || '')) |
|
|
|
}) |
|
|
|
|
|
|
|
// 判断当前用户是否已拉取完user_info信息
|
|
|
|
store.dispatch('GetInfo').then(() => { |
|
|
|
isRelogin.show = false |
|
|
|
store.dispatch('GenerateRoutes').then(accessRoutes => { |
|
|
|
// 根据roles权限生成可访问的路由表
|
|
|
|
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
|
|
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
|
|
|
store |
|
|
|
.dispatch('GetInfo') |
|
|
|
.then(() => { |
|
|
|
isRelogin.show = false |
|
|
|
store.dispatch('GenerateRoutes').then((accessRoutes) => { |
|
|
|
// 根据roles权限生成可访问的路由表
|
|
|
|
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
|
|
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}).catch(err => { |
|
|
|
.catch((err) => { |
|
|
|
store.dispatch('LogOut').then(() => { |
|
|
|
Message.error(err) |
|
|
|
next({ path: '/' }) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
//业务菜单角标
|
|
|
|
store |
|
|
|
.dispatch('GetMenuCount') |
|
|
|
.then(() => {}) |
|
|
|
.catch((error) => { |
|
|
|
console.log('GetMenuCount出错:' + (error.msg || '')) |
|
|
|
}) |
|
|
|
|
|
|
|
next() |
|
|
|
} |
|
|
|
} |
|
|
|
|