Files
ai-portal/app/admin/page.tsx
T
2026-05-06 17:22:50 +08:00

115 lines
4.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { getServerSession } from "next-auth/next"
import { redirect } from "next/navigation"
import Link from "next/link"
import { prisma } from "@//app/lib/prisma"
export default async function AdminDashboard() {
const session = await getServerSession()
if (!session) {
redirect("/admin/login")
}
const agentsCount = await prisma.agent.count()
const newsCount = await prisma.news.count()
const categoriesCount = await prisma.category.count()
return (
<div className="min-h-screen bg-gray-50">
<nav className="bg-white border-b border-gray-200">
<div className="max-w-7xl mx-auto px-6 py-4 flex items-center justify-between">
<h1 className="text-xl font-bold text-gray-900"></h1>
<div className="flex items-center gap-4">
<span className="text-sm text-gray-600">{session.user?.name}</span>
<Link
href="/api/auth/signout"
className="text-sm text-red-600 hover:text-red-700"
>
退
</Link>
</div>
</div>
</nav>
<main className="max-w-7xl mx-auto px-6 py-8">
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div className="bg-white p-6 rounded-2xl shadow-sm border border-gray-200">
<div className="flex items-center gap-4 mb-4">
<div className="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center text-2xl">
🤖
</div>
<div>
<p className="text-sm text-gray-500"></p>
<p className="text-2xl font-bold text-gray-900">{agentsCount}</p>
</div>
</div>
<Link href="/admin/agents" className="text-blue-600 text-sm hover:underline">
</Link>
</div>
<div className="bg-white p-6 rounded-2xl shadow-sm border border-gray-200">
<div className="flex items-center gap-4 mb-4">
<div className="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center text-2xl">
📰
</div>
<div>
<p className="text-sm text-gray-500"></p>
<p className="text-2xl font-bold text-gray-900">{newsCount}</p>
</div>
</div>
<Link href="/admin/news" className="text-blue-600 text-sm hover:underline">
</Link>
</div>
<div className="bg-white p-6 rounded-2xl shadow-sm border border-gray-200">
<div className="flex items-center gap-4 mb-4">
<div className="w-12 h-12 bg-purple-100 rounded-xl flex items-center justify-center text-2xl">
📂
</div>
<div>
<p className="text-sm text-gray-500"></p>
<p className="text-2xl font-bold text-gray-900">{categoriesCount}</p>
</div>
</div>
<Link href="/admin/categories" className="text-blue-600 text-sm hover:underline">
</Link>
</div>
</div>
<div className="bg-white rounded-2xl shadow-sm border border-gray-200 p-6">
<h2 className="text-lg font-semibold text-gray-900 mb-4"></h2>
<div className="flex flex-wrap gap-4">
<Link
href="/admin/agents/new"
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition"
>
</Link>
<Link
href="/admin/news/new"
className="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition"
>
</Link>
<Link
href="/admin/categories/new"
className="px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition"
>
</Link>
<Link
href="/"
className="px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition"
>
</Link>
</div>
</div>
</main>
</div>
)
}