feat: 全站评论开关,并统一后台表单控件

关闭评论后前台隐藏评论能力;外观/设置/公告改用 AdminField 与 Stepper。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-17 01:22:00 +08:00
parent 442af625f6
commit d93635c961
27 changed files with 989 additions and 479 deletions

View File

@@ -2,6 +2,7 @@ import Link from "next/link";
import { ArrowLeft } from "lucide-react";
import type { PostListItem } from "@/lib/api";
import { formatRelative } from "@/lib/format";
import { getPublicSettingsCached } from "@/lib/serverData";
import { normalizePostType, postTypeLabel, contentAccessLabel, typeStatusLabel, typeStatusClass } from "@/lib/postMeta";
import LikeButton from "./LikeButton";
import Avatar from "./Avatar";
@@ -15,7 +16,7 @@ import { IconComment, IconEye } from "./Icons";
* 点击:标题 stretch-link 铺满整行进帖;仅头像/作者/回复者/点赞等加 above-link 抬层。
* 板块胶囊仅展示,不可点,避免误进板块筛选。
*/
export default function PostRow({
export default async function PostRow({
post,
showBoard = false,
index = 0,
@@ -31,8 +32,12 @@ export default function PostRow({
showViews?: boolean;
showLike?: boolean;
}) {
const allowComments = (await getPublicSettingsCached()).allow_comments !== false;
const lastReply = post.last_reply;
const replied = lastReply && new Date(lastReply.created_at).getTime() > new Date(post.created_at).getTime() + 60_000;
const replied =
allowComments &&
lastReply &&
new Date(lastReply.created_at).getTime() > new Date(post.created_at).getTime() + 60_000;
const pt = normalizePostType(post.post_type);
const statusBadge = pt !== "discussion" ? typeStatusLabel(pt, post.type_status) : "";
const statusClass = statusBadge ? typeStatusClass(pt, post.type_status) : "";
@@ -115,7 +120,7 @@ export default function PostRow({
<span className="tabular-nums shrink-0">{formatRelative(lastReply!.created_at)}</span>
</span>
)}
{!replied && post.comment_count === 0 && (
{!replied && allowComments && post.comment_count === 0 && (
<span className="hidden sm:inline" aria-hidden>
· 暂无回复
</span>
@@ -124,15 +129,17 @@ export default function PostRow({
</div>
<div className="flex items-center gap-3 sm:gap-4 shrink-0">
<Link
href={`/post/${post.id}`}
tabIndex={-1}
aria-label={`${post.comment_count} 条评论`}
className={`${showViews ? "hidden sm:inline-flex" : "inline-flex"} above-link items-center gap-1.5 meta tabular-nums text-[13.5px] hover:text-[var(--accent)] transition-colors`}
>
<IconComment size={17} />
{post.comment_count}
</Link>
{allowComments ? (
<Link
href={`/post/${post.id}`}
tabIndex={-1}
aria-label={`${post.comment_count} 条评论`}
className={`${showViews ? "hidden sm:inline-flex" : "inline-flex"} above-link items-center gap-1.5 meta tabular-nums text-[13.5px] hover:text-[var(--accent)] transition-colors`}
>
<IconComment size={17} />
{post.comment_count}
</Link>
) : null}
{showViews && (
<span
className="hidden md:inline-flex items-center gap-1.5 meta tabular-nums"