feat: 桌面快捷方式命名统一「启动Bookworm」+「更新Bookworm」

- install.ps1 / auto-setup.ps1 的「Bookworm.lnk」改名为「启动Bookworm.lnk」
- 顺序反转: 先建新 lnk -> 验证存在 -> 再删老 lnk (防空窗)
- install.ps1 的 -StartOnly 分支也调用 New-DesktopShortcuts,
  让只从老 Bookworm.lnk 启动的老用户也能自动完成命名迁移
- 所有分支幂等, Test-Path 守门, 多次运行不报错

用户端生效路径:
- 新用户装 Bookworm-Setup.exe (195584 B, 已含新 auto-setup) -> 直接建新 lnk
- 老用户下次启动 -> bat 的 git pull 拉此 commit 的 install.ps1 -> 自动迁移

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
bookworm 2026-04-22 01:02:43 +08:00
parent 656460e13e
commit d7a0931407
2 changed files with 28 additions and 5 deletions

View File

@ -723,8 +723,9 @@ function New-DesktopShortcuts {
$iconPath = Join-Path $BootDir "bookworm.ico"
}
# 快速启动 (bat 文件位于 bookworm-boot 仓库内)
$shortcut = $shell.CreateShortcut("$desktop\Bookworm.lnk")
# 步骤 1: 快速启动 (bat 文件位于 bookworm-boot 仓库内)
$newLnk = "$desktop\启动Bookworm.lnk"
$shortcut = $shell.CreateShortcut($newLnk)
$batPath = Join-Path $BootDir "启动Bookworm.bat"
if (-not (Test-Path $batPath)) { $batPath = Join-Path $BootDir "Bookworm-OneClick.bat" }
$shortcut.TargetPath = $batPath
@ -733,6 +734,13 @@ function New-DesktopShortcuts {
if (Test-Path $iconPath) { $shortcut.IconLocation = "$iconPath,0" }
$shortcut.Save()
# 步骤 2: 迁移清理老 Bookworm.lnk (v3.0.3 及以前命名), 必须在新 lnk 确认存在后, 防空窗
$oldLnk = "$desktop\Bookworm.lnk"
if ((Test-Path $oldLnk) -and (Test-Path $newLnk)) {
try { Remove-Item -LiteralPath $oldLnk -Force -ErrorAction Stop; Log-OK "已清理旧快捷方式 Bookworm.lnk (迁移到「启动Bookworm」)" }
catch { Log-Warn "无法清理旧 Bookworm.lnk: $_" }
}
# 更新启动
$shortcut2 = $shell.CreateShortcut("$desktop\更新Bookworm.lnk")
$updateBat = Join-Path $BootDir "更新并启动Bookworm.bat"

View File

@ -175,8 +175,8 @@ function New-DesktopShortcuts {
$desktop = [System.Environment]::GetFolderPath("Desktop")
$bootDir = $ScriptDir
# 启动Bookworm 快捷方式 — 优先 pwsh (PS7),回退 powershell (PS5)
$lnkPath = Join-Path $desktop "Bookworm.lnk"
# 步骤 1: 确保新「启动Bookworm.lnk」存在 (缺失时创建)
$lnkPath = Join-Path $desktop "启动Bookworm.lnk"
if (-not (Test-Path $lnkPath)) {
try {
$shell = New-Object -ComObject WScript.Shell
@ -190,11 +190,22 @@ function New-DesktopShortcuts {
$shortcut.Description = "Bookworm Smart Assistant"
$shortcut.Save()
$psVer = if ($hasPwsh) { "PowerShell 7" } else { "PowerShell 5.1" }
Write-Host " [OK] 桌面快捷方式已创建: Bookworm ($psVer)" -ForegroundColor Green
Write-Host " [OK] 桌面快捷方式已创建: 启动Bookworm ($psVer)" -ForegroundColor Green
} catch {
Write-Host " [!] 桌面快捷方式创建失败 (不影响使用)" -ForegroundColor Gray
}
}
# 步骤 2: 迁移清理老 Bookworm.lnk (v3.0.3 及以前命名), 必须在新 lnk 确认存在后, 防空窗
$oldLnk = Join-Path $desktop "Bookworm.lnk"
if ((Test-Path $oldLnk) -and (Test-Path $lnkPath)) {
try {
Remove-Item -LiteralPath $oldLnk -Force -ErrorAction Stop
Write-Host " [MIGRATE] 已清理旧快捷方式 Bookworm.lnk (已替换为启动Bookworm)" -ForegroundColor DarkGray
} catch {
Write-Host " [!] 无法清理旧 Bookworm.lnk (不影响使用)" -ForegroundColor Gray
}
}
}
function Parse-AuthCode {
@ -771,6 +782,10 @@ if (-not $StartOnly) {
Start-Process $guidePath
Write-Host " [OK] 使用教程已在浏览器打开" -ForegroundColor Gray
}
} else {
# StartOnly 路径 (老 Bookworm.lnk 指向此): 跑幂等迁移, 单次 ~10ms
# 让只从不点「更新Bookworm」的老用户也自动完成快捷方式命名统一
New-DesktopShortcuts
}
# 启动 Claude Code (同步执行, 窗口类型由调用方 .bat 决定)