From 33b9bf5dc3510f45a234298b011d73aa966396c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=85=8E=E9=A5=BC=E6=9E=9C=E5=AD=90=E5=8D=B7=E9=B2=A8?= =?UTF-8?q?=E9=B1=BC=E8=BE=A3=E6=A4=92?= Date: Wed, 14 Jan 2026 10:44:59 +0800 Subject: [PATCH] =?UTF-8?q?```=20fix(cursor=5Fwin=5Fid=5Fmodifier):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DPowerShell=E9=A2=9C=E8=89=B2=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E5=85=BC=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为解决PowerShell 5.1和7.x版本间的颜色编码差异, 采用[char]27方式定义转义字符以确保跨版本兼容性。 同时修正了字符串插值语法中的变量引用格式。 ``` --- scripts/run/cursor_win_id_modifier.ps1 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/run/cursor_win_id_modifier.ps1 b/scripts/run/cursor_win_id_modifier.ps1 index 15a874d..6bc1142 100644 --- a/scripts/run/cursor_win_id_modifier.ps1 +++ b/scripts/run/cursor_win_id_modifier.ps1 @@ -2,12 +2,13 @@ $OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 -# 颜色定义 -$RED = "`e[31m" -$GREEN = "`e[32m" -$YELLOW = "`e[33m" -$BLUE = "`e[34m" -$NC = "`e[0m" +# 颜色定义(兼容 PowerShell 5.1 和 7.x) +$ESC = [char]27 +$RED = "$ESC[31m" +$GREEN = "$ESC[32m" +$YELLOW = "$ESC[33m" +$BLUE = "$ESC[34m" +$NC = "$ESC[0m" # 路径解析:优先使用 .NET 获取系统目录,避免环境变量缺失导致路径异常 function Get-FolderPathSafe { @@ -36,7 +37,7 @@ function Get-FolderPathSafe { if ([string]::IsNullOrWhiteSpace($path)) { Write-Host "$YELLOW⚠️ [路径]$NC $Label 无法解析,将尝试其他方式" } else { - Write-Host "$BLUEℹ️ [路径]$NC $Label: $path" + Write-Host "$BLUEℹ️ [路径]$NC ${Label}: $path" } return $path }