feat: 后台增加开放消息开关
关闭后前台隐藏私聊/群聊入口并由后端拦截;同步去掉公告页重复计数胶囊。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
MessageSquare,
|
||||
Save,
|
||||
UserPlus,
|
||||
MessagesSquare,
|
||||
ExternalLink,
|
||||
Shield,
|
||||
Mail,
|
||||
@@ -107,12 +108,14 @@ export default function SettingsAdmin({ initial }: { initial: PublicSettings })
|
||||
const [siteDescription, setSiteDescription] = useState(initial.site_description);
|
||||
const [allowRegister, setAllowRegister] = useState(initial.allow_register);
|
||||
const [allowComments, setAllowComments] = useState(initial.allow_comments !== false);
|
||||
const [allowMessages, setAllowMessages] = useState(initial.allow_messages !== false);
|
||||
const [postLinkNewTab, setPostLinkNewTab] = useState(initial.post_link_new_tab !== false);
|
||||
const [savedName, setSavedName] = useState(initial.site_name);
|
||||
const [savedDesc, setSavedDesc] = useState(initial.site_description);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [togglingReg, setTogglingReg] = useState(false);
|
||||
const [togglingComments, setTogglingComments] = useState(false);
|
||||
const [togglingMessages, setTogglingMessages] = useState(false);
|
||||
const [togglingLink, setTogglingLink] = useState(false);
|
||||
const [active, setActive] = useState<SectionId>("basic");
|
||||
|
||||
@@ -199,6 +202,21 @@ export default function SettingsAdmin({ initial }: { initial: PublicSettings })
|
||||
}
|
||||
};
|
||||
|
||||
const toggleMessages = async () => {
|
||||
if (togglingMessages) return;
|
||||
const next = !allowMessages;
|
||||
setTogglingMessages(true);
|
||||
try {
|
||||
const res = await apiUpdateSiteSettings({ allow_messages: next });
|
||||
setAllowMessages(res.allow_messages);
|
||||
toast(res.allow_messages ? "已开放消息" : "已关闭消息", "ok");
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : "保存失败");
|
||||
} finally {
|
||||
setTogglingMessages(false);
|
||||
}
|
||||
};
|
||||
|
||||
const togglePostLinkNewTab = async () => {
|
||||
if (togglingLink) return;
|
||||
const next = !postLinkNewTab;
|
||||
@@ -293,7 +311,7 @@ export default function SettingsAdmin({ initial }: { initial: PublicSettings })
|
||||
</div>
|
||||
|
||||
<div id="settings-content" className="scroll-mt-4">
|
||||
<AdminSection title="内容与互动" description="控制注册、评论与链接打开方式">
|
||||
<AdminSection title="内容与互动" description="控制注册、评论、消息与链接打开方式">
|
||||
<SwitchRow
|
||||
bordered
|
||||
title={
|
||||
@@ -328,6 +346,23 @@ export default function SettingsAdmin({ initial }: { initial: PublicSettings })
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SwitchRow
|
||||
bordered
|
||||
title={
|
||||
<>
|
||||
<MessagesSquare size={15} /> 开放消息
|
||||
</>
|
||||
}
|
||||
description="关闭后前台不展示私聊与群聊入口;已有会话由后台消息管理继续监管。"
|
||||
control={
|
||||
<AdminSwitch
|
||||
checked={allowMessages}
|
||||
disabled={togglingMessages}
|
||||
onChange={() => void toggleMessages()}
|
||||
label="开放消息"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SwitchRow
|
||||
title={
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user