|
@@ -5,6 +5,7 @@ import router, { constantRoutes } from '@/router'
|
|
*/
|
|
*/
|
|
export const state = {
|
|
export const state = {
|
|
routes: [], //最后改变完呈现的路由
|
|
routes: [], //最后改变完呈现的路由
|
|
|
|
+ role: 'admin', //权限admin 目前先写死了
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -26,6 +27,9 @@ export const mutations = {
|
|
setRouter(state, asyncRouter) {
|
|
setRouter(state, asyncRouter) {
|
|
router.addRoutes(asyncRouter) //注册路由
|
|
router.addRoutes(asyncRouter) //注册路由
|
|
state.routes = constantRoutes.concat(asyncRouter) //拼接原来的和异步的路由得到最新路由
|
|
state.routes = constantRoutes.concat(asyncRouter) //拼接原来的和异步的路由得到最新路由
|
|
|
|
+ },
|
|
|
|
+ setRole(state, role) {
|
|
|
|
+ state.role = role
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -40,4 +44,11 @@ export const actions = {
|
|
await commit('setRouter', asyncRouter)
|
|
await commit('setRouter', asyncRouter)
|
|
await commit('addRouter')
|
|
await commit('addRouter')
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ /** 设置角色
|
|
|
|
+ * @param {String} role 角色名
|
|
|
|
+ */
|
|
|
|
+ setPermissionRole({ commit }, role) {
|
|
|
|
+ commit('setRole', role)
|
|
|
|
+ }
|
|
}
|
|
}
|