Commit Graph
86 Commits
Author SHA1 Message Date
CodexandClaude Sonnet 4.5 b1fa6af9ce fix(gui): 修复启动后 GUI 卡死约 1.2 秒
delayed_refresh_preview 在 mainloop 启动 300ms 后同步加载大图(PIL
Image.open + load + convert),阻塞主线程。改为:
1. 延迟到 3 秒后再触发预览(GUI 已完全初始化)
2. 图片加载放到后台线程,完成后通过 root.after 回主线程更新

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-05-23 21:58:50 +08:00
CodexandClaude Opus 4.7 fe97e82104 fix(gui): 实时查看器/状态 Tab 的耗时解析支持 ms 单位
问题:实际 actions.log 写的是 `耗时=10.00ms`(毫秒),但 _parse_minimal
和 parse_action_duration 的正则只匹配 `s`,导致:
- 实时查看弹窗永远显示"暂无动作"
- 实时状态 Tab 同样空白

同时存在的副 bug:兜底正则在整行匹配,前缀里的 `192.168.5.2:5555` /
日志时间戳 `2026-05-21` 都可能被误识别成耗时。

修复:
- 解析窗口限定到 line.find("耗时") 之后的子串 (tail)
- 优先匹配 ms(顺序很重要:\s*s 会先吃掉 "10ms" 的 m)
- s 单位加 (?![a-zA-Z]) 负向后顾,避免匹配 "ms" / "second" 之类
- 同步修复 gui_app.py:3685 的 parse_action_duration(实时状态 Tab)

测试:
- _parse_minimal 加 4 个新测试覆盖 ms / 整数 ms / 优先级 / 前缀干扰
- 全量 1426 passed (+5)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 09:08:58 +08:00
CodexandClaude Opus 4.7 4277bf7fa4 fix(gui): WiFi 扫描显示 adb 真实返回,state=failed 不再误导为"请授权"
问题:扫描提示 "192.168.5.2:5555 当前状态=failed,请先在手机上授权后重试",
但 failed 表示 adb connect 既不成功也不是 unauthorized(通常是 adb 服务异常 /
设备短暂不可达),不是授权问题。手机不会弹窗,用户照提示去手机上找授权窗
口,永远不会成功。

修复:
- _handle_scan_result: 区分 failed 分支,逐项打印 adb 真实返回(去掉换行
  方便单行显示),并提示用户排查 adb 服务而非"请授权"。
- _open_scan_pick_dialog: 表格新增 "adb 返回" 列(截断 200 字符);
  Toplevel 拓宽到 680x320 容纳新列。
- use_selected: 根据 state 给出针对性提示——unauthorized 让用户授权,
  failed 显示对应 message,其他状态保持通用提示。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 08:55:15 +08:00
CodexandClaude Opus 4.7 ca6c2e4d20 fix(gui): 恢复运行日志 Tab 搜索工具栏定义
d759921 抽 _open_realtime_viewer_impl 时误删了紧随其后的 16 行
"搜索工具栏"块(log_search_frame / log_filter_var / log_search_var /
log_search_entry),导致 gui_app 启动时在 L3964 报
NameError: name 'log_search_entry' is not defined。

恢复这 16 行到原位置,gui_app 可正常启动。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 08:37:30 +08:00
CodexandClaude Opus 4.7 d759921442 refactor(gui): 抽 _open_realtime_viewer_impl 到 components/realtime_viewer (5539 → 5370)
gui_app.py 嵌套函数 _open_realtime_viewer_impl 是 170 行的"实时查看"对话框:
弹 Toplevel 显示当前 pic/screenshot.png + 列表展示 actions.log 中含"耗时"的
最近 80 行,每秒刷新。

抽到 gui/components/realtime_viewer.py:
- open_realtime_viewer(root) 主入口
- _tail_read(path, max_bytes) 末尾字节读取
- _parse_minimal(line) 提取 (动作名, 耗时) 二元组
- 全局单例 _active_win 替代原嵌套 def 的属性式 _win

gui_app.py 中嵌套 def 缩成 4 行委托。

新增 13 个单元测试覆盖 _tail_read 4 种情况 + _parse_minimal 8 种格式。

1421 passed (+13)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 03:47:58 +08:00
CodexandClaude Opus 4.7 fb35670032 refactor(gui): 抽 ThreadSafeLogWriter 到 components/log_writer (5649 → 5537)
gui_app.py 的 ThreadSafeLogWriter 类(109 行)是自包含的日志文件写入器:
threading.Lock 保护、按日期分割、配置开关、PermissionError/Exception 兜底。

抽到 gui/components/log_writer.py,原 gui_app 中的 109 行类定义 + 1 行实例化
替换为 3 行导入 + 实例化。read_config 通过 staticmethod _read_config 延迟导入,
避免循环依赖。

新增 15 个单元测试覆盖:
- __init__:默认 log_dir / 配置开关 / dated_logs / 相对路径解析 / 配置异常兜底
- write:正常写 / 禁用跳过 / 空行跳过 / 时间戳前缀 / 已格式化行原样写
- 100 线程 × 10 行的并发安全测试(确认 1000 行无丢失)
- PermissionError / 通用异常下不抛 + warn 一次

1408 passed (+15)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 03:29:25 +08:00
CodexandClaude Opus 4.7 230c0d4049 refactor(gui): 抽 refresh_stats 字符串格式化到 stats_formatter (6339 → 5634)
gui_app.py 的 refresh_stats 闭包是 705 行纯字符串构建:把 runner.get_stats()
的字典格式化成多个分段(基本信息/快速汇总/核心统计/跳过/OCR/详情/福袋查找/
性能/粉丝团/切换/预约/错误/价值/最近福袋/中奖记录)。

抽到 gui/components/stats_formatter.py:
- format_stats(stats: Dict) -> List[str] 主入口
- 14 个 _append_* 子段构建器(每段一个,按需追加)
- _section_lines(title, body) 标题包装

闭包改为 16 行委托:调 format_stats + 写入 ScrolledText。

新增 32 个单元测试覆盖:
- 空 dict / 缺字段时的兜底
- 基本运行状态(uptime / pid / exit_code 各种格式)
- 各分段的"有数据 / 无数据"条件
- 关键率计算(打开成功率/点击率/参与成功率/中奖率/跳过率/错误频率)
- 边界情况(attend_ok > clicks 检测到已参与,结果未开奖警告,wins 截断到 10 条)

1393 passed (+32)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 03:23:53 +08:00
CodexandClaude Opus 4.7 52b811d0cb feat(scan): WiFi-ADB 扫描支持自定义/多端口(覆盖 Android 11+ 随机端口)
之前只扫 5555。Android 11+ "无线调试" 用 37000-44999 随机端口,
固定的 adb tcpip 也可改端口。新接口让扫描适配任意端口规格。

新增 parse_port_spec:解析端口规格字符串
  - 5555            单端口
  - "5555,5556"     逗号分隔
  - "37000-37010"   范围(最大 1024 个)
  - 混合格式与序列输入
  - 非法/越界 → 退化为默认 5555
  - 单个范围 > 1024 端口直接忽略,避免误扫整个端口段

scan_open_ports 重构:
  - 接受 ports 参数(list[int]),传 ports 时优先于旧 port=int
  - 返回 list[(ip, port)] 而不是 list[ip],按 (IP 数值序, port 升序) 稳定排序

discover_adb_devices 支持 ports 参数,按 (ip, port) 逐个 verify_adb_target

接入 GUI 与 webui:
  - gui_app.py 扫描对话框新增"端口"输入框 + 提示
  - gui_app.py 启动重连:上次端口非 5555 时把它一并扫描
  - web_gui.py /api/wifi/scan 接受 ports;/api/wifi/auto-reconnect 同上次端口逻辑

新增 13 个 parse_port_spec 单测 + 4 个 scan_open_ports 多端口测试 +
2 个 discover_adb_devices 多端口集成测试。
真机验证:6 端口 (5555 + 37000-37005) × 254 IP,~8.5s 扫完,
正确发现 192.168.5.2:5555 (PEPM00)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 01:02:48 +08:00
CodexandClaude Opus 4.7 5966f461c3 feat(wifi_adb): 启动重连失败时自动扫描子网 + 智能匹配
新增 pick_best_match(devs, last) 纯函数,按优先级匹配上次设备:
1. target 完全一致(IP 没换)
2. 同 model + 同 port(换 IP 但同一台手机)—— 多台同型号时返回 None 让用户选
3. 同主机段 + 同 port(弱兜底,仅唯一时返回)
4. 唯一一台 connected(扫到就一台时认定)

GUI _try_reconnect_last_wifi 流程升级:
- verify_adb_target 失败(不可达)→ 自动 discover_adb_devices 扫子网
- pick_best_match 命中 → 选中 + 更新 last_wifi_target
- 命中且 IP 已变 → 日志写"上次目标 X 已变 → 智能匹配到 Y(已更新记忆)"
- 没命中 → 列出候选 + 提示点'扫描 WiFi'手选

实际场景:换 WiFi 网段(家里 → 公司 / 192.168.1 → 192.168.5)后
GUI 启动时自动找回同一台手机,无需任何手动操作。

新增 15 个 pick_best_match 单元测试覆盖所有规则 + 边界。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 20:46:23 +08:00
CodexandClaude Opus 4.7 b3a41db029 feat(wifi_adb): WiFi-ADB 设置对话框三个连接路径都记 last_wifi_target
补齐之前 main commit a71f6fa 漏的几处:
- "连接"按钮:成功后保存 ip:port + 设备型号到 last_wifi_target
- "自动连接"按钮:从 USB → WiFi 切换成功后保存
- "断开连接"按钮:如果断开的就是上次记住的 IP,清掉记录避免下次启动徒劳重试

行为现在统一:所有"连上一台 WiFi 设备"的入口都会更新记忆,所有"主动断开"
的入口都会清除记忆。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 20:21:24 +08:00
CodexandClaude Opus 4.7 a71f6faed0 feat(wifi_adb): 记住上次成功的 WiFi 设备,GUI 启动时自动重连
新增 gui/gui_core_pkg/config.py 三个 helper:
- get_last_wifi_target  / set_last_wifi_target / clear_last_wifi_target
配置以 last_wifi_target = {target, model, saved_at} 形式存在 config.json 顶层。

GUI 行为:
- "扫描 WiFi" 选中或自动连上一台 connected 设备 → 写入 last_wifi_target
- WiFi 选择对话框"使用选中"也写入
- 主窗口启动后延迟 300ms 后台尝试 verify_adb_target(last.target)
  - 已有设备:不打扰
  - 重连成功:自动设为当前设备
  - unauthorized:提示需手机端授权
  - 不可达:提示换网了,引导点'扫描 WiFi'

新增 12 个 last_wifi_target 单元测试覆盖读写/清除/损坏值/缺文件等场景。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 20:16:37 +08:00
CodexandClaude Opus 4.7 db7a78876b feat(gui): 主窗口加"扫描 WiFi"一键按钮
主窗口设备行的"刷新设备"按钮旁加"扫描 WiFi"按钮。后台线程扫描局域网,
按结果数智能处理:

- 0 个发现     → 日志提示
- 1 个 connected → 自动设为当前设备
- N 个 unauthorized → 提示需手机端授权
- 多个候选     → 弹简化版列表对话框让用户选

省去打开 WiFi-ADB 设置对话框的步骤,常见单机场景一键完成。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 20:09:01 +08:00
CodexandClaude Opus 4.7 e89393693b feat(wifi_adb): 加局域网 ADB 设备扫描发现
新增 gui/gui_core_pkg/wifi_adb_scan.py(356 行):
- get_local_subnet:从本机 WLAN 出口 IP 推 /24 子网
- parse_subnet_spec:解析 192.168.5.0/24 / 192.168.5.1-100 / 192.168.5.5 / 逗号组合
- probe_adb_port:并发 TCP 探测(默认 0.3s 超时,64 线程并发)
- verify_adb_target:对每个开放端口的 IP 调 adb connect 区分 connected / unauthorized / failed
- discover_adb_devices:主入口,端到端只需 1.5 秒扫完 /24

GUI(gui/gui_app.py)"扫描局域网"按钮加在 WiFi 设备操作区:
- 自动推子网(默认)+ 手动输入支持 CIDR / 范围 / 单 IP / 逗号
- 后台线程扫描,进度条 + 阶段提示
- 列表展示 IP / 状态 / 设备型号 / adb connect 输出,列表中手动选
- 选中已 connected 的设备 → 回填 IP 到主对话框
- unauthorized 设备明确提示需手机端授权

新增 25 个 wifi_adb_scan 单元测试。真机端到端验证通过:1.5s 扫完
192.168.5.0/24 子网,发现 192.168.5.2:5555(PEPM00)connected。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 19:59:19 +08:00
CodexandClaude Opus 4.7 0d01dabb69 P2 §5.3: 23 处 importlib.import_module → 静态 from import
把剩余 5 个文件里所有动态导入 douyin_screenshot_manager 的 importlib 调用
替换为顶部静态 from import 模式:

  - douyin/detection/douyin_pixel.py        7 处
  - douyin/detection/douyin_detection.py    8 处
  - douyin/fudai/douyin_fudai_finder.py     4 处
  - douyin/fudai/core/fudai_attend.py       2 处
  - gui/gui_app.py                          2 处

douyin_screenshot_manager 只引用 douyin.core.path_config,与上述 5 个文件
无循环依赖。bin/run_cli.py 的剩余 1 处 importlib 是有意为之
(绕过 package __init__ 遮蔽),保留。

收益:
  - 可读性 + IDE 跳转/类型提示
  - 每次调用省去 ~100µs 的 import_module 开销(detection 模块在热路径上调用密集)
  - 死代码减少 ~92 行(5 个文件合计 -115 / +23)

回归:140 .py 编译通过;importlib 残留只剩 bin/run_cli 故意 1 处;
5 个模块导入 + fudai_analyse + should_skip_fudai_by_config 业务链路正常;
test_filter_logging / check_web_gui_config_sync 通过。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 12:06:23 +08:00
CodexandClaude Opus 4.7 d5c9936c88 gui_app + base_interface: 内部错误 print → logger
gui/gui_app.py(8 处 sys.stderr print → _LOGGER):
  - 配置读取失败、日志文件权限/写入错误(warning/error 级)
  - pump_logs 内日志插入失败、循环异常、调度下次更新失败(error/warning 级)
  - 顶部 import logging + 模块级 _LOGGER

douyin/core/fudai_modules/base_interface.py(2 处 print → _LOGGER):
  - BaseFudaiMixin._safe_log 在主类无 _enhanced_log_kv 时的兜底改为 logger.info
  - 顶部 import logging + 模块级 _LOGGER

保留为 stdout 的合理场景:
  - bin/run_cli.py 的 [TEST]/[YANGHAO-ONLY] CLI 输出
  - bin/manage_logs.py 的 CLI 工具输出
  - gui/webgui_launcher.py: GUI 同时把 log 输出到控制台
  - douyin/logging/internal_loggers.py: logger 模块自身的初始化失败兜底
  - douyin/logging/douyin_logging{,_wrapper}.py: 日志系统内部的格式化输出

回归:140 .py 编译通过;test_filter_logging / check_web_gui_config_sync 通过;
gui.gui_app/web_gui/gui_core/base_interface 全部可加载,_LOGGER 名称正确。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 11:43:44 +08:00
CodexandClaude Opus 4.5 ba4c131b2d refactor: 简化 gui_app.format_gui_log_line 为薄包装
原本 64 行的 fallback 实现实际上是死代码——
gui.components.log_viewer.format_gui_log_line 一直存在,
import 失败几乎不可能发生。

简化为薄包装函数,import 失败时返回原字符串。

文件行数:5857 -> 5804(减 53 行)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-21 09:42:27 +08:00
CodexandClaude Opus 4.5 8fe7ff0585 refactor: 根目录核心模块迁移到 douyin/core/ 和 douyin/logging/
将 4 个根目录核心模块迁移到合理位置:
- path_config.py    -> douyin/core/path_config.py
- version.py        -> douyin/core/version.py
- Underlying_Operations.py -> douyin/core/underlying_operations.py
- unified_logger.py -> douyin/logging/unified_logger.py

配套更新所有 import:
- path_config: 41 处 import 改为 douyin.core.path_config
- version: 4 处改为 douyin.core.version
- unified_logger: 5 处改为 douyin.logging.unified_logger
- Underlying_Operations: 14 处改为 douyin.core.underlying_operations

修复 path_config.PROJECT_ROOT 计算(向上 2 级而非当前目录)。

验证:python -m compileall 全项目通过。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-21 00:23:14 +08:00
Codex caa24ea8ca 保持Web端和桌面端参数同步 2026-05-20 20:32:23 +08:00
Your Name 6933c0b4fe 优化:调整参与按钮区域坐标,修正按钮覆盖范围 2026-01-25 20:50:16 +08:00
Your Name 272dcab91d 优化:调整参与按钮区域坐标,增强对部分机型底部按钮的覆盖;更新调试截图逻辑以使用新坐标 2026-01-25 16:58:15 +08:00
Your Name 4903e50ff2 优化:调整代码格式,增强可读性 2026-01-23 15:29:09 +08:00
Your Name c79c50ffe4 优化:添加购物红包背景红色占比阈值配置,增强红包弹窗检测功能 2026-01-18 14:38:38 +08:00
Your Name 96c5cd50ec 优化:调整_mapping_tree_columns函数的格式,提升代码可读性 2026-01-18 13:42:20 +08:00
Your Name eb23d2d8e6 GUI: 自动调整映射表列宽以适配内容 2026-01-17 22:00:14 +08:00
Your Name 272f3ddae0 GUI: 修复映射表容器,避免列挤压并修复滚动条问题 2026-01-17 21:40:20 +08:00
Your Name 3ce0aa73dd feat: 优化当前直播间标题获取逻辑,提升匹配准确性 2026-01-17 19:34:57 +08:00
Your Name 3488624b8f feat: 优化预约逻辑,增强映射表记录功能,提升用户体验 2026-01-17 18:46:13 +08:00
Your Name db75248b98 feat: 优化滑动重置回退延迟,从2秒减少到0.1秒;完善预约系统二次回退机制 2026-01-16 21:54:09 +08:00
Your Name 54f9b39d2e feat: 优化滑动重置和返回键回退逻辑,完善预约系统二次回退机制 2026-01-16 21:53:05 +08:00
Your Name ca77862a86 feat: 添加滑动坐标配置功能,优化滑动操作的灵活性 2026-01-16 19:18:37 +08:00
Your Name 7c839c5d39 feat: 优化直播间标题识别逻辑,增强缓存管理和错误处理 2026-01-16 16:15:40 +08:00
Your Name 3723c39a58 feat: 优化福袋详情记录逻辑,提升代码可读性 2026-01-16 03:44:53 +08:00
Your Name df65adfe4e feat: 更新配置文件以启用调试捕获,调整福袋相关坐标,优化预约处理逻辑,增强界面显示信息 2026-01-16 03:04:11 +08:00
Your Name 362b7c841c fix: 修复代码格式问题,提升可读性 2026-01-16 02:31:34 +08:00
Your Name 0862a92dc5 feat: 优化 diagnose_stage_from_current_screen 函数的调用格式,提升代码可读性 2026-01-15 23:04:53 +08:00
Your Name d2c5ca57e8 feat: 更新房间状态管理,优化直播间标题记录逻辑,移除过时的房间位置映射文件 2026-01-15 23:03:56 +08:00
Your Name d1f675073f feat: 更新房间位置映射表,修改标题为海宁齐总 2026-01-15 16:19:08 +08:00
Your Name 504410f7b9 feat: 优化映射表加载与导出功能,确保数据一致性与可视化更新 2026-01-15 16:18:10 +08:00
Your Name 2358682216 feat: 添加持久化映射加载和状态文件序列化功能,优化 GUI 显示 2026-01-15 14:25:54 +08:00
Your Name a84836a6c7 refactor: 优化代码格式,提升可读性 2026-01-15 01:12:20 +08:00
Your Name df96e5fc83 feat: 添加确保输入框获得焦点的选项,优化文本粘贴功能 2026-01-15 01:10:54 +08:00
Your Name 54f3b35a26 Refactor code structure for improved readability and maintainability 2026-01-11 23:31:38 +08:00
Your Name 2f01200887 feat: 更新高价值房间数据,调整房间信息和时间戳;优化红包弹窗检测函数,增加返回详细信息参数 2026-01-09 16:35:23 +08:00
Your Name 0830c08fca feat: 更新高价值房间数据,调整房间信息和检测耗时 2026-01-09 15:09:06 +08:00
Your Name fb0c07c91a Add shopping red packet detection tests and sample image
- Implemented a test script for shopping red packet detection using pixel analysis and OCR.
- Created a sample image to simulate a shopping red packet for testing purposes.
- Added functions to test pixel detection, coordinate definitions, and OCR keyword matching.
- Included detailed print statements for test results and summaries.
2026-01-08 20:37:49 +08:00
Your Name b3011dd9ce feat: Implement high-value room revisit feature and enhance fudai tracking
- Added tracking for previously seen fudai in Runner and ProcRunner classes to avoid duplicate recognition.
- Extracted room title during fudai recognition for better tracking.
- Updated high_value_rooms.json with new room entries and adjusted total count.
- Introduced new GUI elements for configuring icon coordinates in webui.
- Created comprehensive documentation for the high-value room revisit functionality.
- Added tests for delay settings and icon detection logic to ensure functionality.
- Implemented a tool for analyzing step times in logs to identify performance bottlenecks.
2026-01-08 14:27:38 +08:00
Your Name 5738d29bd6 feat: 添加预约回退功能完整测试脚本和错误场景测试脚本 2026-01-08 00:15:00 +08:00
Your Name 93d47a16d6 Refactor reservation preemption handling and logging
- Removed the reservation preempt minimum value from the Runner and GUI components.
- Updated logging mechanism to streamline log message handling and improve readability.
- Introduced a new method for appending log lines in the Runner class.
- Cleaned up related GUI elements and configuration options in web interface.
- Deleted obsolete simulation scripts related to reservation preemption checks.
2026-01-07 21:24:10 +08:00
Your Name eb96d6869e feat: 优化日志搜索功能,增强用户体验和性能 2026-01-07 19:31:26 +08:00
Your Name c6b6745e3e feat: 优化日志记录格式,增强循环次数和运行时间限制的可读性 2026-01-07 19:06:10 +08:00