diff --git a/src/components/ProviderForm.tsx b/src/components/ProviderForm.tsx index b5a495c..6513216 100644 --- a/src/components/ProviderForm.tsx +++ b/src/components/ProviderForm.tsx @@ -1123,21 +1123,21 @@ const ProviderForm: React.FC = ({ const claudeSpeedTestEndpoints = useMemo(() => { if (isCodex) return []; const map = new Map(); - const add = (url?: string, label?: string) => { + const add = (url?: string) => { if (!url) return; const sanitized = url.trim().replace(/\/+$/, ""); if (!sanitized || map.has(sanitized)) return; - map.set(sanitized, { url: sanitized, label }); + map.set(sanitized, { url: sanitized }); }; if (baseUrl) { - add(baseUrl, "当前地址"); + add(baseUrl); } if (initialData && typeof initialData.settingsConfig === "object") { const envUrl = (initialData.settingsConfig as any)?.env?.ANTHROPIC_BASE_URL; if (typeof envUrl === "string") { - add(envUrl, envUrl === baseUrl ? "当前地址" : "历史地址"); + add(envUrl); } } @@ -1149,7 +1149,7 @@ const ProviderForm: React.FC = ({ const preset = providerPresets[selectedPreset]; const presetEnv = (preset.settingsConfig as any)?.env?.ANTHROPIC_BASE_URL; if (typeof presetEnv === "string") { - add(presetEnv, presetEnv === baseUrl ? "当前地址" : "预设地址"); + add(presetEnv); } } @@ -1159,15 +1159,15 @@ const ProviderForm: React.FC = ({ const codexSpeedTestEndpoints = useMemo(() => { if (!isCodex) return []; const map = new Map(); - const add = (url?: string, label?: string) => { + const add = (url?: string) => { if (!url) return; const sanitized = url.trim().replace(/\/+$/, ""); if (!sanitized || map.has(sanitized)) return; - map.set(sanitized, { url: sanitized, label }); + map.set(sanitized, { url: sanitized }); }; if (codexBaseUrl) { - add(codexBaseUrl, "当前地址"); + add(codexBaseUrl); } const initialCodexConfig = @@ -1176,7 +1176,7 @@ const ProviderForm: React.FC = ({ : ""; const existing = extractCodexBaseUrl(initialCodexConfig); if (existing) { - add(existing, existing === codexBaseUrl ? "当前地址" : "历史地址"); + add(existing); } if ( @@ -1187,7 +1187,7 @@ const ProviderForm: React.FC = ({ const presetConfig = codexProviderPresets[selectedCodexPreset]?.config; const presetBase = extractCodexBaseUrl(presetConfig); if (presetBase) { - add(presetBase, presetBase === codexBaseUrl ? "当前地址" : "预设地址"); + add(presetBase); } } diff --git a/src/components/ProviderForm/EndpointSpeedTest.tsx b/src/components/ProviderForm/EndpointSpeedTest.tsx index 67ab5ac..f4ef7ed 100644 --- a/src/components/ProviderForm/EndpointSpeedTest.tsx +++ b/src/components/ProviderForm/EndpointSpeedTest.tsx @@ -7,7 +7,6 @@ import type { AppType } from "../../lib/tauri-api"; export interface EndpointCandidate { id?: string; url: string; - label?: string; isCustom?: boolean; } @@ -40,25 +39,11 @@ const buildInitialEntries = ( const addCandidate = (candidate: EndpointCandidate) => { const sanitized = candidate.url ? normalizeEndpointUrl(candidate.url) : ""; if (!sanitized) return; - if (map.has(sanitized)) { - const existing = map.get(sanitized)!; - if (candidate.label && candidate.label !== existing.label) { - map.set(sanitized, { ...existing, label: candidate.label }); - } - return; - } - const index = map.size; - const label = - candidate.label ?? - (candidate.isCustom - ? `自定义 ${index + 1}` - : index === 0 - ? "默认地址" - : `候选 ${index + 1}`); + if (map.has(sanitized)) return; + map.set(sanitized, { id: candidate.id ?? randomId(), url: sanitized, - label, isCustom: candidate.isCustom ?? false, latency: null, status: undefined, @@ -70,7 +55,7 @@ const buildInitialEntries = ( const selectedUrl = normalizeEndpointUrl(selected); if (selectedUrl && !map.has(selectedUrl)) { - addCandidate({ url: selectedUrl, label: "当前地址", isCustom: true }); + addCandidate({ url: selectedUrl, isCustom: true }); } return Array.from(map.values()); @@ -112,25 +97,11 @@ const EndpointSpeedTest: React.FC = ({ : ""; if (!sanitized) return; const existing = map.get(sanitized); - if (existing) { - if (candidate.label && candidate.label !== existing.label) { - map.set(sanitized, { ...existing, label: candidate.label }); - changed = true; - } - return; - } - const index = map.size; - const label = - candidate.label ?? - (candidate.isCustom - ? `自定义 ${index + 1}` - : index === 0 - ? "默认地址" - : `候选 ${index + 1}`); + if (existing) return; + map.set(sanitized, { id: candidate.id ?? randomId(), url: sanitized, - label, isCustom: candidate.isCustom ?? false, latency: null, status: undefined, @@ -141,19 +112,8 @@ const EndpointSpeedTest: React.FC = ({ initialEndpoints.forEach(mergeCandidate); - if (normalizedSelected) { - const existing = map.get(normalizedSelected); - if (existing) { - if (existing.label !== "当前地址") { - map.set(normalizedSelected, { - ...existing, - label: existing.isCustom ? existing.label : "当前地址", - }); - changed = true; - } - } else { - mergeCandidate({ url: normalizedSelected, label: "当前地址", isCustom: true }); - } + if (normalizedSelected && !map.has(normalizedSelected)) { + mergeCandidate({ url: normalizedSelected, isCustom: true }); } if (!changed) { @@ -204,13 +164,11 @@ const EndpointSpeedTest: React.FC = ({ setAddError("该地址已存在"); return prev; } - const customCount = prev.filter((entry) => entry.isCustom).length; return [ ...prev, { id: randomId(), url: sanitized, - label: `自定义 ${customCount + 1}`, isCustom: true, latency: null, status: undefined, @@ -341,9 +299,9 @@ const EndpointSpeedTest: React.FC = ({ /> {/* Modal */} -
+
{/* Header */} -
+

请求地址管理

@@ -378,7 +336,7 @@ const EndpointSpeedTest: React.FC = ({ type="button" onClick={runSpeedTest} disabled={isTesting || !hasEndpoints} - className="flex h-7 items-center gap-1.5 rounded-md bg-gray-900 px-2.5 text-xs font-medium text-white transition hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-40 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200" + className="flex h-7 items-center gap-1.5 rounded-md bg-blue-500 px-2.5 text-xs font-medium text-white transition hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-40 dark:bg-blue-600 dark:hover:bg-blue-700" > {isTesting ? ( <> @@ -456,12 +414,7 @@ const EndpointSpeedTest: React.FC = ({ {/* 内容 */}
-
- - {entry.label} - -
-
+
{entry.url}
@@ -516,11 +469,11 @@ const EndpointSpeedTest: React.FC = ({
{/* Footer */} -
+