"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useEffect, useState, type ReactNode } from "react"; import { openAppDownload, useAppDownloadHref } from "@/components/download/download-dialog"; import { footerNavItems } from "@/components/layout/footer-nav-items"; import { lockBodyScroll } from "@/lib/browser/scroll-lock"; import type { AppTranslationInfo, ConfigInfo, TranslationCategory, TranslationInfo } from "@/lib/api/types"; import { OFFICIAL_TG_HANDLE, OFFICIAL_TG_URL } from "@/lib/seo/metadata"; import { resolveAboutPlatformHref, resolveNavHref } from "./nav-href"; import { categoryHref, isNavActive } from "./nav-utils"; function isDownloadAppNav(name?: string | null) { return (name || "").trim() === "下载APP"; } function withDividers(items: ReactNode[], divider: string) { return items.flatMap((item, index) => index === 0 ? [item] : [, item], ); } /** 联系方式只保留官方 TG */ const contacts = [ { key: "tg", node: ( 官方TG:{OFFICIAL_TG_HANDLE} ), }, ]; const socials = [{ label: "Telegram", icon: "/images/footer_tg.svg", href: OFFICIAL_TG_URL }]; function InfoNavLink({ item, onClose }: { item: TranslationInfo; onClose: () => void }) { const href = resolveAboutPlatformHref(item); const external = /^https?:\/\//i.test(href); const className = "text-xs leading-[18px] text-[#948AA3]/90"; if (external) { return ( {item.name} ); } return ( {item.name} ); } export function MobileMenu({ open, onClose, categoryList, bottonTranslations, }: { open: boolean; onClose: () => void; categoryList?: TranslationCategory[] | null; bottonTranslations?: AppTranslationInfo | null; config?: ConfigInfo | null; }) { const pathname = usePathname(); const categories = categoryList ?? []; const [expandedId, setExpandedId] = useState(null); // 仅渲染接口 bottonTranslations,不补自定义项 const bottomNavLinks = footerNavItems(bottonTranslations); const downloadHref = useAppDownloadHref(); useEffect(() => { if (!open) return; const onKeyDown = (event: KeyboardEvent) => { if (event.key === "Escape") onClose(); }; const unlockScroll = lockBodyScroll(); window.addEventListener("keydown", onKeyDown); return () => { unlockScroll(); window.removeEventListener("keydown", onKeyDown); }; }, [open, onClose]); return (
黄果黑料 {bottomNavLinks.length ? ( ) : null} {contacts.length ? (
{withDividers( contacts.map((item) => {item.node}), "h-[18px] w-px bg-[#615970]", )}
) : null} {socials.length ? (
{withDividers( socials.map((social) => ( )), "h-[15px] w-px bg-white/20", )}
) : null}
); }