From 6b12546d06568e280acb7fde8ca73f86ce144643 Mon Sep 17 00:00:00 2001 From: zhengen Date: Sun, 11 Oct 2026 10:57:59 +0800 Subject: [PATCH] fix: correct mobile navigation layout --- components/layout/Header.tsx | 8 ++-- components/layout/MobileNavigation.tsx | 65 ++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 components/layout/MobileNavigation.tsx diff --git a/components/layout/Header.tsx b/components/layout/Header.tsx index 12676c9..ab93ee0 100644 --- a/components/layout/Header.tsx +++ b/components/layout/Header.tsx @@ -1,5 +1,6 @@ import Link from "next/link"; import { getNavigationMenu } from "@/services/navigation.service"; +import MobileNavigation from "./MobileNavigation"; const fallbackNavItems = [ { title: "首页", href: "/" }, @@ -24,15 +25,15 @@ export default async function Header() { return (
- + 企业官网 -
); diff --git a/components/layout/MobileNavigation.tsx b/components/layout/MobileNavigation.tsx new file mode 100644 index 0000000..12f78d3 --- /dev/null +++ b/components/layout/MobileNavigation.tsx @@ -0,0 +1,65 @@ +"use client"; + +import Link from "next/link"; +import { Menu, X } from "lucide-react"; +import { useId, useRef, useState } from "react"; + +interface NavigationItem { + title: string; + href: string; + newTab: boolean; +} + +export default function MobileNavigation({ items }: { items: NavigationItem[] }) { + const [isOpen, setIsOpen] = useState(false); + const menuId = useId(); + const toggleRef = useRef(null); + const label = isOpen ? "关闭导航菜单" : "打开导航菜单"; + + return ( +
{ + if (event.key === "Escape" && isOpen) { + setIsOpen(false); + toggleRef.current?.focus(); + } + }} + > + + +
+ ); +} \ No newline at end of file