From 42609651bd62db5a0a49fbbb303f414fa3480e13 Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Fri, 16 Jan 2026 22:16:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=88=AA=E5=9B=BE?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91=E7=9A=84?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:attempt > 0 应该是 attempt > 1 - attempt 从 range(1, max_retries + 1) 开始,值为 1, 2, 3 - 原条件 attempt > 0 在 attempt=1 时就为 True - 导致 elif 分支(首次尝试逻辑)成为死代码 修复: - 将 attempt > 0 改为 attempt > 1 - 更新注释使其更清晰准确 Co-Authored-By: Claude Opus 4.5 --- services/screenshots.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/screenshots.py b/services/screenshots.py index 2c79e06..2b47b59 100644 --- a/services/screenshots.py +++ b/services/screenshots.py @@ -252,8 +252,8 @@ def take_screenshot_for_account( # 智能登录状态检查:只在必要时才刷新登录 should_refresh_login = not is_cookie_jar_fresh(cookie_path) - if should_refresh_login and attempt > 0: - # 只有在重试时才刷新登录,避免重复登录操作 + if should_refresh_login and attempt > 1: + # 重试时刷新登录(attempt > 1 表示第2次及以后的尝试) log_to_client("正在刷新登录态...", user_id, account_id) if not _ensure_login_cookies(account, proxy_config, custom_log): log_to_client("截图登录失败", user_id, account_id)