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

@@ -85,9 +85,11 @@ function BoardIntro({ board }: { board: BoardWithCount }) {
function BoardPulse({
stats,
checkin,
allowComments,
}: {
stats: BoardSidebarStats;
checkin?: CheckinStatus | null;
allowComments: boolean;
}) {
const cells = [
{
@@ -104,20 +106,24 @@ function BoardPulse({
foot: "本日新增",
up: stats.today_posts > 0,
},
{
icon: <MessageCircle size={12.5} />,
label: "回复总数",
value: formatCompact(stats.comment_count),
foot: `+${formatCompact(stats.today_comments)} 今日`,
up: true,
},
{
icon: <Heart size={12.5} />,
label: "今日回复",
value: formatCompact(stats.today_comments),
foot: "本日新增",
up: stats.today_comments > 0,
},
...(allowComments
? [
{
icon: <MessageCircle size={12.5} />,
label: "回复总数",
value: formatCompact(stats.comment_count),
foot: `+${formatCompact(stats.today_comments)} 今日`,
up: true,
},
{
icon: <Heart size={12.5} />,
label: "今日回复",
value: formatCompact(stats.today_comments),
foot: "本日新增",
up: stats.today_comments > 0,
},
]
: []),
];
return (
<section className="j13-module" aria-label="板块数据">
@@ -150,7 +156,7 @@ function BoardPulse({
/* ---------- 4. 本板热门 ---------- */
function BoardHot({ posts }: { posts: PostListItem[] }) {
function BoardHot({ posts, allowComments }: { posts: PostListItem[]; allowComments: boolean }) {
return (
<section className="j13-module" aria-label="本板热门">
<p className="j13-module-title mb-1.5">
@@ -169,9 +175,11 @@ function BoardHot({ posts }: { posts: PostListItem[] }) {
{p.title}
</span>
<span className="mt-1 flex items-center gap-2.5 meta text-[11.5px]">
<span className="inline-flex items-center gap-1">
<MessageCircle size={11.5} /> {p.comment_count}
</span>
{allowComments ? (
<span className="inline-flex items-center gap-1">
<MessageCircle size={11.5} /> {p.comment_count}
</span>
) : null}
<span className="inline-flex items-center gap-1">
<Heart size={11.5} /> {p.like_count}
</span>
@@ -188,7 +196,7 @@ function BoardHot({ posts }: { posts: PostListItem[] }) {
/* ---------- 5. 本板活跃 ---------- */
function BoardActive({ users }: { users: ActiveUser[] }) {
function BoardActive({ users, allowComments }: { users: ActiveUser[]; allowComments: boolean }) {
return (
<section className="j13-module" aria-label="本板活跃成员">
<p className="j13-module-title mb-2">
@@ -221,17 +229,23 @@ function BoardActive({ users }: { users: ActiveUser[] }) {
<span className="inline-flex items-center gap-1">
<PenLine size={10.5} /> 发帖 {u.post_count}
</span>
<span className="inline-flex items-center gap-1">
<MessageCircle size={10.5} /> 回复 {u.comment_count}
</span>
{allowComments ? (
<span className="inline-flex items-center gap-1">
<MessageCircle size={10.5} /> 回复 {u.comment_count}
</span>
) : null}
</span>
</span>
<span
className="shrink-0 text-[13px] tabular-nums"
style={{ color: "var(--accent)" }}
aria-label={`本周共 ${u.post_count + u.comment_count} 次互动`}
aria-label={
allowComments
? `本周共 ${u.post_count + u.comment_count} 次互动`
: `本周发帖 ${u.post_count}`
}
>
{u.post_count + u.comment_count}
{allowComments ? u.post_count + u.comment_count : u.post_count}
</span>
</Link>
</li>
@@ -252,6 +266,7 @@ type BoardPanelsProps = {
hot: PostListItem[];
activeUsers: ActiveUser[];
checkin?: CheckinStatus | null;
allowComments: boolean;
};
function BoardPanelsBody(props: BoardPanelsProps) {
@@ -259,9 +274,9 @@ function BoardPanelsBody(props: BoardPanelsProps) {
<>
<Moderators items={props.moderators} />
<BoardIntro board={props.board} />
<BoardPulse stats={props.stats} checkin={props.checkin} />
<BoardHot posts={props.hot} />
<BoardActive users={props.activeUsers} />
<BoardPulse stats={props.stats} checkin={props.checkin} allowComments={props.allowComments} />
<BoardHot posts={props.hot} allowComments={props.allowComments} />
<BoardActive users={props.activeUsers} allowComments={props.allowComments} />
</>
);
}