feat: 后台增加开放消息开关

关闭后前台隐藏私聊/群聊入口并由后端拦截;同步去掉公告页重复计数胶囊。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-17 04:16:10 +08:00
parent 9a55c2f6f2
commit 4b93739468
18 changed files with 275 additions and 91 deletions

View File

@@ -596,6 +596,8 @@ export interface PublicSettings {
allow_register: boolean;
/** 全站是否开放评论;关闭后前台不展示评论能力 */
allow_comments: boolean;
/** 全站是否开放私聊/群聊;关闭后前台不展示消息入口 */
allow_messages: boolean;
post_cooldown_hours: number;
/** 超过 N 行的代码块是否默认折叠;缺省 true */
code_block_auto_fold: boolean;
@@ -620,6 +622,7 @@ const DEFAULT_PUBLIC_SETTINGS: PublicSettings = {
site_description: "姜十三论坛 - 技术分享与讨论社区",
allow_register: true,
allow_comments: true,
allow_messages: true,
post_cooldown_hours: 24,
code_block_auto_fold: true,
code_block_fold_lines: 5,
@@ -641,6 +644,7 @@ function normalizePublicSettings(data: Partial<PublicSettings> | null | undefine
: DEFAULT_PUBLIC_SETTINGS.site_description,
allow_register: data?.allow_register !== false,
allow_comments: data?.allow_comments !== false,
allow_messages: data?.allow_messages !== false,
post_cooldown_hours:
typeof data?.post_cooldown_hours === "number" && data.post_cooldown_hours >= 0
? data.post_cooldown_hours
@@ -1744,6 +1748,7 @@ export type UpdateSiteSettingsBody = {
site_description?: string;
allow_register?: boolean;
allow_comments?: boolean;
allow_messages?: boolean;
post_cooldown_hours?: number;
code_block_auto_fold?: boolean;
code_block_fold_lines?: number;