diff --git a/src/app/community/[category]/page.tsx b/src/app/community/[category]/page.tsx
index f86437c..316ad4c 100644
--- a/src/app/community/[category]/page.tsx
+++ b/src/app/community/[category]/page.tsx
@@ -15,6 +15,11 @@ export default async function CategoryPage({ params, searchParams }: Props) {
if (!category) notFound();
+ const childCategories = await prisma.forumCategory.findMany({
+ where: { parentId: category.id },
+ select: { id: true, name: true, slug: true },
+ });
+
const sort = searchParams.sort || "latest";
const page = parseInt(searchParams.page || "1", 10);
const pageSize = 20;
@@ -30,7 +35,7 @@ export default async function CategoryPage({ params, searchParams }: Props) {
where: { categoryId: category.id },
include: {
category: { select: { name: true, slug: true, icon: true } },
- user: { select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true } },
+ user: { select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true, isBot: true } },
_count: { select: { posts: true } },
},
orderBy: [{ isPinned: "desc" }, orderBy],
@@ -70,6 +75,26 @@ export default async function CategoryPage({ params, searchParams }: Props) {
))}
+ {childCategories.length > 0 && (
+
+ )}
+
{topics.map((topic) => {
const initial = topic.user.name?.charAt(0).toUpperCase() || "?";
@@ -99,7 +124,7 @@ export default async function CategoryPage({ params, searchParams }: Props) {
-
{topic.user.name || topic.user.email?.split("@")[0]}
+
{topic.user.name || topic.user.email?.split("@")[0]}{topic.user.isBot && AI}
{topic.createdAt?.toLocaleDateString("zh-CN")}
{topic._count.posts}回复
{topic.viewCount}浏览
diff --git a/src/app/community/topic/[id]/ReplyForm.tsx b/src/app/community/topic/[id]/ReplyForm.tsx
new file mode 100644
index 0000000..aad84c8
--- /dev/null
+++ b/src/app/community/topic/[id]/ReplyForm.tsx
@@ -0,0 +1,66 @@
+"use client";
+
+import { useState } from "react";
+
+interface ReplyFormProps {
+ topicId: number;
+ isLocked: boolean;
+}
+
+export function ReplyForm({ topicId, isLocked }: ReplyFormProps) {
+ const [submitting, setSubmitting] = useState(false);
+
+ if (isLocked) {
+ return (
+
+ );
+ }
+
+ return (
+
+ );
+}
\ No newline at end of file
diff --git a/src/app/community/topic/[id]/page.tsx b/src/app/community/topic/[id]/page.tsx
index 9cd4028..824a2ba 100644
--- a/src/app/community/topic/[id]/page.tsx
+++ b/src/app/community/topic/[id]/page.tsx
@@ -2,6 +2,7 @@ import { prisma } from "@/lib/prisma";
import { notFound } from "next/navigation";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
+import { ReplyForm } from "./ReplyForm";
export const dynamic = "force-dynamic";
@@ -17,7 +18,7 @@ export default async function TopicPage({ params }: Props) {
where: { id: topicId },
include: {
category: { select: { name: true, slug: true, icon: true } },
- user: { select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true } },
+ user: { select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true, isBot: true } },
_count: { select: { posts: true } },
},
});
@@ -32,7 +33,7 @@ export default async function TopicPage({ params }: Props) {
const posts = await prisma.forumPost.findMany({
where: { topicId },
include: {
- user: { select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true } },
+ user: { select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true, isBot: true } },
},
orderBy: { createdAt: "asc" },
take: 50,
@@ -79,7 +80,7 @@ export default async function TopicPage({ params }: Props) {
)}
-
{topic.user.name || topic.user.email?.split("@")[0]}
+
{topic.user.name || topic.user.email?.split("@")[0]}{topic.user.isBot && 🤖 AI}
{topic.createdAt?.toLocaleDateString("zh-CN")} {topic.createdAt?.toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" })}
@@ -113,7 +114,7 @@ export default async function TopicPage({ params }: Props) {
)}
-
{post.user.name || post.user.email?.split("@")[0]}
+
{post.user.name || post.user.email?.split("@")[0]}{post.user.isBot && 🤖 AI}
{post.createdAt?.toLocaleDateString("zh-CN")} {post.createdAt?.toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" })}
@@ -133,52 +134,7 @@ export default async function TopicPage({ params }: Props) {