From fbb6ec9a634ae7a26c16df2a97ea1c16a3a24d46 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Sun, 26 Oct 2025 23:18:44 +0800 Subject: [PATCH] feat(theme): optimize local nav --- theme/src/client/components/VPLocalNav.vue | 6 ++--- .../components/VPLocalNavOutlineDropdown.vue | 26 ------------------- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/theme/src/client/components/VPLocalNav.vue b/theme/src/client/components/VPLocalNav.vue index dc369a51..30cb50da 100644 --- a/theme/src/client/components/VPLocalNav.vue +++ b/theme/src/client/components/VPLocalNav.vue @@ -12,7 +12,7 @@ const props = defineProps<{ defineEmits<(e: 'openMenu') => void>() const { theme } = useData() -const { isPosts } = usePostsPageData() +const { isPosts, isPostsLayout } = usePostsPageData() const { hasSidebar } = useSidebar() const { y } = useWindowScroll() @@ -38,13 +38,13 @@ const classes = computed(() => { 'vp-local-nav': true, 'fixed': empty.value, 'reached-top': y.value >= navHeight.value, - 'is-posts': isPosts.value, + 'is-posts': isPosts.value && !isPostsLayout.value, 'with-outline': !props.showOutline, } }) const showLocalNav = computed(() => { - return (hasSidebar.value || isPosts.value) && (!empty.value || y.value >= navHeight.value) + return (hasSidebar.value || (isPosts.value && !isPostsLayout.value)) && !empty.value }) diff --git a/theme/src/client/components/VPLocalNavOutlineDropdown.vue b/theme/src/client/components/VPLocalNavOutlineDropdown.vue index 89879054..dbb1a2ad 100644 --- a/theme/src/client/components/VPLocalNavOutlineDropdown.vue +++ b/theme/src/client/components/VPLocalNavOutlineDropdown.vue @@ -42,11 +42,6 @@ function onItemClick(e: Event) { }) } } - -function scrollToTop() { - open.value = false - window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }) -}