"use client"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { type ReactNode, useEffect } from "react"; import { Truck, SignOut } from "@phosphor-icons/react"; import { useAuth } from "@/hooks/use-auth"; import { LoadingSpinner } from "@/components/ui/loading-spinner"; const NAV_ITEMS = [ { href: "/dashboard", label: "工作台" }, { href: "/admin/customers", label: "客户管理" }, { href: "/admin/markup", label: "加价配置" }, { href: "/admin/alerts", label: "预警中心" }, { href: "/admin/queues", label: "查价记录" }, ]; interface AdminLayoutProps { children: ReactNode; } export function AdminLayout({ children }: AdminLayoutProps) { const pathname = usePathname(); const router = useRouter(); const { user, token, ready, logout } = useAuth(); useEffect(() => { if (!ready) return; if (!token || !user) { const redirect = encodeURIComponent(pathname); router.replace(`/login?redirect=${redirect}`); } }, [ready, token, user, pathname, router]); if (!ready) { return (