优化导航菜单

This commit is contained in:
Hooray
2025-03-10 21:49:36 +08:00
parent 49cdde285a
commit 4a0ffdd0f0
2 changed files with 5 additions and 19 deletions
+4 -9
View File
@@ -29,13 +29,6 @@ const isItemActive = computed(() => {
return isActived.value && (!props.subMenu || rootMenu.isMenuPopup)
})
// 缩进样式
const indentStyle = computed(() => {
return !rootMenu.isMenuPopup
? `padding-left: ${20 * (props.level ?? 0)}px`
: ''
})
defineExpose({
ref: itemRef,
})
@@ -68,11 +61,13 @@ defineExpose({
}"
>
<div
class="inline-flex flex-1 items-center justify-center gap-[12px]" :class="{
class="inline-flex flex-1 items-center justify-center gap-[12px] pl-[calc(var(--indent-level)*20px)]" :class="{
'flex-col': rootMenu.isMenuPopup && level === 0 && rootMenu.props.mode === 'vertical',
'gap-1!': rootMenu.isMenuPopup && level === 0 && rootMenu.props.showCollapseName,
'w-full': rootMenu.isMenuPopup && level === 0 && rootMenu.props.showCollapseName && rootMenu.props.mode === 'vertical',
}" :style="indentStyle"
}" :style="{
'--indent-level': !rootMenu.isMenuPopup ? props.level ?? 0 : 0,
}"
>
<FaIcon v-if="props.item.meta?.icon" :name="props.item.meta.icon" class="menu-item-container-icon size-5 transition-transform group-hover-scale-120" />
<span
+1 -10
View File
@@ -102,16 +102,7 @@ const transitionClass = computed(() => {
})
const hasChildren = computed(() => {
let flag = true
if (props.menu.children) {
if (props.menu.children.every((item: any) => item.meta?.menu === false)) {
flag = false
}
}
else {
flag = false
}
return flag
return props.menu.children?.some((item: any) => item.meta?.menu !== false) ?? false
})
function handleClick() {