Skip to content

Commit 08c6fce

Browse files
committed
feat(profile): 添加用户级环境变量显示并验证代理URL格式
在Show-MyProfileHelp函数中添加显示用户级持久环境变量的功能 为Initialize-Environment的ProxyUrl参数添加格式验证
1 parent 8df870f commit 08c6fce

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎profile/profile.ps1‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ function Show-MyProfileHelp {
135135
}
136136
}
137137

138+
Write-Host "`n[用户级持久环境变量]" -ForegroundColor Yellow
139+
$persistVars = @('POWERSHELL_SCRIPTS_ROOT', 'http_proxy', 'https_proxy')
140+
foreach ($var in $persistVars) {
141+
$uval = [Environment]::GetEnvironmentVariable($var, "User")
142+
if ($uval) { Write-Host ("{0,-25} : {1}" -f "$var(用户级)", $uval) }
143+
}
144+
138145
Write-Host "`n要重新加载环境, 请运行: Initialize-Environment" -ForegroundColor Green
139146
}
140147

@@ -206,7 +213,7 @@ function Initialize-Environment {
206213
param (
207214
[string]$ScriptRoot = $PSScriptRoot,
208215
[bool]$EnableProxy = (Test-Path -Path "$PSScriptRoot\enableProxy"),
209-
[string]$ProxyUrl = "http://127.0.0.1:7890"
216+
[ValidatePattern('^https?://')][string]$ProxyUrl = "http://127.0.0.1:7890"
210217
)
211218

212219
Write-Verbose "开始初始化PowerShell环境配置"

0 commit comments

Comments
 (0)