"use client"; import { useSectionStore } from "@/stores/sectionStore"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; export default function SectionDropdown() { const { sections } = useSectionStore(); if (!sections || sections.length === 0) return null; return ( 页面目录 {sections.map((s) => ( { const el = document.getElementById(s.id); if (!el) return; const rect = el.getBoundingClientRect(); const top = rect.top + window.scrollY - 80; window.scrollTo({ top, behavior: "smooth" }); history.replaceState(null, "", `#${s.id}`); }} > {s.name} ))} ); }