refactor: improve endpoint management type safety and error handling

- Unify EndpointCandidate type definition in types.ts
- Remove all 'as any' type assertions in useSpeedTestEndpoints
- Add cleanup function to prevent race conditions in async operations
- Fix stale error messages persisting after successful deletion
- Improve error handling for endpoint deletion (distinguish not-found vs network errors)
- Extract timeout magic numbers to ENDPOINT_TIMEOUT_SECS constant
- Clarify URL validation to explicitly allow only http/https
- Fix ambiguous payload.meta assignment logic in ProviderForm
- Add i18n for new error messages (removeFailed, updateLastUsedFailed)
This commit is contained in:
Jason
2025-10-24 09:24:03 +08:00
parent 6cc75d5c24
commit 495e66e3b6
8 changed files with 125 additions and 61 deletions

View File

@@ -265,6 +265,8 @@
"loadEndpointsFailed": "加载自定义端点失败:",
"addEndpointFailed": "添加自定义端点失败:",
"removeEndpointFailed": "删除自定义端点失败:",
"removeFailed": "删除失败: {{error}}",
"updateLastUsedFailed": "更新端点使用时间失败",
"pleaseAddEndpoint": "请先添加端点",
"testUnavailable": "测速功能不可用",
"noResult": "未返回结果",