wood chen c4cd99a827 feat(cache): Implement comprehensive caching system for proxy requests
- Add CacheManager to handle caching for proxy and mirror handlers
- Introduce cache-related API endpoints for stats, enabling, and clearing
- Modify proxy and mirror handlers to support caching GET requests
- Remove rate limiting and simplify request handling
- Update go.mod dependencies and remove unused imports
- Add cache hit/miss headers to responses
- Enhance metrics collection for cached requests
2025-02-15 17:00:16 +08:00

65 lines
1.7 KiB
TypeScript

"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 (
<nav className="border-b bg-white">
<div className="container mx-auto flex h-14 items-center px-4">
<div className="mr-4 font-bold"></div>
<div className="flex flex-1 items-center space-x-4 md:space-x-6">
<Link
href="/dashboard"
className={pathname === "/dashboard" ? "text-primary" : "text-muted-foreground"}
>
</Link>
<Link
href="/dashboard/config"
className={pathname === "/dashboard/config" ? "text-primary" : "text-muted-foreground"}
>
</Link>
<Link
href="/dashboard/cache"
className={pathname === "/dashboard/cache" ? "text-primary" : "text-muted-foreground"}
>
</Link>
</div>
<Button variant="ghost" onClick={handleLogout}>
退
</Button>
</div>
</nav>
)
}