From e27b8ee31fff939af6d0852745cb3efc48e051f6 Mon Sep 17 00:00:00 2001 From: YoVinchen Date: Wed, 24 Dec 2025 16:11:12 +0800 Subject: [PATCH] refactor(ui): remove timeout settings from AutoFailoverConfigPanel Remove streaming/non-streaming timeout configuration from failover panel as these settings have been moved to a dedicated location. --- .../proxy/AutoFailoverConfigPanel.tsx | 160 +----------------- 1 file changed, 3 insertions(+), 157 deletions(-) diff --git a/src/components/proxy/AutoFailoverConfigPanel.tsx b/src/components/proxy/AutoFailoverConfigPanel.tsx index 726d669e9..182dbce5c 100644 --- a/src/components/proxy/AutoFailoverConfigPanel.tsx +++ b/src/components/proxy/AutoFailoverConfigPanel.tsx @@ -10,7 +10,6 @@ import { useCircuitBreakerConfig, useUpdateCircuitBreakerConfig, } from "@/lib/query/failover"; -import { useProxyConfig } from "@/hooks/useProxyConfig"; export interface AutoFailoverConfigPanelProps { enabled?: boolean; @@ -27,12 +26,6 @@ export function AutoFailoverConfigPanel({ const { t } = useTranslation(); const { data: config, isLoading, error } = useCircuitBreakerConfig(); const updateConfig = useUpdateCircuitBreakerConfig(); - const { - config: proxyConfig, - isLoading: isProxyLoading, - updateConfig: updateProxyConfig, - isUpdating: isProxyUpdating, - } = useProxyConfig(); const [formData, setFormData] = useState({ failureThreshold: 5, @@ -41,11 +34,6 @@ export function AutoFailoverConfigPanel({ errorRateThreshold: 0.5, minRequests: 10, }); - const [timeoutConfig, setTimeoutConfig] = useState({ - streaming_first_byte_timeout: 30, - streaming_idle_timeout: 60, - non_streaming_timeout: 600, - }); useEffect(() => { if (config) { @@ -55,17 +43,6 @@ export function AutoFailoverConfigPanel({ } }, [config]); - useEffect(() => { - if (proxyConfig) { - setTimeoutConfig({ - streaming_first_byte_timeout: - proxyConfig.streaming_first_byte_timeout ?? 30, - streaming_idle_timeout: proxyConfig.streaming_idle_timeout ?? 60, - non_streaming_timeout: proxyConfig.non_streaming_timeout ?? 300, - }); - } - }, [proxyConfig]); - const handleSave = async () => { try { await updateConfig.mutateAsync({ @@ -75,15 +52,6 @@ export function AutoFailoverConfigPanel({ errorRateThreshold: formData.errorRateThreshold, minRequests: formData.minRequests, }); - if (proxyConfig) { - await updateProxyConfig({ - ...proxyConfig, - streaming_first_byte_timeout: - timeoutConfig.streaming_first_byte_timeout, - streaming_idle_timeout: timeoutConfig.streaming_idle_timeout, - non_streaming_timeout: timeoutConfig.non_streaming_timeout, - }); - } toast.success( t("proxy.autoFailover.configSaved", "自动故障转移配置已保存"), { closeButton: true }, @@ -101,14 +69,6 @@ export function AutoFailoverConfigPanel({ ...config, }); } - if (proxyConfig) { - setTimeoutConfig({ - streaming_first_byte_timeout: - proxyConfig.streaming_first_byte_timeout ?? 30, - streaming_idle_timeout: proxyConfig.streaming_idle_timeout ?? 60, - non_streaming_timeout: proxyConfig.non_streaming_timeout ?? 300, - }); - } }; if (isLoading) { @@ -295,134 +255,20 @@ export function AutoFailoverConfigPanel({ - {/* 代理请求超时配置 */} -
-

- {t("proxy.settings.timeout.title", { - defaultValue: "超时设置", - })} -

- -
-
- - { - const val = parseInt(e.target.value) || 0; - if (val === 0 || (val >= 1 && val <= 180)) { - setTimeoutConfig({ - ...timeoutConfig, - streaming_first_byte_timeout: val, - }); - } - }} - disabled={!enabled || isProxyLoading || isProxyUpdating} - /> -

- {t( - "proxy.settings.fields.streamingFirstByteTimeout.description", - "等待首个数据块的最大时间(0 禁用,范围 1-180 秒)", - )} -

-
- -
- - { - const val = parseInt(e.target.value) || 0; - if (val === 0 || (val >= 60 && val <= 600)) { - setTimeoutConfig({ - ...timeoutConfig, - streaming_idle_timeout: val, - }); - } - }} - disabled={!enabled || isProxyLoading || isProxyUpdating} - /> -

- {t( - "proxy.settings.fields.streamingIdleTimeout.description", - "数据块之间的最大间隔(0 禁用,范围 60-600 秒)", - )} -

-
- -
- - { - const val = parseInt(e.target.value) || 0; - if (val === 0 || (val >= 60 && val <= 1800)) { - setTimeoutConfig({ - ...timeoutConfig, - non_streaming_timeout: val, - }); - } - }} - disabled={!enabled || isProxyLoading || isProxyUpdating} - /> -

- {t( - "proxy.settings.fields.nonStreamingTimeout.description", - "非流式请求的总超时时间(0 禁用,范围 60-1800 秒)", - )} -

-
-
-
- {/* 操作按钮 */}