"use client" import Link from "next/link" import { usePathname, useRouter } from "next/navigation" import { Button } from "@/components/ui/button" import { useToast } from "@/components/ui/use-toast" export function Nav() { const pathname = usePathname() const router = useRouter() const { toast } = useToast() const handleLogout = async () => { try { const response = await fetch("/admin/api/logout", { method: "POST", }) if (response.ok) { localStorage.removeItem("token") toast({ title: "已退出登录", }) router.push("/") } } catch { toast({ title: "退出失败", description: "请稍后重试", variant: "destructive", }) } } return ( ) }