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 }