|
|
|
|
@ -53,6 +53,7 @@ export function filterAsyncRoutes(routes, roles) {
|
|
|
|
|
|
|
|
|
|
const state = {
|
|
|
|
|
routes: [],
|
|
|
|
|
rootMenu:[],
|
|
|
|
|
addRoutes: []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -66,7 +67,7 @@ export function generaMenu(routes, data) {
|
|
|
|
|
routes.push({
|
|
|
|
|
path: '/',
|
|
|
|
|
component: Layout,
|
|
|
|
|
redirect: '/dashboard',
|
|
|
|
|
redirect: '/worker',
|
|
|
|
|
children: [{
|
|
|
|
|
path: 'dashboard',
|
|
|
|
|
name: '系统首页',
|
|
|
|
|
@ -84,16 +85,16 @@ export function generaMenu(routes, data) {
|
|
|
|
|
}
|
|
|
|
|
const menu = {
|
|
|
|
|
path: (path === '#' ? item.id + '_key' : path),
|
|
|
|
|
redirect: (item.children.length > 0 ? "noRedirect" : ""),
|
|
|
|
|
redirect: (item.children?.length > 0 ? "noRedirect" : ""),
|
|
|
|
|
component: item.url === '#' ? Layout : loadView(item.url),
|
|
|
|
|
// hidden: true,
|
|
|
|
|
hidden: item.hidden ?? false,
|
|
|
|
|
children: [],
|
|
|
|
|
name: 'menu_' + item.id,
|
|
|
|
|
meta: {
|
|
|
|
|
title: item.name,
|
|
|
|
|
id: item.id,
|
|
|
|
|
roles: ['admin'],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
icon: item.icon
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -109,6 +110,9 @@ const mutations = {
|
|
|
|
|
SET_ROUTES: (state, routes) => {
|
|
|
|
|
state.addRoutes = routes
|
|
|
|
|
state.routes = constantRoutes.concat(routes)
|
|
|
|
|
},
|
|
|
|
|
SET_ROOTMENU:(state,menu) => {
|
|
|
|
|
state.rootMenu = menu
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -124,11 +128,19 @@ const actions = {
|
|
|
|
|
getAuthMenu(state.token).then(response => {
|
|
|
|
|
let data = response
|
|
|
|
|
|
|
|
|
|
//console.log(JSON.stringify(data))
|
|
|
|
|
commit('SET_ROOTMENU',data)
|
|
|
|
|
|
|
|
|
|
Object.assign(loadMenuData, data)
|
|
|
|
|
let routes = data.filter(item => item.path === '/contract')[0]?.children
|
|
|
|
|
let root = data.map(item => {
|
|
|
|
|
delete item.children
|
|
|
|
|
item.hidden = true
|
|
|
|
|
return item
|
|
|
|
|
})
|
|
|
|
|
Object.assign(loadMenuData, [...routes,...root])
|
|
|
|
|
asyncRoutes.length=0;
|
|
|
|
|
generaMenu(asyncRoutes, loadMenuData)
|
|
|
|
|
|
|
|
|
|
console.log(asyncRoutes)
|
|
|
|
|
let accessedRoutes
|
|
|
|
|
if (roles.includes('admin')) {
|
|
|
|
|
// alert(JSON.stringify(asyncRoutes))
|
|
|
|
|
|