Files
ai-portal/app/news/page.tsx
T

72 lines
2.9 KiB
TypeScript
Raw Normal View History

2026-05-06 17:22:50 +08:00
import { prisma } from "@//app/lib/prisma"
import Link from "next/link"
export const dynamic = "force-dynamic"
2026-05-06 17:22:50 +08:00
export default async function NewsPage() {
const news = await prisma.news.findMany({
where: { published: true },
orderBy: { createdAt: "desc" },
})
return (
<div className="min-h-screen bg-gray-50">
<nav className="bg-white border-b border-gray-200">
<div className="max-w-6xl mx-auto px-6 py-3">
<div className="flex items-center justify-between">
<Link href="/" className="flex items-center gap-2">
<div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center">
<span className="text-white font-bold text-sm">AI</span>
</div>
<span className="font-bold text-gray-900">广</span>
</Link>
<div className="flex items-center gap-6">
<Link href="/" className="text-gray-600 hover:text-blue-600 transition"></Link>
<Link href="/agents" className="text-gray-600 hover:text-blue-600 transition">广</Link>
<Link href="/news" className="text-blue-600 font-medium"></Link>
</div>
</div>
</div>
</nav>
<main className="max-w-6xl mx-auto px-6 py-8">
<h1 className="text-2xl font-bold text-gray-900 mb-8"></h1>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5">
{news.map((item) => (
<Link
key={item.id}
href={`/news/${item.id}`}
className="bg-white rounded-2xl border border-gray-200 overflow-hidden hover:border-blue-300 hover:shadow-md transition"
>
<div className="h-36 bg-gradient-to-br from-blue-100 to-indigo-100 flex items-center justify-center">
<span className="text-5xl">📰</span>
</div>
<div className="p-5">
<div className="flex items-center gap-2 mb-3">
<span className="px-2 py-0.5 bg-blue-50 text-blue-600 text-xs font-medium rounded-full">
{item.type === "news" ? "新闻" : item.type}
</span>
<span className="text-xs text-gray-400">
{new Date(item.createdAt).toLocaleDateString("zh-CN")}
</span>
</div>
<h3 className="font-semibold text-gray-900 mb-2 leading-snug">{item.title}</h3>
<p className="text-gray-500 text-sm leading-relaxed">
{item.content.substring(0, 100)}...
</p>
</div>
</Link>
))}
</div>
{news.length === 0 && (
<div className="text-center py-12 text-gray-500">
</div>
)}
</main>
</div>
)
}