支持不同角色自定义首页

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
+4 -1
View File
@@ -28,7 +28,7 @@ export const router = {
// 设置动态路由
setAsyncRouter(state, asyncRouters) {
state.asyncRouters = asyncRouters
}
},
},
actions: {
// 从后台获取动态路由
@@ -73,6 +73,9 @@ export const router = {
},
routerList(state) {
return state.routerList
},
defaultRouter(state) {
return state.defaultRouter
}
}
}
+5 -2
View File
@@ -35,16 +35,19 @@ export const user = {
}
},
actions: {
async LoginIn({ commit }, loginInfo) {
async LoginIn({ commit, dispatch, rootGetters, getters }, loginInfo) {
const res = await login(loginInfo)
if (res.code == 0) {
commit('setUserInfo', res.data.user)
commit('setToken', res.data.token)
await dispatch('router/SetAsyncRouter', {}, { root: true })
const asyncRouters = rootGetters['router/asyncRouters']
router.addRoutes(asyncRouters)
const redirect = router.history.current.query.redirect
if (redirect) {
router.push({ path: redirect })
} else {
router.push({ path: '/layout/dashboard' })
router.push({ name: getters["userInfo"].authority.defaultRouter })
}
return true
}