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:
@@ -30,6 +30,13 @@ export interface CustomEndpoint {
|
||||
lastUsed?: number;
|
||||
}
|
||||
|
||||
// 端点候选项(用于端点测速弹窗)
|
||||
export interface EndpointCandidate {
|
||||
id?: string;
|
||||
url: string;
|
||||
isCustom?: boolean;
|
||||
}
|
||||
|
||||
// 用量查询脚本配置
|
||||
export interface UsageScript {
|
||||
enabled: boolean; // 是否启用用量查询
|
||||
|
||||
Reference in New Issue
Block a user