"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useState, useCallback } from "react";
import { motion } from "framer-motion";
// 导航链接配置
const NAV_LINKS = [{ path: "/", label: "首页" }];
export default function Header() {
const pathname = usePathname();
const [isMenuOpen, setIsMenuOpen] = useState(false);
const toggleMenu = useCallback(() => {
setIsMenuOpen((prev) => !prev);
}, []);
const closeMenu = useCallback(() => {
setIsMenuOpen(false);
}, []);
const sidebarVariants = {
open: {
x: 0,
transition: {
type: "spring" as const,
stiffness: 300,
damping: 30,
staggerChildren: 0.1,
delayChildren: 0.1,
},
},
closed: {
x: "100%",
transition: {
type: "spring" as const,
stiffness: 300,
damping: 30,
staggerChildren: 0.05,
staggerDirection: -1,
},
},
};
const menuItemVariants = {
open: {
y: 0,
opacity: 1,
transition: {
y: { stiffness: 1000, velocity: -100 },
},
},
closed: {
y: 20,
opacity: 0,
transition: {
y: { stiffness: 1000 },
},
},
};
// 导航链接组件
const NavLink = ({ href, children, className, onClick }: { href: string; children: React.ReactNode; className?: string; onClick?: () => void }) => (