Skip to content

Commit 8ce51b0

Browse files
committed
refactor(profile): 用 Set-Proxy 替换手动代理设置逻辑
使用新的 Set-Proxy 命令自动处理代理配置,简化代码并提高可维护性
1 parent becc1fe commit 8ce51b0

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

‎profile/profile.ps1‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,8 @@ function Initialize-Environment {
233233
# 设置代理环境变量
234234
# 设置项目根目录环境变量
235235
$Global:Env:POWERSHELL_SCRIPTS_ROOT = Split-Path -Parent $PSScriptRoot
236-
if ($EnableProxy) {
237-
Write-Verbose "启用代理设置: $ProxyUrl"
238-
$Global:Env:http_proxy = $ProxyUrl
239-
$Global:Env:https_proxy = $ProxyUrl
240-
Write-Debug "已设置代理: $ProxyUrl"
241-
}
242-
else {
243-
Write-Verbose "跳过代理设置"
244-
$Global:Env:http_proxy = $null
245-
$Global:Env:https_proxy = $null
246-
}
247-
236+
# 自动检测代理
237+
Set-Proxy -Command auto
248238
# 加载自定义环境变量脚本 (用于存放机密或个人配置)
249239
if (Test-Path -Path (Join-Path -Path $ScriptRoot -ChildPath 'env.ps1')) {
250240
Write-Verbose "加载自定义环境变量脚本: $(Join-Path -Path $ScriptRoot -ChildPath 'env.ps1')"

0 commit comments

Comments
 (0)