feat: enhance swipe and back navigation logic

- Adjusted configuration for reset after swipes to 10 seconds and added action to go back.
- Updated flow control to skip back action if a recent reset was triggered within 5 seconds.
- Implemented a mechanism to enable back navigation when consecutive misses reach a threshold.
- Added GUI options to enable or disable back navigation on misses, ensuring consistency with user settings.
- Introduced new diagnostic tools for runtime flag checks and screenshot diagnostics.
- Created PowerShell scripts for restoring Start Menu shortcuts and performing system health checks.
- Added tests for swipe operations and back navigation to validate new logic.
This commit is contained in:
Your Name committed 2026-01-06 16:55:00 +08:00
1 parent 0c3a763d63
commit dcded08796
19 files changed
+936 -22

No files matched your search

+31 -11
View File
@@ -199,20 +199,40 @@ def find_and_open_fudai_detail(
enabled = True
if enabled:
# 若最近已有由滑动重置触发的回退,且在短时间内,跳过本次返回键调用以避免重复
try:
analyser.operation.click_back(analyser.device_id)
import time as _time
recent_ts = getattr(analyser, "_recent_reset_ts", 0)
if recent_ts and (_time.time() - float(recent_ts) < 5.0):
try:
analyser._log_kv(
"流程",
"检测到近期已由滑动重置触发回退,跳过重复按返回键",
)
except Exception:
pass
else:
try:
analyser.operation.click_back(analyser.device_id)
except Exception:
try:
# 兜底:使用通用 click 返回坐标
rx = int(
getattr(analyser, "resolution_ratio_x", 1080) or 1080
)
ry = int(
getattr(analyser, "resolution_ratio_y", 2400) or 2400
)
back_x = int(50 * rx / 1080)
back_y = int(50 * ry / 2400)
analyser.operation.click(analyser.device_id, back_x, back_y)
except Exception:
pass
except Exception:
# 在异常情况下保守地尝试按返回键
try:
# 兜底:使用通用 click 返回坐标
rx = int(
getattr(analyser, "resolution_ratio_x", 1080) or 1080
)
ry = int(
getattr(analyser, "resolution_ratio_y", 2400) or 2400
)
back_x = int(50 * rx / 1080)
back_y = int(50 * ry / 2400)
analyser.operation.click(analyser.device_id, back_x, back_y)
analyser.operation.click_back(analyser.device_id)
except Exception:
pass
else:
+20 -1
View File
@@ -206,8 +206,23 @@ class SwipeHandler:
if mode not in ("swipe", "back"):
mode = "swipe"
# 如果显式启用了达到未找到福袋阈值时按返回键回退(GUI 勾选),优先使用返回键回退
try:
if bool(getattr(analyser, "enable_back_on_misses", False)):
mode = "back"
except Exception:
pass
if mode == "back":
# 使用返回键回退(兼容性更好,适用于无法通过滑动稳定回退的设备)
# 标记:开始通过滑动重置/回退流程,防止其他路径重复触发返回键
try:
import time as _time
setattr(analyser, "_recent_reset_ts", _time.time())
setattr(analyser, "_recent_reset_by", "swipe_reset")
except Exception:
pass
for i in range(back_times):
try:
analyser.operation.click_back(analyser.device_id)
@@ -278,12 +293,16 @@ class SwipeHandler:
analyser.operation.delay(2)
except Exception:
pass
# 回到第一个后,计数归零
analyser.operation.delay(3)
try:
analyser._swipe_times = 0
analyser.room_pos = 0
# 清除连续未找到福袋计数,避免与其他回退逻辑重复
try:
setattr(analyser, "_consecutive_no_fudai_count", 0)
except Exception:
pass
except Exception:
pass
return 0
+18
View File
@@ -244,6 +244,24 @@ class ConfigManager:
if "reset_after_swipes" in config:
analyser.reset_after_swipes = int(config["reset_after_swipes"] or 10)
# 回退方式配置:'swipe'(默认)或 'back'
if "reset_after_swipes_action" in config:
try:
analyser.reset_after_swipes_action = str(
config["reset_after_swipes_action"] or "swipe"
).lower()
except Exception:
analyser.reset_after_swipes_action = "swipe"
if analyser.reset_after_swipes_action not in ("swipe", "back"):
analyser.reset_after_swipes_action = "swipe"
# 启用/禁用:达到连续未找到福袋阈值时按返回键回退
if "enable_back_on_misses" in config:
try:
analyser.enable_back_on_misses = bool(config["enable_back_on_misses"])
except Exception:
analyser.enable_back_on_misses = True
# 新增:下滑达到阈值后按返回并重新进入直播间的配置
if "swipe_down_back_enabled" in config:
analyser.swipe_down_back_enabled = bool(config["swipe_down_back_enabled"])