From a6d461282d0ba7ac2f68346a5e122eb605133743 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 8 Oct 2025 17:32:20 +0800 Subject: [PATCH] fix: custom endpoints not saved when creating new provider When creating a new provider, custom endpoints added in the speed test modal were not being saved properly. The issue was in ProviderForm.tsx where the CustomEndpoint object was constructed without the optional lastUsed field. This caused inconsistency between: - Edit mode: uses backend API (addCustomEndpoint) which correctly constructs complete CustomEndpoint objects - Create mode: directly constructs objects in frontend, missing the lastUsed field Fixed by explicitly setting lastUsed to undefined when constructing custom endpoints in create mode, ensuring structural consistency with the TypeScript CustomEndpoint interface. --- src/components/ProviderForm.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ProviderForm.tsx b/src/components/ProviderForm.tsx index a0c4cae..bbe0d13 100644 --- a/src/components/ProviderForm.tsx +++ b/src/components/ProviderForm.tsx @@ -615,7 +615,7 @@ const ProviderForm: React.FC = ({ ...(category ? { category } : {}), }; - // 若为“新建供应商”,且已在弹窗中添加了自定义端点,则随提交一并落盘 + // 若为"新建供应商",且已在弹窗中添加了自定义端点,则随提交一并落盘 if (!initialData && draftCustomEndpoints.length > 0) { const now = Date.now(); const customMap: Record = {}; @@ -623,7 +623,7 @@ const ProviderForm: React.FC = ({ const url = raw.trim().replace(/\/+$/, ""); if (!url) continue; if (!customMap[url]) { - customMap[url] = { url, addedAt: now }; + customMap[url] = { url, addedAt: now, lastUsed: undefined }; } } onSubmit({ ...basePayload, meta: { custom_endpoints: customMap } });