master
xy 3 years ago
parent 3c84c09436
commit 1f2fa5c2af

@ -6,6 +6,28 @@ import Layout from '@/layout'
import { import {
getAuthMenu getAuthMenu
} from '@/api/user.js' } from '@/api/user.js'
const pathHandler = (item) => {
if(!item.path || item.path?.includes('#') || item.path == ''){
return item.id + '_key'
}
if(/^\^/.test(item.path)){
return item.path.replace(/^\^+/g,"")
}
if(/^\$/.test(item.path)){
return item.path.replace(/^\$+/g,"")
}
return item.path
// if(path.includes('$')){
// return path.replace(/^\$+/g,"")
// }
// if(path.includes('^')){
// return path.replace(/^\^+/g,"")
// }
// if(path.includes('#') || path == ''){
// return id + '_key'
// }
// return path
}
const componentHandler = (path) => { const componentHandler = (path) => {
//return path === '#'|| path == '' ? Layout : loadView(path) //return path === '#'|| path == '' ? Layout : loadView(path)
if(path === '#' || path === ''){ if(path === '#' || path === ''){
@ -109,6 +131,29 @@ export function generaMenu(routes, data) {
} }
}] }]
}) })
}else if(/^\^/.test(item.path)){
const menu = {
path: pathHandler(item),
component: Layout,
children: [{
path: "",
name: 'menu_' + item.id,
component: (item.url.includes('#')||item.path == '') ? Layout : loadView(item.url),
meta: {
title: item.name,
id: item.id,
roles: ['admin'],
auths:item.has_auth_node_tags,
params,
icon: item.icon
}
}, ]
}
if (item.children) {
generaMenu(menu.children, item.children)
}
routes.push(menu)
} else { } else {
var path = item.url; var path = item.url;
if (item.path != "null" && item.path != null && item.path != "") { if (item.path != "null" && item.path != null && item.path != "") {
@ -132,6 +177,7 @@ export function generaMenu(routes, data) {
if (item.children) { if (item.children) {
generaMenu(menu.children, item.children) generaMenu(menu.children, item.children)
} }
routes.push(menu) routes.push(menu)
} }
}) })
@ -167,8 +213,8 @@ const actions = {
commit('SET_ROOTMENU',data) commit('SET_ROOTMENU',data)
let routes = data.find(item => item.path === '/contract').children let routes = data?.find(item => item.path === '/contract').children
let root = data.map(item => { let root = data?.map(item => {
let menu = [] let menu = []
generaMenu(menu,item.children) generaMenu(menu,item.children)
commit('SET_SIDEBARMENUMAP', { k: item.path, v: menu }) commit('SET_SIDEBARMENUMAP', { k: item.path, v: menu })
@ -176,7 +222,7 @@ const actions = {
item.redirect = item.children[0]?.path item.redirect = item.children[0]?.path
} }
if(item.path === '/contract') { if(item.path === '/contract') {
item.redirect = '/contract/contract/contractList' item.redirect = '/contract/dashboard'
} }
item.hidden = true item.hidden = true
return item return item
@ -188,7 +234,6 @@ const actions = {
console.log(asyncRoutes) console.log(asyncRoutes)
let accessedRoutes let accessedRoutes
if (roles.includes('admin')) { if (roles.includes('admin')) {
// alert(JSON.stringify(asyncRoutes))
accessedRoutes = asyncRoutes || [] accessedRoutes = asyncRoutes || []
} else { } else {
accessedRoutes = filterAsyncRoutes(asyncRoutes, roles) accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)

Loading…
Cancel
Save