|
|
@ -1,14 +1,29 @@
|
|
|
|
<script lang="ts" setup>
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import type { DefaultTheme } from 'vitepress/theme'
|
|
|
|
import type { DefaultTheme } from 'vitepress/theme'
|
|
|
|
|
|
|
|
import { computed } from 'vue'
|
|
|
|
import { useData } from '../composables/data'
|
|
|
|
import { useData } from '../composables/data'
|
|
|
|
import { isActive } from '../../shared'
|
|
|
|
import { isActive } from '../../shared'
|
|
|
|
import VPFlyout from './VPFlyout.vue'
|
|
|
|
import VPFlyout from './VPFlyout.vue'
|
|
|
|
|
|
|
|
|
|
|
|
defineProps<{
|
|
|
|
const props = defineProps<{
|
|
|
|
item: DefaultTheme.NavItemWithChildren
|
|
|
|
item: DefaultTheme.NavItemWithChildren
|
|
|
|
}>()
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
|
|
const { page } = useData()
|
|
|
|
const { page } = useData()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isChildActive = (navItem: DefaultTheme.NavItem) => {
|
|
|
|
|
|
|
|
if ('link' in navItem) {
|
|
|
|
|
|
|
|
return isActive(
|
|
|
|
|
|
|
|
page.value.relativePath,
|
|
|
|
|
|
|
|
navItem.link,
|
|
|
|
|
|
|
|
!!props.item.activeMatch
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return navItem.items.some(isChildActive)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childrenActive = computed(() => isChildActive(props.item))
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
@ -19,7 +34,7 @@ const { page } = useData()
|
|
|
|
page.relativePath,
|
|
|
|
page.relativePath,
|
|
|
|
item.activeMatch,
|
|
|
|
item.activeMatch,
|
|
|
|
!!item.activeMatch
|
|
|
|
!!item.activeMatch
|
|
|
|
)
|
|
|
|
) || childrenActive
|
|
|
|
}"
|
|
|
|
}"
|
|
|
|
:button="item.text"
|
|
|
|
:button="item.text"
|
|
|
|
:items="item.items"
|
|
|
|
:items="item.items"
|
|
|
|