Files
ttstd-infinite-canvas/scripts/windows-proxy.ps1
Codex 9b9a7f4a72 feat(merge): 以官方 main 为基底融合 PR#530 多维表格与本地定制
- 多维表格(canvas-batch-table-node/use-canvas-batch-table/canvas-batch-table 等)以 PR#530 实现为主
- 保留官方 main 全部新功能:banner/画布版本历史/提示词编辑/方舟 Agent Plan/支付导出
- 移植本地定制:ddcat 多参考图校验、万有引力 lxmone 连接错误提示、Description v20(v24)、自建插件(a6api/metaso-h3/antigravity-proxy/lxmone)、seccomp、Windows 脚本
- 迁移版本升至 v24(官方 v20-23 banner/版本历史 + 我们的 Description 列)
- 修复官方缺失的 markdownPlainText import
2026-09-18 14:09:50 +08:00

36 lines
1.8 KiB
PowerShell

# Go uses proxy environment variables, not Windows Internet Settings.
# Inherit the user's enabled static proxy only when no explicit proxy was set.
function Import-CanvasWindowsProxy {
if ($env:HTTPS_PROXY -or $env:HTTP_PROXY -or $env:ALL_PROXY) { return }
$settings = Get-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -ErrorAction SilentlyContinue
if (-not $settings -or $settings.ProxyEnable -ne 1 -or -not $settings.ProxyServer) { return }
$proxies = @{}
foreach ($entry in ($settings.ProxyServer -split ';')) {
if ($entry -match '^\s*(https?)=(.+)$') {
$proxies[$Matches[1]] = $Matches[2].Trim()
} elseif ($entry -notmatch '=') {
$proxies['http'] = $entry.Trim()
$proxies['https'] = $entry.Trim()
}
}
foreach ($scheme in @('http', 'https')) {
$address = $proxies[$scheme]
if (-not $address) { continue }
if ($address -notmatch '^[a-z]+://') { $address = "http://$address" }
$parsed = $null
if (-not [Uri]::TryCreate($address, [UriKind]::Absolute, [ref]$parsed) -or $parsed.Scheme -notin @('http', 'https')) {
throw 'Windows proxy address is invalid. Check system proxy settings.'
}
[Environment]::SetEnvironmentVariable("$($scheme.ToUpper())_PROXY", $address, 'Process')
}
if ($env:HTTP_PROXY -or $env:HTTPS_PROXY) {
$bypass = @($env:NO_PROXY, 'localhost', '127.0.0.1', '::1')
foreach ($entry in ($settings.ProxyOverride -split ';')) {
$entry = $entry.Trim()
if ($entry -and $entry -ne '<local>') { $bypass += $entry }
}
$env:NO_PROXY = ($bypass | Where-Object { $_ } | Select-Object -Unique) -join ','
Write-Host 'Backend network: using the enabled Windows proxy.' -ForegroundColor Cyan
}
}