feat(proxy): add local proxy auto-scan and fix hot-reload

- Add scan_local_proxies command to detect common proxy ports
- Fix SkillService not using updated proxy after hot-reload
- Move global proxy settings to advanced tab
- Add error handling for scan failures
This commit is contained in:
YoVinchen
2026-01-12 01:11:43 +08:00
parent b18be24384
commit cba8e8fdb3
13 changed files with 353 additions and 175 deletions
+24 -1
View File
@@ -23,6 +23,15 @@ export interface UpstreamProxyStatus {
proxyUrl: string | null;
}
/**
* 检测到的代理
*/
export interface DetectedProxy {
url: string;
proxyType: string;
port: number;
}
/**
* 获取全局代理 URL
*
@@ -39,7 +48,12 @@ export async function getGlobalProxyUrl(): Promise<string | null> {
* 空字符串表示清除代理(直连)
*/
export async function setGlobalProxyUrl(url: string): Promise<void> {
return invoke("set_global_proxy_url", { url });
try {
return await invoke("set_global_proxy_url", { url });
} catch (error) {
// Tauri invoke 错误可能是字符串
throw new Error(typeof error === "string" ? error : String(error));
}
}
/**
@@ -60,3 +74,12 @@ export async function testProxyUrl(url: string): Promise<ProxyTestResult> {
export async function getUpstreamProxyStatus(): Promise<UpstreamProxyStatus> {
return invoke<UpstreamProxyStatus>("get_upstream_proxy_status");
}
/**
* 扫描本地代理
*
* @returns 检测到的代理列表
*/
export async function scanLocalProxies(): Promise<DetectedProxy[]> {
return invoke<DetectedProxy[]>("scan_local_proxies");
}