feat: v2.2.3 - 启动终端优先 Windows Terminal > pwsh > cmd

检测 wt.exe (Windows Terminal) 可用则优先使用 (现代UI/全屏/标签页),
其次 pwsh (PowerShell 7), 最后降级 cmd.exe。
解决 Win10 用户只能看到老旧蓝色终端的问题。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
bookworm 2026-04-13 17:39:24 +08:00
parent 9e0d22513f
commit 4dc5f8e0f8

View File

@ -16,7 +16,7 @@ param(
$ErrorActionPreference = "Stop"
# ─── 版本号 (每次更新递增, build.ps1 自动读取) ──────
$BWVersion = "2.2.2"
$BWVersion = "2.2.3"
# ─── B4: 单实例保护 (防止双击两次导致竞态) ─────────
$mutexCreated = $false
@ -1522,14 +1522,21 @@ if ($allOK -and $env:ANTHROPIC_API_KEY) {
$splash.Close()
$splash.Dispose()
# 启动 Bookworm — 通过桌面快捷方式的 bat (含自动 git pull)
# 启动 Bookworm — 优先 Windows Terminal > pwsh > cmd.exe
if (-not $SkipLaunch) {
$startBat = Join-Path $BootDir "启动Bookworm.bat"
if (Test-Path $startBat) {
Start-Process -FilePath $startBat -WorkingDirectory $BootDir
} else {
$launchCmd = "title Bookworm Smart Assistant v$BWVersion && cd /d `"$BootDir`" && claude --dangerously-skip-permissions"
Start-Process -FilePath "cmd.exe" -ArgumentList "/k", $launchCmd
$claudeCmd = "claude --dangerously-skip-permissions"
if (Get-Command wt.exe -ErrorAction SilentlyContinue) {
# Windows Terminal: 现代 UI, 支持全屏/标签页
Start-Process wt.exe -ArgumentList "new-tab", "-d", $BootDir, "--title", "Bookworm v$BWVersion", "cmd", "/k", $claudeCmd
} elseif ($PwshPath -and (Test-Path $PwshPath)) {
Start-Process $PwshPath -ArgumentList "-NoExit", "-Command", "cd '$BootDir'; $claudeCmd" -WorkingDirectory $BootDir
} else {
Start-Process cmd.exe -ArgumentList "/k", "title Bookworm v$BWVersion && cd /d `"$BootDir`" && $claudeCmd"
}
}
}
@ -1543,6 +1550,11 @@ if ($allOK -and $env:ANTHROPIC_API_KEY) {
$launchResult = Show-MsgBox "安装完成, 但存在以下问题:`n$issueText`n`n是否仍然启动 Claude Code?`n(将以受限模式运行)`n`n日志: $BWLogFile" "安装警告" "YesNo" "Warning"
if ($launchResult -eq "Yes" -and -not $SkipLaunch) {
Start-Process -FilePath "cmd.exe" -ArgumentList "/k", "claude --dangerously-skip-permissions"
$claudeCmd = "claude --dangerously-skip-permissions"
if (Get-Command wt.exe -ErrorAction SilentlyContinue) {
Start-Process wt.exe -ArgumentList "new-tab", "--title", "Bookworm", "cmd", "/k", $claudeCmd
} else {
Start-Process cmd.exe -ArgumentList "/k", $claudeCmd
}
}
}