"use client" import { useState, useEffect } from "react" import Link from "next/link" import Image from "next/image" import { usePathname } from "next/navigation" import { Menu, X } from "lucide-react" import { Button } from "@/components/ui/button" import { cn } from "@/lib/utils" export default function Header() { const [isMenuOpen, setIsMenuOpen] = useState(false) const [scrolled, setScrolled] = useState(false) const [activeSection, setActiveSection] = useState("home") const pathname = usePathname() const isHomePage = pathname === "/" useEffect(() => { const handleScroll = () => { setScrolled(window.scrollY > 10) // 只在主页上确定活动部分 if (isHomePage) { // Determine active section based on scroll position const sections = ["home", "about", "team-groups", "achievements", "robots", "contact"] for (const section of sections.reverse()) { const element = document.getElementById(section) if (element && window.scrollY >= element.offsetTop - 100) { setActiveSection(section) break } } } } window.addEventListener("scroll", handleScroll) return () => window.removeEventListener("scroll", handleScroll) }, [isHomePage]) const toggleMenu = () => { setIsMenuOpen(!isMenuOpen) } const navLinks = [ { name: "主页", href: isHomePage ? "#home" : "/#home", id: "home", en: "INDEX" }, { name: "关于", href: isHomePage ? "#about" : "/#about", id: "about", en: "INFORMATION" }, { name: "团队", href: isHomePage ? "#team-groups" : "/#team-groups", id: "team-groups", en: "OPERATOR" }, { name: "成就", href: isHomePage ? "#achievements" : "/#achievements", id: "achievements", en: "GAMEPLAY" }, { name: "机器人", href: isHomePage ? "#robots" : "/#robots", id: "robots", en: "ROBOTS" }, { name: "联系我们", href: isHomePage ? "#contact" : "/#contact", id: "contact", en: "NEWS" }, ] return (
Simba Robotics Logo
SIMBA ROBOTICS
{/* Desktop Navigation */}
{/* Mobile Menu Button */}
{/* Mobile Navigation */} {isMenuOpen && (
)}
) }