From 235839a880e8a463409251ef6b569f1a21c49acd Mon Sep 17 00:00:00 2001 From: bookworm Date: Wed, 22 Apr 2026 01:02:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A1=8C=E9=9D=A2=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=91=BD=E5=90=8D=E7=BB=9F=E4=B8=80=E3=80=8C?= =?UTF-8?q?=E5=90=AF=E5=8A=A8Bookworm=E3=80=8D+=E3=80=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?Bookworm=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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) --- auto-setup.ps1 | 12 ++++++++++-- install.ps1 | 21 ++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/auto-setup.ps1 b/auto-setup.ps1 index 0c42ee4..4abe302 100644 --- a/auto-setup.ps1 +++ b/auto-setup.ps1 @@ -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" diff --git a/install.ps1 b/install.ps1 index 2d2cd6c..8e6c027 100644 --- a/install.ps1 +++ b/install.ps1 @@ -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 决定)