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 (