'use client'; import { cn } from "@/lib/utils"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useEffect, useRef, useState } from "react"; import { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer" import { Button } from "@/components/ui/button"; import { X } from "lucide-react"; export default function Header() { const router = useRouter(); const pathname = usePathname(); const [showMenu, setShowMenu] = useState(false); const menuItems = [ { name: '特恩(TONE)', path: '/' }, { name: '资源', path: '/resource' }, { name: '博客', path: '/blog' }, { name: '控制台', path: '/console' }, ]; const handleClick = (e: React.MouseEvent, path: string) => { if (path === '/console') { e.preventDefault(); const token = typeof window !== 'undefined' ? localStorage.getItem('token') : null; router.push(token ? '/console' : '/console/login'); setShowMenu(false); } else { setShowMenu(false); } } const menuButtonRef = useRef(null); useEffect(() => { if (!showMenu && menuButtonRef.current) { menuButtonRef.current.focus(); } }, [showMenu]); return ( <>
特恩(TONE) {pathname === "/" ? : }
菜单 请选择需要前往的页面 ) }