Files
CC-Switch/src/vite-env.d.ts
T
Jason 4fc76200e8 feat: add unified endpoint speed test for API providers
Add a comprehensive endpoint latency testing system that allows users to:
- Test multiple API endpoints concurrently
- Auto-select the fastest endpoint based on latency
- Add/remove custom endpoints dynamically
- View latency results with color-coded indicators

Backend (Rust):
- Implement parallel HTTP HEAD requests with configurable timeout
- Handle various error scenarios (timeout, connection failure, invalid URL)
- Return structured latency data with status codes

Frontend (React):
- Create interactive speed test UI component with auto-sort by latency
- Support endpoint management (add/remove custom endpoints)
- Extract and update Codex base_url from TOML configuration
- Integrate with provider presets for default endpoint candidates

This feature improves user experience when selecting optimal API endpoints,
especially useful for users with multiple provider options or proxy setups.
2025-10-04 18:04:40 +08:00

70 lines
2.4 KiB
TypeScript

/// <reference types="vite/client" />
import { Provider, Settings } from "./types";
import { AppType } from "./lib/tauri-api";
import type { UnlistenFn } from "@tauri-apps/api/event";
interface ImportResult {
success: boolean;
message?: string;
}
interface ConfigStatus {
exists: boolean;
path: string;
error?: string;
}
declare global {
interface Window {
api: {
getProviders: (app?: AppType) => Promise<Record<string, Provider>>;
getCurrentProvider: (app?: AppType) => Promise<string>;
addProvider: (provider: Provider, app?: AppType) => Promise<boolean>;
deleteProvider: (id: string, app?: AppType) => Promise<boolean>;
updateProvider: (provider: Provider, app?: AppType) => Promise<boolean>;
switchProvider: (providerId: string, app?: AppType) => Promise<boolean>;
importCurrentConfigAsDefault: (app?: AppType) => Promise<ImportResult>;
getClaudeCodeConfigPath: () => Promise<string>;
getClaudeConfigStatus: () => Promise<ConfigStatus>;
getConfigStatus: (app?: AppType) => Promise<ConfigStatus>;
getConfigDir: (app?: AppType) => Promise<string>;
selectConfigDirectory: (defaultPath?: string) => Promise<string | null>;
openConfigFolder: (app?: AppType) => Promise<void>;
openExternal: (url: string) => Promise<void>;
updateTrayMenu: () => Promise<boolean>;
onProviderSwitched: (
callback: (data: { appType: string; providerId: string }) => void,
) => Promise<UnlistenFn>;
getSettings: () => Promise<Settings>;
saveSettings: (settings: Settings) => Promise<boolean>;
checkForUpdates: () => Promise<void>;
isPortable: () => Promise<boolean>;
getAppConfigPath: () => Promise<string>;
openAppConfigFolder: () => Promise<void>;
// Claude 插件配置能力
getClaudePluginStatus: () => Promise<ConfigStatus>;
readClaudePluginConfig: () => Promise<string | null>;
applyClaudePluginConfig: (options: {
official: boolean;
}) => Promise<boolean>;
isClaudePluginApplied: () => Promise<boolean>;
testApiEndpoints: (
urls: string[],
options?: { timeoutSecs?: number },
) => Promise<Array<{
url: string;
latency: number | null;
status?: number;
error?: string;
}>>;
};
platform: {
isMac: boolean;
};
__TAURI__?: any;
}
}
export {};