(config: ProxyConfig)
| 84 | * 保存代理配置 |
| 85 | */ |
| 86 | export async function saveProxyConfig(config: ProxyConfig): Promise<void> { |
| 87 | const configPath = getConfigPath() |
| 88 | const dir = path.dirname(configPath) |
| 89 | |
| 90 | if (!fs.existsSync(dir)) { |
| 91 | fs.mkdirSync(dir, { recursive: true }) |
| 92 | } |
| 93 | |
| 94 | fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8') |
| 95 | |
| 96 | // 保存后立即应用代理设置到 Electron session |
| 97 | await applyProxyToSession() |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * 验证代理 URL 格式 |
no test coverage detected