Skip to content

Commit 33b9bf5

Browse files
committed
```
fix(cursor_win_id_modifier): 修复PowerShell颜色编码兼容性问题 为解决PowerShell 5.1和7.x版本间的颜色编码差异, 采用[char]27方式定义转义字符以确保跨版本兼容性。 同时修正了字符串插值语法中的变量引用格式。 ```
1 parent 761120f commit 33b9bf5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

scripts/run/cursor_win_id_modifier.ps1

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
$OutputEncoding = [System.Text.Encoding]::UTF8
33
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
44

5-
# 颜色定义
6-
$RED = "`e[31m"
7-
$GREEN = "`e[32m"
8-
$YELLOW = "`e[33m"
9-
$BLUE = "`e[34m"
10-
$NC = "`e[0m"
5+
# 颜色定义(兼容 PowerShell 5.1 和 7.x)
6+
$ESC = [char]27
7+
$RED = "$ESC[31m"
8+
$GREEN = "$ESC[32m"
9+
$YELLOW = "$ESC[33m"
10+
$BLUE = "$ESC[34m"
11+
$NC = "$ESC[0m"
1112

1213
# 路径解析:优先使用 .NET 获取系统目录,避免环境变量缺失导致路径异常
1314
function Get-FolderPathSafe {
@@ -36,7 +37,7 @@ function Get-FolderPathSafe {
3637
if ([string]::IsNullOrWhiteSpace($path)) {
3738
Write-Host "$YELLOW⚠️ [路径]$NC $Label 无法解析,将尝试其他方式"
3839
} else {
39-
Write-Host "$BLUEℹ️ [路径]$NC $Label: $path"
40+
Write-Host "$BLUEℹ️ [路径]$NC ${Label}: $path"
4041
}
4142
return $path
4243
}

0 commit comments

Comments
 (0)