fix: 修复一级菜单问题
This commit is contained in:
@@ -29,13 +29,35 @@
|
||||
</el-menu-item>
|
||||
</AppLink>
|
||||
</template>
|
||||
<template
|
||||
v-else-if="
|
||||
item.children && item.children.length == 1 && hasOneShowingChild(item.children, item)
|
||||
"
|
||||
>
|
||||
<AppLink
|
||||
v-if="onlyOneChild.meta"
|
||||
:to="{
|
||||
path: resolvePath(onlyOneChild.path),
|
||||
query: onlyOneChild.meta.params,
|
||||
}"
|
||||
>
|
||||
<el-menu-item
|
||||
:index="resolvePath(onlyOneChild.path)"
|
||||
:class="{ 'one-menu submenu-title-noDropdown': !isNest }"
|
||||
>
|
||||
<SidebarMenuItemTitle
|
||||
:icon="onlyOneChild.meta.icon || item.meta?.icon"
|
||||
:title="onlyOneChild.meta.title"
|
||||
/>
|
||||
</el-menu-item>
|
||||
</AppLink>
|
||||
</template>
|
||||
|
||||
<!--【非叶子节点】显示含多个子节点的父菜单,或始终显示的单子节点 -->
|
||||
<el-sub-menu v-else :index="resolvePath(item.path)" teleported>
|
||||
<template #title>
|
||||
<SidebarMenuItemTitle v-if="item.meta" :icon="item.meta.icon" :title="item.meta.title" />
|
||||
</template>
|
||||
|
||||
<SidebarMenuItem
|
||||
v-for="child in item.children"
|
||||
:key="child.path"
|
||||
@@ -95,9 +117,14 @@ const onlyOneChild = ref();
|
||||
* @returns 是否仅有一个可见子节点
|
||||
*/
|
||||
function hasOneShowingChild(children: RouteRecordRaw[] = [], parent: RouteRecordRaw) {
|
||||
if (parent.name == "marketing_center") {
|
||||
console.log(children);
|
||||
console.log(parent);
|
||||
}
|
||||
// 过滤出可见子节点
|
||||
const showingChildren = children.filter((route: RouteRecordRaw) => {
|
||||
if (!route.meta?.hidden) {
|
||||
console.log(route);
|
||||
onlyOneChild.value = route;
|
||||
return true;
|
||||
}
|
||||
@@ -201,4 +228,7 @@ function resolvePath(routePath: string) {
|
||||
.el-menu-item {
|
||||
color: rgb(153, 153, 153);
|
||||
}
|
||||
.one-menu {
|
||||
color: #555;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -29,6 +29,7 @@ import NavbarRight from "../NavBar/components/NavbarRight.vue";
|
||||
const appStore = useAppStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const permissionStore = usePermissionStore();
|
||||
console.log(permissionStore.routes);
|
||||
const sidebarLogo = computed(() => settingsStore.sidebarLogo);
|
||||
const layout = computed(() => settingsStore.layout);
|
||||
|
||||
|
||||
3
src/views/test/index.vue
Normal file
3
src/views/test/index.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<div>test</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user