import type { Metadata } from "next"; import { auth } from "@/auth"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Globe, ExternalLink } from "lucide-react"; import Link from "next/link"; export const metadata: Metadata = { title: "仪表盘", }; const SERVER_API_URL = process.env.SERVER_API_URL || "http://backend:8080"; interface Bookmark { id: number; title: string; url: string; description: string; icon: string; category: string; } async function fetchPublicBookmarks(): Promise { try { const res = await fetch(`${SERVER_API_URL}/api/bookmarks/public`, { next: { revalidate: 0 }, }); if (!res.ok) return []; const data = await res.json(); return data.bookmarks?.slice(0, 6) || []; } catch { return []; } } export default async function DashboardPage() { const session = await auth(); const user = session?.user as any; const isAdmin = user?.role === "admin"; const bookmarks = await fetchPublicBookmarks(); return (

欢迎,{user?.name || user?.email}

用户信息

用户名: {user?.name}

邮箱: {user?.email}

角色: {user?.role}

最近书签 {isAdmin && ( 管理 → )} {bookmarks.length === 0 ? (

还没有公开书签

) : (
{bookmarks.map((bm) => (
{bm.icon ? ( ) : ( )}
{bm.title}
))}
)}
); }