From 16604e5f860f2e81c10f367001c7d8640eec1045 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 12 Jun 2026 11:52:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A2=9E=E5=8A=A0=E7=AB=99?= =?UTF-8?q?=E5=90=8D=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/common/settings/system-tab.tsx | 235 +++++++++--------- 1 file changed, 114 insertions(+), 121 deletions(-) diff --git a/frontend/components/common/settings/system-tab.tsx b/frontend/components/common/settings/system-tab.tsx index 0018f386..7e279fb7 100644 --- a/frontend/components/common/settings/system-tab.tsx +++ b/frontend/components/common/settings/system-tab.tsx @@ -2,7 +2,7 @@ import {useEffect, useState} from "react" import {useMutation, useQueryClient, type UseQueryResult} from "@tanstack/react-query" -import {Globe, Info, Loader2, Mail, Search, Server, Sparkles} from "lucide-react" +import {Globe, Loader2, Mail, Search, Server, Sparkles} from "lucide-react" import {Button} from "@/components/ui/button" import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/components/ui/card" @@ -23,6 +23,7 @@ interface SystemTabProps { export function SystemTab({ configs, systemConfigsQuery }: SystemTabProps) { const queryClient = useQueryClient() const [serverAddress, setServerAddress] = useState("") + const [siteName, setSiteName] = useState("") const [smtpHost, setSmtpHost] = useState("") const [smtpPort, setSmtpPort] = useState("") const [smtpUsername, setSmtpUsername] = useState("") @@ -36,6 +37,7 @@ export function SystemTab({ configs, systemConfigsQuery }: SystemTabProps) { useEffect(() => { if (systemConfigsQuery.data) { setServerAddress(configs["server_address"]?.value || "") + setSiteName(configs["site_name"]?.value || "") setSmtpHost(configs["smtp_host"]?.value || "") setSmtpPort(configs["smtp_port"]?.value || "587") setSmtpUsername(configs["smtp_username"]?.value || "") @@ -73,14 +75,24 @@ export function SystemTab({ configs, systemConfigsQuery }: SystemTabProps) { const saveSystemMutation = useMutation({ mutationFn: async () => { - const currentCfg = configs["server_address"] - await AdminService.updateSystemConfig("server_address", { - value: serverAddress, - description: currentCfg?.description || "服务器地址", - }) + const currentAddrCfg = configs["server_address"] + const currentSiteCfg = configs["site_name"] + await Promise.all([ + AdminService.updateSystemConfig("server_address", { + value: serverAddress, + description: currentAddrCfg?.description || "服务器地址", + }), + AdminService.updateSystemConfig("site_name", { + value: siteName, + description: currentSiteCfg?.description || "系统平台的展示名称", + }), + ]) }, onSuccess: async () => { - await queryClient.invalidateQueries({ queryKey: ["admin", "system-configs"] }) + await Promise.all([ + queryClient.invalidateQueries({ queryKey: ["admin", "system-configs"] }), + queryClient.invalidateQueries({ queryKey: ["public-config"] }), + ]) toast.success("通用配置已成功保存") }, onError: (error: Error) => { @@ -178,137 +190,119 @@ export function SystemTab({ configs, systemConfigsQuery }: SystemTabProps) { return (
{/* 通用设置 */} - - -
-
- + + +
+
+
- 通用设置 - 配置系统的全局网络通信访问限制与搜索引擎的公开检索收录参数 + 通用设置 + + 配置站点标识、服务地址与搜索引擎收录策略 +
- -
+ +
+
+
+ + setSiteName(e.target.value)} + placeholder="例如: Wavelet" + className="border-dashed bg-card text-xs" + /> +

+ 用于网页标题、登录注册页面、管理后台与系统邮件。 +

+
- {/* 跨域源与服务器地址 */} - -
-
-
- - 访问域名与跨域来源限制 -
+
+
+
-
-
- -
-
- setServerAddress(e.target.value)} - placeholder="例如: https://example.com" - className="bg-zinc-50/50 dark:bg-zinc-900/50 border-zinc-200 dark:border-zinc-800 text-xs focus-visible:ring-1 focus-visible:ring-indigo-500 transition-all duration-200 h-9.5" - /> -
-
- -

- 配置 API 的对外服务访问域名。留空则允许任意源访问(CORS 将开放 `*`,有安全风险)。若配置具体域名,将激活同源及 CORS 白名单验证保护。 -

-
-
-
-
- -
- - - {/* SEO 搜索引擎抓取 */} -
-
-
-
- - 搜索引擎抓取检索 (SEO) -
- - - {indexingEnabled ? "已启用索引" : "已屏蔽检索"} - -
-
- 站点检索可见性开关 -
- -

- 控制本系统是否向主流搜索引擎(如 Google、Baidu、Bing)开放公开索引。关闭时,系统响应的 HTML 头部会自动注入 meta robots 标签,防止爬虫收录。 -

-
-
-
- -
-
- - {indexingEnabled ? "允许爬虫访问与收录" : "全面屏蔽外部搜索"} - - - {indexingEnabled ? "爬虫可自由搜集并抓取网站内容" : "已拦截所有网络爬虫的收录请求"} - -
- - updateConfigMutation.mutate({ key: "search_engine_indexing_enabled", value: checked }) - } - className="data-[state=checked]:bg-emerald-500 dark:data-[state=checked]:bg-emerald-600 focus-visible:ring-emerald-500" + setServerAddress(e.target.value)} + placeholder="例如: https://example.com" + className="border-dashed bg-card text-xs" /> +

+ 限定 API 的允许来源;留空将开放任意来源访问。 +

-
+
+
+
+ +
+
+
+ 搜索引擎抓取与收录 + + {indexingEnabled ? "允许收录" : "禁止收录"} + +
+

+ 控制 Google、Baidu、Bing 等搜索引擎是否可以索引公开页面。 +

+
+
+ + + updateConfigMutation.mutate({ key: "search_engine_indexing_enabled", value: checked }) + } + /> +
+ +
+
+ + 地址变更会影响跨域访问策略,请填写完整协议与域名。 +
+ +
+ @@ -488,4 +482,3 @@ export function SystemTab({ configs, systemConfigsQuery }: SystemTabProps) {
) } -