()
| 290 | } |
| 291 | |
| 292 | export async function resolveModelDownloadProxyUrl(): Promise<string | undefined> { |
| 293 | const config = loadProxyConfig() |
| 294 | |
| 295 | if (config.mode === 'manual' && config.url) { |
| 296 | const validation = validateProxyUrl(config.url) |
| 297 | if (validation.valid) return config.url |
| 298 | } |
| 299 | |
| 300 | if (config.mode !== 'system') return undefined |
| 301 | |
| 302 | try { |
| 303 | await waitForPendingProxyApply() |
| 304 | const resolvedProxy = await session.defaultSession.resolveProxy('https://huggingface.co/') |
| 305 | return proxyUrlFromElectronResolvedProxy(resolvedProxy) |
| 306 | } catch (error) { |
| 307 | console.warn('[Proxy] Failed to resolve system proxy for model downloads:', error) |
| 308 | return undefined |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * 初始化代理模块 |
nothing calls this directly
no test coverage detected