支持不同角色自定义首页

This commit is contained in:
pixel
2021-01-14 12:28:13 +08:00
parent 3d01706fb6
commit 7abe6987a5
6 changed files with 56 additions and 16 deletions

View File

@@ -13,7 +13,7 @@ router.beforeEach(async(to, from, next) => {
document.title = getPageTitle(to.meta.title)
if (whiteList.indexOf(to.name) > -1) {
if (token) {
next({ path: '/layout/dashboard' })
next({ name: store.getters["user/userInfo"].authority.defaultRouter })
} else {
next()
}
@@ -21,7 +21,7 @@ router.beforeEach(async(to, from, next) => {
// 不在白名单中并且已经登陆的时候
if (token) {
// 添加flag防止多次获取动态路由和栈溢出
if (!asyncRouterFlag) {
if (!asyncRouterFlag && store.getters['router/asyncRouters'].length == 0) {
asyncRouterFlag++
await store.dispatch('router/SetAsyncRouter')
const asyncRouters = store.getters['router/asyncRouters']