mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-29 01:05:59 +08:00
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:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user