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

@@ -17,6 +17,7 @@ import {
} from "@/lib/api";
import { toast } from "@/lib/toast";
import Avatar from "@/components/Avatar";
import { useAllowComments } from "@/components/CommentsPolicyProvider";
export default function PostInteractPanels({
postId,
@@ -177,6 +178,7 @@ function DeadlineCountdown({
/** 正文下方的问答状态卡(未解决 / 仅标记已解决);有采纳答案时改用 AcceptedAnswerCard */
export function QuestionStatusCard({ postId, state }: { postId: number; state: QuestionState }) {
const allowComments = useAllowComments();
const router = useRouter();
const [busy, setBusy] = useState(false);
@@ -241,7 +243,7 @@ export function QuestionStatusCard({ postId, state }: { postId: number; state: Q
<p className="j13-typed-meta">
{state.solved
? state.accepted_comment_id
? state.accepted_comment_id && allowComments
? (
<>
已采纳{" "}
@@ -255,7 +257,9 @@ export function QuestionStatusCard({ postId, state }: { postId: number; state: Q
</>
)
: "作者已标记为已解决"
: "可在评论旁采纳答案,或手动标记已解决"}
: allowComments
? "可在评论旁采纳答案,或手动标记已解决"
: "可由作者标记为已解决"}
</p>
<div className="j13-typed-foot">
@@ -466,6 +470,7 @@ function PollPanel({
}
function BountyPanel({ state }: { postId: number; state: BountyState }) {
const allowComments = useAllowComments();
const statusBadge = state.accepted_comment_id
? { cls: "badge-status badge-status-solved", label: "已采纳" }
: state.expired || state.refunded
@@ -507,7 +512,7 @@ function BountyPanel({ state }: { postId: number; state: BountyState }) {
<p className="j13-typed-meta">
<span className="j13-bounty-points tabular-nums">{state.points} 积分</span>
{bodyHint ? ` · ${bodyHint}` : null}
{state.can_accept ? " · 在评论旁点击「采纳」发放积分" : null}
{state.can_accept && allowComments ? " · 在评论旁点击「采纳」发放积分" : null}
</p>
{!state.accepted_comment_id && state.ends_at ? (
@@ -518,7 +523,7 @@ function BountyPanel({ state }: { postId: number; state: BountyState }) {
/>
) : null}
{state.accepted_comment_id > 0 && (
{allowComments && state.accepted_comment_id > 0 && (
<p className="j13-typed-meta">
已采纳{" "}
<a