|
|
|
|
@ -11,31 +11,36 @@ const props = defineProps<{
|
|
|
|
|
|
|
|
|
|
const { page } = useData()
|
|
|
|
|
|
|
|
|
|
const isChildActive = (navItem: DefaultTheme.NavItem) => {
|
|
|
|
|
const isActiveGroup = computed(() => {
|
|
|
|
|
if (props.item.activeMatch) {
|
|
|
|
|
return isActive(page.value.relativePath, props.item.activeMatch, true)
|
|
|
|
|
}
|
|
|
|
|
return isChildActive(props.item)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function isChildActive(navItem: DefaultTheme.NavItem): boolean {
|
|
|
|
|
if ('component' in navItem) return false
|
|
|
|
|
|
|
|
|
|
if ('link' in navItem) {
|
|
|
|
|
const href =
|
|
|
|
|
typeof navItem.link === 'function'
|
|
|
|
|
? navItem.link(page.value)
|
|
|
|
|
: navItem.link
|
|
|
|
|
|
|
|
|
|
return isActive(
|
|
|
|
|
page.value.relativePath,
|
|
|
|
|
typeof navItem.link === "function" ? navItem.link(page.value) : navItem.link,
|
|
|
|
|
!!props.item.activeMatch
|
|
|
|
|
navItem.activeMatch || href,
|
|
|
|
|
!!navItem.activeMatch
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return navItem.items.some(isChildActive)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const childrenActive = computed(() => isChildActive(props.item))
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<VPFlyout
|
|
|
|
|
:class="{
|
|
|
|
|
VPNavBarMenuGroup: true,
|
|
|
|
|
active:
|
|
|
|
|
isActive(page.relativePath, item.activeMatch, !!item.activeMatch) ||
|
|
|
|
|
childrenActive
|
|
|
|
|
}"
|
|
|
|
|
:class="{ VPNavBarMenuGroup: true, active: isActiveGroup }"
|
|
|
|
|
:button="item.text"
|
|
|
|
|
:items="item.items"
|
|
|
|
|
/>
|
|
|
|
|
|