import { prisma } from "@/lib/prisma"; import { getServerSession } from "next-auth"; import { authOptions } from "@/lib/auth"; export const dynamic = "force-dynamic"; async function getHotTopics() { return prisma.forumTopic.findMany({ where: {}, include: { category: { select: { name: true, slug: true, icon: true } }, user: { select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true } }, _count: { select: { posts: true } }, }, orderBy: [{ isPinned: "desc" }, { createdAt: "desc" }], take: 5, }); } async function getActiveUsers() { return prisma.user.findMany({ where: { OR: [ { forumTopics: { some: {} } }, { forumPosts: { some: {} } }, ], }, select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true }, take: 5, }); } export default async function CommunityPage() { const categories = await prisma.forumCategory.findMany({ where: { parentId: null }, include: { children: { orderBy: [{ sortOrder: "asc" }], }, }, orderBy: [{ sortOrder: "asc" }, { createdAt: "desc" }], }); const [hotTopics, activeUsers] = await Promise.all([getHotTopics(), getActiveUsers()]); return (

追光会

AI爱好者交流社区

板块

{categories.map((cat) => (
{cat.icon || "📌"}

{cat.name}

{cat.description && ( {cat.description} )}
{cat.children.map((child) => (
(window.location.href = `/community/${child.slug}`)} > {child.icon || "📌"}

{child.name}

{child.description && (

{child.description}

)}
{child.topicCount}话题
))}
))}

最新话题

{hotTopics.map((topic) => { const initial = topic.user.name?.charAt(0).toUpperCase() || "?"; return (
(window.location.href = `/community/topic/${topic.id}`)} > {topic.user.avatarUrl ? ( ) : (
{initial}
)}
{topic.isPinned && ( 置顶 )}

{topic.title}

{topic.user.name || topic.user.email.split("@")[0]} {topic.category.name} {topic._count.posts}回复 {topic.viewCount}浏览
); })}

活跃用户

{activeUsers.map((user) => { const initial = user.name?.charAt(0).toUpperCase() || "?"; return (
{user.avatarUrl ? ( ) : (
{initial}
)}

{user.name || user.email.split("@")[0]}

{user.points}分

); })}
); }