fix(installer): 授权码跳过改为强制确认 + 前置提示
问题: 旧版用户重装时, 缓存过期/格式不兼容 → 弹授权码 → 用户以为已装过点"取消" → 凭证空 → Claude 不能用 修复: 1. 弹授权码前先 MsgBox 解释"需要授权码才能使用" 2. 点"取消安装"时二次确认"没有授权码将无法使用,确定跳过?" 3. 三级自动检测 (User env → DPAPI cache → 旧明文 cache) 能自动恢复的不弹窗, 都恢复不了才要求输入 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7114f4e7a8
commit
c4177c21aa
@ -976,20 +976,25 @@ if (-not $secretsDecrypted -and (Get-CachedSecrets)) {
|
|||||||
Log-OK "从 Registry 缓存加载凭证"
|
Log-OK "从 Registry 缓存加载凭证"
|
||||||
$secretsDecrypted = $true
|
$secretsDecrypted = $true
|
||||||
}
|
}
|
||||||
# 再解密 (缓存命中则跳过)
|
# 优先级 3: 解密 (缓存均未命中时)
|
||||||
if (-not $secretsDecrypted) {
|
if (-not $secretsDecrypted) {
|
||||||
# B6: Node.js 是硬性要求 (OpenSSL fallback 与 BWENC1 格式不兼容, 已移除)
|
|
||||||
$cryptoHelper = Join-Path $BootDir "crypto-helper.js"
|
$cryptoHelper = Join-Path $BootDir "crypto-helper.js"
|
||||||
if (-not (Test-Cmd "node") -or -not (Test-Path $cryptoHelper)) {
|
if (-not (Test-Cmd "node") -or -not (Test-Path $cryptoHelper)) {
|
||||||
Log-Fail "解密需要 Node.js (Phase 1 应已安装)"
|
Log-Fail "解密需要 Node.js (Phase 1 应已安装)"
|
||||||
Show-MsgBox "解密凭证需要 Node.js,但未检测到。`n请确认 Phase 1 安装成功后重试。" "缺少 Node.js" "OK" "Error"
|
Show-MsgBox "解密凭证需要 Node.js,但未检测到。`n请确认 Phase 1 安装成功后重试。" "缺少 Node.js" "OK" "Error"
|
||||||
}
|
}
|
||||||
elseif ((Test-Path $SecretsEnc) -or (Get-ChildItem $BootDir -Filter "secrets-*.enc" -ErrorAction SilentlyContinue)) {
|
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
|
$validAttempts = 0
|
||||||
while ($validAttempts -lt 3) {
|
while ($validAttempts -lt 3) {
|
||||||
$rawCode = Show-AuthCodeDialog ($validAttempts + 1) 3
|
$rawCode = Show-AuthCodeDialog ($validAttempts + 1) 3
|
||||||
if (-not $rawCode) {
|
if (-not $rawCode) {
|
||||||
Log-Warn "用户取消授权码输入"
|
# 不再静默跳过,明确警告
|
||||||
|
$skip = Show-MsgBox "未输入授权码。`n`n没有授权码将无法使用 Bookworm(无 API 凭证)。`n`n确定要跳过吗?" "警告" "YesNo" "Warning"
|
||||||
|
if ($skip -eq "No") { continue }
|
||||||
|
Log-Warn "用户确认跳过授权码"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user