From db75248b989c43d399e2869a1035924d198a7bb0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 16 Jan 2026 21:54:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=BB=91=E5=8A=A8?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E5=9B=9E=E9=80=80=E5=BB=B6=E8=BF=9F=EF=BC=8C?= =?UTF-8?q?=E4=BB=8E2=E7=A7=92=E5=87=8F=E5=B0=91=E5=88=B00.1=E7=A7=92?= =?UTF-8?q?=EF=BC=9B=E5=AE=8C=E5=96=84=E9=A2=84=E7=BA=A6=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E5=9B=9E=E9=80=80=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/完整技术文档.md | 14 +++++- douyin/handlers/douyin_swipe_handler.py | 2 +- .../reservation/douyin_reservation_logic.py | 50 +++++++++++++------ gui/gui_app.py | 8 ++- 4 files changed, 56 insertions(+), 18 deletions(-) diff --git a/docs/完整技术文档.md b/docs/完整技术文档.md index 4ff9c30..2e51fbe 100644 --- a/docs/完整技术文档.md +++ b/docs/完整技术文档.md @@ -16,7 +16,7 @@ 本小节记录最近完成的若干修复与功能开关,便于开发与运维快速验证和回滚。 -- 概要:修复GUI中滑动重置回退方式与返回键回退的配置逻辑分离问题;完善预约系统中回退校验失败后的二次回退机制,确保能根据映射表重新定位目标直播间。 +- 概要:修复GUI中滑动重置回退方式与返回键回退的配置逻辑分离问题;完善预约系统中回退校验失败后的二次回退机制,确保能根据映射表重新定位目标直播间;优化滑动重置回退过程中的延迟,从2秒减少到0.1秒以加快回退速度。 - GUI回退配置逻辑分离: - `gui/gui_app.py`:修复保存配置逻辑,独立处理`reset_after_swipes_action`和`enable_back_on_misses`配置;重新组织UI布局,按功能分组显示相关配置。 @@ -27,11 +27,15 @@ - `douyin/reservation/douyin_reservation_logic.py`:修复回退校验失败后的二次回退逻辑,添加位置重新查找机制;确保二次回退成功时正确设置锁定期和待处理标志。 - `douyin/reservation/douyin_reservation_handler.py`:`seek_reservation_room`函数优化,确保位置差为0时仍能正确处理。 + - 滑动回退延迟优化: + - `douyin/handlers/douyin_swipe_handler.py`:优化滑动重置回退过程中的延迟,从每次回退间的2秒延迟减少到0.1秒;显著加快回退到第一个直播间的速度。 + - 验证要点(运行时观察): - GUI中滑动重置回退方式与返回键回退配置完全独立,不再相互影响。 - 预约回退校验失败时,会先重新查找目标直播间位置,然后执行二次回退。 - 二次回退成功时会正确设置锁定期,避免重复处理同一预约。 - 日志中显示"重新查找目标直播间位置成功"和"第二次回退成功"的相关信息。 + - 滑动重置回退过程显著加快,每次回退间的延迟从2秒减少到0.1秒。 - 快速验证命令(仓库根目录,PowerShell): @@ -61,6 +65,14 @@ python -c " from douyin.handlers import douyin_swipe_handler handler = douyin_swipe_handler.SwipeHandler() print('滑动处理器初始化正常') + +# 检查回退延迟是否已优化 +import inspect +source = inspect.getsource(handler.maybe_reset_after_swipes) +if 'analyser.operation.delay(0.1)' in source and 'analyser.operation.delay(2)' not in source.split('#')[0]: + print('回退延迟优化验证通过:延迟已从2秒减少到0.1秒') +else: + print('回退延迟优化验证失败:延迟未正确修改') " ``` diff --git a/douyin/handlers/douyin_swipe_handler.py b/douyin/handlers/douyin_swipe_handler.py index badee47..5e83625 100644 --- a/douyin/handlers/douyin_swipe_handler.py +++ b/douyin/handlers/douyin_swipe_handler.py @@ -371,7 +371,7 @@ class SwipeHandler: ) except Exception: pass - analyser.operation.delay(2) + analyser.operation.delay(0.1) # 减少回退延迟,从2秒改为0.1秒 except Exception: pass # 回到第一个后,计数归零,但不重置位置以保持映射表连续性 diff --git a/douyin/reservation/douyin_reservation_logic.py b/douyin/reservation/douyin_reservation_logic.py index 7d576fb..7a65734 100644 --- a/douyin/reservation/douyin_reservation_logic.py +++ b/douyin/reservation/douyin_reservation_logic.py @@ -1868,14 +1868,20 @@ def process_reservation_attend_window( pass # 校验失败意味着位置信息可能不准确,先尝试重新查找目标直播间的当前位置 - updated_target = dict(target) # 复制一份,避免修改原预约项 + updated_target = dict( + target + ) # 复制一份,避免修改原预约项 try: - from douyin.reservation import douyin_reservation_handler + from douyin.reservation import ( + douyin_reservation_handler, + ) - current_pos = ReservationHandler.find_room_pos_by_title( - analyser, - target_room_title, - target_room_title_raw + current_pos = ( + ReservationHandler.find_room_pos_by_title( + analyser, + target_room_title, + target_room_title_raw, + ) ) if current_pos is not None and current_pos > 0: updated_target["pos_seen"] = current_pos @@ -1898,7 +1904,9 @@ def process_reservation_attend_window( analyser._log_kv( "预约", "[预约] 重新查找目标直播间位置失败,使用原有位置", - target_pos=int(target.get("pos_seen", 0)), + target_pos=int( + target.get("pos_seen", 0) + ), target_room_title=( target_room_title[:50] if target_room_title @@ -1923,7 +1931,9 @@ def process_reservation_attend_window( try: if seek_reservation_room_callback: ok2 = bool( - seek_reservation_room_callback(updated_target) + seek_reservation_room_callback( + updated_target + ) ) except Exception: ok2 = False @@ -1932,20 +1942,28 @@ def process_reservation_attend_window( # 第二次回退成功,设置锁定期并标记待处理 focus_until_new = ft + max(0.0, poll_before) if reservation_focus_until_ts_ref: - reservation_focus_until_ts_ref[0] = focus_until_new + reservation_focus_until_ts_ref[0] = ( + focus_until_new + ) else: - reservation_focus_until_ts_ref.append(focus_until_new) + reservation_focus_until_ts_ref.append( + focus_until_new + ) if reservation_after_action_pending_ref: reservation_after_action_pending_ref[0] = True else: - reservation_after_action_pending_ref.append(True) + reservation_after_action_pending_ref.append( + True + ) try: analyser._log_kv( "预约", "[预约] 第二次回退成功:已根据映射表回退到目标直播间", - target_pos=int(updated_target.get("pos_seen", 0)), + target_pos=int( + updated_target.get("pos_seen", 0) + ), target_room_title=( target_room_title[:50] if target_room_title @@ -1972,7 +1990,9 @@ def process_reservation_attend_window( pass try: if reservation_after_action_pending_ref: - reservation_after_action_pending_ref[0] = False + reservation_after_action_pending_ref[0] = ( + False + ) except Exception: pass @@ -1980,7 +2000,9 @@ def process_reservation_attend_window( analyser._log_kv( "预约", "[预约] 第二次回退失败:无法根据映射表定位到目标直播间", - target_pos=int(updated_target.get("pos_seen", 0)), + target_pos=int( + updated_target.get("pos_seen", 0) + ), target_room_title=( target_room_title[:50] if target_room_title diff --git a/gui/gui_app.py b/gui/gui_app.py index 04baada..dc60d87 100644 --- a/gui/gui_app.py +++ b/gui/gui_app.py @@ -2008,7 +2008,9 @@ def main(): except Exception: enable_back_on_misses_var.set(True) try: - reset_after_swipes_action_var.set(str(cfg.get("reset_after_swipes_action", "swipe"))) + reset_after_swipes_action_var.set( + str(cfg.get("reset_after_swipes_action", "swipe")) + ) except Exception: reset_after_swipes_action_var.set("swipe") switch_room_wait_after_stage_diag_seconds_var.set( @@ -2301,7 +2303,9 @@ def main(): ) cfg2["fudai_exit_after_misses"] = int(fudai_exit_after_misses_var.get() or 30) cfg2["enable_back_on_misses"] = bool(enable_back_on_misses_var.get()) - cfg2["reset_after_swipes_action"] = str(reset_after_swipes_action_var.get() or "swipe") + cfg2["reset_after_swipes_action"] = str( + reset_after_swipes_action_var.get() or "swipe" + ) cfg2["fudai_disable_content_recognition"] = bool( fudai_disable_content_recognition_var.get() )