动态menu和角色关联

This commit is contained in:
pixelqm
2019-09-19 23:49:10 +08:00
parent 968b8c21cd
commit a15521d83e
2 changed files with 117 additions and 35 deletions
+13 -3
View File
@@ -16,15 +16,25 @@ export const router = {
actions: {
// 从后台获取动态路由
async SetAsyncRouter({ commit }) {
const baseRouter = [{
path: '/layout',
name: 'layout',
component: "view/layout/index.vue",
meta: {
title: "底层layout"
},
children: []
}]
const asyncRouterRes = await asyncMenu()
const asyncRouter = asyncRouterRes.data.menus
asyncRouter.push({
baseRouter[0].children = asyncRouter
baseRouter.push({
path: '*',
redirect: '/404'
})
asyncRouterHandle(asyncRouter)
commit('setAsyncRouter', asyncRouter)
asyncRouterHandle(baseRouter)
commit('setAsyncRouter', baseRouter)
}
},
getters: {