"use client"; import { useState } from "react"; import Image from "next/image"; import { usePathname, useRouter } from "next/navigation"; import { ScrollShadow } from "@heroui/react"; import { Menu, X, TrendingUp, BarChart3, ArrowLeftRight, Landmark, ShieldCheck, Network, Sparkles, HelpCircle, type LucideIcon, } from "lucide-react"; import { useQuery } from "@tanstack/react-query"; import { useApp } from "@/contexts/AppContext"; import WalletButton from "@/components/wallet/WalletButton"; import LanguageSwitch from "./LanguageSwitch"; import { fetchStats } from "@/lib/api/fundmarket"; interface NavItem { Icon: LucideIcon; label: string; key: string; path: string; } export default function Sidebar() { const { t } = useApp(); const pathname = usePathname(); const router = useRouter(); const [mobileOpen, setMobileOpen] = useState(false); const { data: stats = [] } = useQuery({ queryKey: ["fundmarket-stats"], queryFn: fetchStats, staleTime: 5 * 60 * 1000, }); const tvlValue = stats[0]?.value ?? "$0"; const navigationItems: NavItem[] = [ { Icon: TrendingUp, label: t("nav.fundMarket"), key: "FundMarket", path: "/market" }, { Icon: BarChart3, label: t("nav.alp"), key: "ALP", path: "/alp" }, { Icon: ArrowLeftRight, label: t("nav.swap"), key: "Swap", path: "/swap" }, { Icon: Landmark, label: t("nav.lending"), key: "Lending", path: "/lending" }, { Icon: ShieldCheck, label: t("nav.transparency"), key: "Transparency", path: "/transparency" }, { Icon: Network, label: t("nav.ecosystem"), key: "Ecosystem", path: "/ecosystem" }, { Icon: Sparkles, label: t("nav.points"), key: "Points", path: "/points" }, ]; const isActive = (path: string) => pathname === path || pathname.startsWith(path + "/"); // 桌面端导航项 const renderDesktopNavItems = (onClick: (path: string) => void) => navigationItems.map(({ Icon, label, key, path }) => { const active = isActive(path); return (