fix: 定时任务修复+管理后台Task7支持 (Task4外键修复, Task7管理员邮箱动态查询, Task5限流防护, Task7加入SCRIPT_MAP)
This commit is contained in:
@@ -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) {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{childCategories.length > 0 && (
|
||||
<div className="flex flex-wrap items-center gap-2 mb-6">
|
||||
<a
|
||||
href={`/community/${category.slug}`}
|
||||
className="px-3 py-1.5 rounded-lg text-sm bg-primary text-white"
|
||||
>
|
||||
全部
|
||||
</a>
|
||||
{childCategories.map((child) => (
|
||||
<a
|
||||
key={child.id}
|
||||
href={`/community/${child.slug}`}
|
||||
className="px-3 py-1.5 rounded-lg text-sm bg-white border border-border/40 text-muted-foreground hover:border-border/60 hover:text-foreground transition-colors"
|
||||
>
|
||||
{child.name}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-3">
|
||||
{topics.map((topic) => {
|
||||
const initial = topic.user.name?.charAt(0).toUpperCase() || "?";
|
||||
@@ -99,7 +124,7 @@ export default async function CategoryPage({ params, searchParams }: Props) {
|
||||
</h3>
|
||||
</div>
|
||||
<div className="mt-1.5 flex items-center gap-3 text-xs text-muted-foreground/50">
|
||||
<span>{topic.user.name || topic.user.email?.split("@")[0]}</span>
|
||||
<span>{topic.user.name || topic.user.email?.split("@")[0]}{topic.user.isBot && <span className="ml-1 px-1 py-0.5 text-[9px] font-medium bg-sky-100 text-sky-600 rounded">AI</span>}</span>
|
||||
<span>{topic.createdAt?.toLocaleDateString("zh-CN")}</span>
|
||||
<span>{topic._count.posts}回复</span>
|
||||
<span>{topic.viewCount}浏览</span>
|
||||
|
||||
Reference in New Issue
Block a user