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 决定)