fix(launcher): Windows Terminal优先 + pwsh7优先 + 修复/dev/null→nul

- 终端优先级: wt.exe > conhost (解决渲染问题和全屏闪退)
- Shell优先级: pwsh7 > powershell 5.1 (更好的TUI支持)
- 修复Unix路径错误: /dev/null → nul (Windows批处理兼容)
- 4条启动路径: wt+pwsh7 / wt+ps5.1 / conhost+pwsh7 / fallback

解决问题:
1. 终端窗不好看 → Windows Terminal优先
2. 全屏闪退 → wt.exe原生支持缩放
3. pwsh7优先 → where pwsh检测 + 4级回退
This commit is contained in:
Bookworm Bot 2026-04-12 15:05:22 +09:00
parent 675606b5c4
commit 9e0d22513f

View File

@ -11,14 +11,38 @@ echo [..] 检查更新...
git pull --rebase >nul 2>nul
git -C "%USERPROFILE%\.claude" pull --rebase >nul 2>nul
:: 优先 pwsh7: 新窗口启动 claude, 先从注册表缓存加载凭证 (DPAPI 解密)
where pwsh >nul 2>nul
if %errorlevel% equ 0 (
start "Bookworm Smart Assistant" pwsh -NoLogo -NoExit -Command "Add-Type -AssemblyName System.Security;$r='HKCU:\Software\Bookworm\CachedEnv';try{(Get-ItemProperty $r -EA Stop).PSObject.Properties|Where-Object{$_.Name-match'^[A-Z_]+$'}|ForEach-Object{$v=$_.Value;try{$b=[Security.Cryptography.ProtectedData]::Unprotect([Convert]::FromBase64String($v),$null,[Security.Cryptography.DataProtectionScope]::CurrentUser);$v=[Text.Encoding]::UTF8.GetString($b)}catch{};[Environment]::SetEnvironmentVariable($_.Name,$v,'Process')}}catch{};& claude --dangerously-skip-permissions"
:: === 终端选择: Windows Terminal > conhost ===
:: wt.exe 支持完整 Unicode 渲染 + 自由缩放不闪退
set USE_WT=0
where wt >nul 2>nul && set USE_WT=1
:: === Shell 选择: pwsh7 > powershell 5.1 ===
:: pwsh7 启动更快, 支持更多语法, Claude Code TUI 渲染更好
set USE_PWSH7=0
where pwsh >nul 2>nul && set USE_PWSH7=1
:: 构建凭证加载命令 (DPAPI 解密)
set CRED_CMD=Add-Type -AssemblyName System.Security;$r='HKCU:\Software\Bookworm\CachedEnv';try{(Get-ItemProperty $r -EA Stop).PSObject.Properties^|Where-Object{$_.Name-match'^[A-Z_]+$'}^|ForEach-Object{$v=$_.Value;try{$b=[Security.Cryptography.ProtectedData]::Unprotect([Convert]::FromBase64String($v),$null,[Security.Cryptography.DataProtectionScope]::CurrentUser);$v=[Text.Encoding]::UTF8.GetString($b)}catch{};[Environment]::SetEnvironmentVariable($_.Name,$v,'Process')}}catch{};
:: 优先路径: wt + pwsh7
if %USE_WT% equ 1 if %USE_PWSH7% equ 1 (
start "" wt new-tab --title "Bookworm Smart Assistant" -d "%~dp0" -- pwsh -NoLogo -NoExit -Command "%CRED_CMD% & claude --dangerously-skip-permissions"
exit
)
:: 回退 PowerShell 5.1
:: 路径 2: wt + powershell 5.1
if %USE_WT% equ 1 if %USE_PWSH7% equ 0 (
start "" wt new-tab --title "Bookworm Smart Assistant" -d "%~dp0" -- powershell -NoLogo -ExecutionPolicy Bypass -NoExit -Command "%CRED_CMD% & claude --dangerously-skip-permissions"
exit
)
:: 路径 3: conhost + pwsh7
if %USE_PWSH7% equ 1 (
start "Bookworm Smart Assistant" pwsh -NoLogo -NoExit -Command "%CRED_CMD% & claude --dangerously-skip-permissions"
exit
)
:: 路径 4: 回退 PowerShell 5.1 (最低保障)
title Bookworm Portable
echo.
echo [!] PowerShell 7 未安装, 使用 PowerShell 5.1