feat(settings): 后台可开关全站评论

关闭后禁止新评论与回复,已有内容仍可浏览;设置经 WS 同步到前台。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-16 07:01:46 +08:00
parent bcb4f6a603
commit 3e135542d3
5 changed files with 73 additions and 2 deletions

View File

@@ -547,6 +547,8 @@ export interface PublicSettings {
site_name: string;
site_description: string;
allow_register: boolean;
/** 全站是否开放评论/回复;缺省 true */
allow_comments: boolean;
post_cooldown_hours: number;
/** 超过 N 行的代码块是否默认折叠;缺省 true */
code_block_auto_fold: boolean;
@@ -568,6 +570,7 @@ const DEFAULT_PUBLIC_SETTINGS: PublicSettings = {
site_name: "姜十三论坛",
site_description: "姜十三论坛 - 技术分享与讨论社区",
allow_register: true,
allow_comments: true,
post_cooldown_hours: 24,
code_block_auto_fold: true,
code_block_fold_lines: 5,
@@ -587,6 +590,7 @@ function normalizePublicSettings(data: Partial<PublicSettings> | null | undefine
? String(data.site_description).trim()
: DEFAULT_PUBLIC_SETTINGS.site_description,
allow_register: data?.allow_register !== false,
allow_comments: data?.allow_comments !== false,
post_cooldown_hours:
typeof data?.post_cooldown_hours === "number" && data.post_cooldown_hours >= 0
? data.post_cooldown_hours
@@ -1530,6 +1534,7 @@ export type UpdateSiteSettingsBody = {
site_name?: string;
site_description?: string;
allow_register?: boolean;
allow_comments?: boolean;
post_cooldown_hours?: number;
code_block_auto_fold?: boolean;
code_block_fold_lines?: number;