修改了menu的查询次数 增强了菜单查询时的性能
This commit is contained in:
@@ -6,7 +6,7 @@ import { asyncMenu } from '@/api/menu'
|
||||
const formatRouter = (routes) => {
|
||||
routes && routes.map(item => {
|
||||
item.meta.hidden = item.hidden
|
||||
if (item.children.length > 0) {
|
||||
if (item.children && item.children.length > 0) {
|
||||
formatRouter(item.children)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<component :is="menuComponent" :routerInfo="routerInfo" v-if="!routerInfo.hidden">
|
||||
<template v-if="routerInfo.children.length">
|
||||
<template v-if="routerInfo.children&&routerInfo.children.length">
|
||||
<AsideComponent :key="item.name" :routerInfo="item" v-for="item in routerInfo.children" />
|
||||
</template>
|
||||
</component>
|
||||
@@ -14,7 +14,7 @@ export default {
|
||||
name: 'AsideComponent',
|
||||
computed: {
|
||||
menuComponent() {
|
||||
if (this.routerInfo.children.filter(item=>!item.hidden).length) {
|
||||
if (this.routerInfo.children&&this.routerInfo.children.filter(item=>!item.hidden).length) {
|
||||
return 'AsyncSubmenu'
|
||||
} else {
|
||||
return 'MenuItem'
|
||||
|
||||
@@ -266,7 +266,7 @@ export default {
|
||||
},
|
||||
setAuthorityOptions(AuthorityData,optionsData,disabled){
|
||||
AuthorityData&&AuthorityData.map(item=>{
|
||||
if(item.children.length){
|
||||
if(item.children&&item.children.length){
|
||||
const option = {
|
||||
authorityId:item.authorityId,
|
||||
authorityName:item.authorityName,
|
||||
|
||||
@@ -78,7 +78,7 @@ export default {
|
||||
obj.authorityId = item.authorityId
|
||||
obj.authorityName = item.authorityName
|
||||
this.authoritys.push(obj)
|
||||
if(item.children.length){
|
||||
if(item.children&&item.children.length){
|
||||
this.roundAuthority(item.children)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -157,7 +157,7 @@ export default {
|
||||
setMenuOptions(menuData, optionsData, disabled) {
|
||||
menuData &&
|
||||
menuData.map(item => {
|
||||
if (item.children.length) {
|
||||
if (item.children&&item.children.length) {
|
||||
const option = {
|
||||
title: item.meta.title,
|
||||
ID: String(item.ID),
|
||||
|
||||
@@ -149,7 +149,7 @@ export default {
|
||||
setAuthorityOptions(AuthorityData, optionsData) {
|
||||
AuthorityData &&
|
||||
AuthorityData.map(item => {
|
||||
if (item.children.length) {
|
||||
if (item.children&&item.children.length) {
|
||||
const option = {
|
||||
authorityId: item.authorityId,
|
||||
authorityName: item.authorityName,
|
||||
|
||||
Reference in New Issue
Block a user