"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/markup", label: "加价配置" }, { href: "/admin/alerts", label: "预警中心" }, { href: "/admin/rpa", label: "RPA 状态" }, { href: "/admin/dashboard", 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 (
); } if (!token || !user) { return null; } return (
美美与共 · 管理端 管理员
{children}
); }