| | |
| | | <template> |
| | | <div v-if="!item.hidden"> |
| | | <template v-if="hasOneShowingChild(item.children, item) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow"> |
| | | <template v-if="hasOneShowingChild(item, item.children) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow"> |
| | | <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)"> |
| | | <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }"> |
| | | <svg-icon :icon-class="onlyOneChild.meta.icon || (item.meta && item.meta.icon)" /> |
| | |
| | | </template> |
| | | |
| | | <sidebar-item |
| | | v-for="child in item.children" |
| | | v-for="(child) in item.children as RouteOption[]" |
| | | :key="child.path" |
| | | :is-nest="true" |
| | | :item="child as RouteOption" |
| | | :item="child" |
| | | :base-path="resolvePath(child.path)" |
| | | class="nest-menu" |
| | | /> |
| | |
| | | import AppLink from './Link.vue' |
| | | import { getNormalPath } from '@/utils/ruoyi' |
| | | import { RouteOption } from "vue-router"; |
| | | import { PropType } from "vue"; |
| | | |
| | | const props = defineProps({ |
| | | // route object |
| | |
| | | |
| | | const onlyOneChild = ref<any>({}); |
| | | |
| | | const hasOneShowingChild = (children:RouteOption[] = [], parent: RouteOption) => { |
| | | const hasOneShowingChild = (parent: RouteOption, children?:RouteOption[]) => { |
| | | if (!children) { |
| | | children = []; |
| | | } |
| | |
| | | // Show parent if there are no child router to display |
| | | if (showingChildren.length === 0) { |
| | | onlyOneChild.value = { ...parent, path: '', noShowingChildren: true } |
| | | if (parent.name === '2222') { |
| | | console.log(onlyOneChild.value) |
| | | } |
| | | return true |
| | | } |
| | | |
| | | |
| | | return false |
| | | }; |
| | | |