From c4177c21aa2154ecc59b18d75efd86fce3ffd995 Mon Sep 17 00:00:00 2001 From: bookworm Date: Fri, 10 Apr 2026 11:20:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(installer):=20=E6=8E=88=E6=9D=83=E7=A0=81?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E6=94=B9=E4=B8=BA=E5=BC=BA=E5=88=B6=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=20+=20=E5=89=8D=E7=BD=AE=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: 旧版用户重装时, 缓存过期/格式不兼容 → 弹授权码 → 用户以为已装过点"取消" → 凭证空 → Claude 不能用 修复: 1. 弹授权码前先 MsgBox 解释"需要授权码才能使用" 2. 点"取消安装"时二次确认"没有授权码将无法使用,确定跳过?" 3. 三级自动检测 (User env → DPAPI cache → 旧明文 cache) 能自动恢复的不弹窗, 都恢复不了才要求输入 Co-Authored-By: Claude Opus 4.6 (1M context) --- auto-setup.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/auto-setup.ps1 b/auto-setup.ps1 index 18155a6..ec1059e 100644 --- a/auto-setup.ps1 +++ b/auto-setup.ps1 @@ -976,20 +976,25 @@ if (-not $secretsDecrypted -and (Get-CachedSecrets)) { Log-OK "从 Registry 缓存加载凭证" $secretsDecrypted = $true } -# 再解密 (缓存命中则跳过) +# 优先级 3: 解密 (缓存均未命中时) if (-not $secretsDecrypted) { -# B6: Node.js 是硬性要求 (OpenSSL fallback 与 BWENC1 格式不兼容, 已移除) $cryptoHelper = Join-Path $BootDir "crypto-helper.js" if (-not (Test-Cmd "node") -or -not (Test-Path $cryptoHelper)) { Log-Fail "解密需要 Node.js (Phase 1 应已安装)" Show-MsgBox "解密凭证需要 Node.js,但未检测到。`n请确认 Phase 1 安装成功后重试。" "缺少 Node.js" "OK" "Error" } elseif ((Test-Path $SecretsEnc) -or (Get-ChildItem $BootDir -Filter "secrets-*.enc" -ErrorAction SilentlyContinue)) { + # 强制要求授权码 — 不允许跳过 (跳过 = 无法使用) + Show-MsgBox "检测到加密凭证文件,需要输入授权码才能使用 Bookworm。`n`n授权码由管理员提供,格式: BW-YYYYMMDD-XXXX...`n如果没有授权码,请联系管理员获取。" "需要授权码" "OK" "Information" + $validAttempts = 0 while ($validAttempts -lt 3) { $rawCode = Show-AuthCodeDialog ($validAttempts + 1) 3 if (-not $rawCode) { - Log-Warn "用户取消授权码输入" + # 不再静默跳过,明确警告 + $skip = Show-MsgBox "未输入授权码。`n`n没有授权码将无法使用 Bookworm(无 API 凭证)。`n`n确定要跳过吗?" "警告" "YesNo" "Warning" + if ($skip -eq "No") { continue } + Log-Warn "用户确认跳过授权码" break }