Commit Graph
69 Commits
Author SHA1 Message Date
Your Name 6cebed599d refactor(gui): _async_refresh_preview 闭包内联到 periodic_refreshers (398 → 396) 2026-05-30 19:09:37 +08:00
Your Name da5e000006 refactor(gui): 抽 root window + ttkbootstrap fallback 到 components/root_window (415 → 398) 2026-05-30 19:04:50 +08:00
Your Name 84c5731cc3 refactor(gui): 抽 on_line + Runner + log_writer 到 components/log_pipeline (440 → 418) 2026-05-30 18:47:36 +08:00
Your Name 8e0ae9396d refactor(gui): actions_log + ocr_results 内置到 simple_tabs (450 → 440) 2026-05-30 18:42:26 +08:00
Your Name a6648c5ce8 refactor(gui): reservation/high_value 用 setup_text_tab_with_refresh 复用 (452 → 450) 2026-05-30 18:37:12 +08:00
Your Name f75d3ae368 refactor(gui): refresh_stats 内置到 setup_stats_tab (470 → 452) 2026-05-30 18:33:21 +08:00
Your Name d9920f1cee refactor(gui): 抽运行日志 Tab UI 到 components/log_tab (487 → 470) 2026-05-30 18:29:00 +08:00
Your Name a1562a513d refactor(gui): 抽顶部常驻按钮区到 components/top_buttons (527 → 518) 2026-05-30 17:55:20 +08:00
Your Name 9642b7b0f8 refactor(gui): 抽顶部设备栏到 components/top_device_bar (607 → 530) 2026-05-30 17:45:01 +08:00
Your Name 9896eb676a refactor(gui): 抽周期性刷新+关闭处理到 components/periodic_refreshers (630 → 607) 2026-05-30 17:40:58 +08:00
Your Name 9744b75878 refactor(gui): 抽 127 个 Var 声明到 components/config_vars 工厂 (1373 → 1110) 2026-05-30 17:14:39 +08:00
Your Name 7a840120b3 refactor(gui): 抽底部操作按钮区到 components/action_buttons (1417 → 1373) 2026-05-30 17:06:36 +08:00
Your Name e314161b6c refactor(gui): 抽右侧主 Notebook + 实时工具栏到 components/main_notebook (1444 → 1417) 2026-05-30 17:02:35 +08:00
Your Name 3a7a7a3b75 refactor(gui): 抽 keywords_tab UI 到 components/keywords_tab (1461 → 1444) 2026-05-30 16:58:53 +08:00
Your Name 8575f04ab9 refactor(gui): 抽截图预览 Tab 整段 UI 到 components/preview_tab (1537 → 1461) 2026-05-30 16:54:53 +08:00
Your Name 728ef3cd79 refactor(gui): 5 个简单文本 Tab 用 simple_tabs 模板复用 (1571 → 1537) 2026-05-30 16:49:01 +08:00
Your Name 32e374e2c2 refactor(gui): 抽行为日志工具栏到 components/actions_log_toolbar (1649 → 1571) 2026-05-30 16:45:02 +08:00
Your Name aa0f4e05f2 refactor(gui): 抽中奖记录 Tab 整段 UI 到 components/win_record_tab (1739 → 1649) 2026-05-30 16:40:49 +08:00
Your Name 5e3015f59b refactor(gui): 抽日志搜索工具栏到 components/log_search_toolbar (1813 → 1739) 2026-05-30 16:36:43 +08:00
Your Name b686a4e3d5 refactor(gui): 抽 log_text 颜色配置到 components/log_text_colors (1878 → 1813) 2026-05-30 16:29:27 +08:00
Your Name 29cef2c578 refactor(gui): 抽 realtime_tab UI 创建到 components/realtime_tab (2037 → 1878) 2026-05-30 16:25:51 +08:00
Your Name e784efd5f8 refactor(gui): 抽 filter_tab UI 创建到 components/filter_tab (2122 → 2037) 2026-05-30 16:18:29 +08:00
Your Name 6c7bbf0945 refactor(gui): 抽 run_tab UI 创建到 components/run_tab (2192 → 2122) 2026-05-30 16:15:24 +08:00
Your Name fe27063913 refactor(gui): 抽 reservation_tab UI 创建到 components/reservation_tab (2334 → 2192) 2026-05-30 16:11:47 +08:00
Your Name 3f04bb23c2 refactor(gui): 抽 yanghao_tab UI 创建到 components/yanghao_tab (2456 → 2334) 2026-05-30 16:06:40 +08:00
Your Name bcb0e363d1 refactor(gui): 抽 logging_tab UI 创建到 components/logging_tab (2656 → 2456) 2026-05-30 15:54:46 +08:00
Your Name b447b6a6a4 refactor(gui): 抽 debug_tab UI 创建到 components/debug_tab (3052 → 2656) 2026-05-30 15:50:58 +08:00
Your Name 6bac014c3d refactor(gui): 抽 load_config_to_ui + save_ui_to_config 到 components/config_io (3538 → 3052) 2026-05-30 15:41:27 +08:00
Your Name f6d382b0e7 refactor(gui): 抽 get_params 到 components/run_params_builder (3563 → 3538) 2026-05-30 15:26:17 +08:00
Your Name 2a05be2319 refactor(gui): 抽 save_logging_config 到 components/logging_config_io (3590 → 3563) 2026-05-30 15:22:29 +08:00
Your Name 97935d9c48 refactor(gui): 抽 _generic_search_widget 到 components/text_search (3669 → 3590) 2026-05-30 15:16:42 +08:00
Your Name 64c210dd5a refactor(gui): 抽 refresh_run_log 到 components/run_log_view (3715 → 3669) 2026-05-30 15:12:38 +08:00
Your Name 68d1224b53 refactor(gui): 抽 _on_scan_one_click + _handle_scan_result 到 components/wifi_adb_one_click_scan (3775 → 3715) 2026-05-30 15:08:35 +08:00
Your Name 92d524297b refactor(gui): 抽预览 Tab 全部 8 个动作到 components/preview_view (3891 → 3775) 2026-05-30 15:03:45 +08:00
Your Name 59ebe8c1e7 refactor(gui): 抽 win_record Tab 全部 7 个动作到 components/win_record_view (4044 → 3891) 2026-05-30 14:53:11 +08:00
Your Name a7ef92fc7c refactor(gui): 抽 pump_logs 到 components/log_pump (4117 → 4044) 2026-05-30 14:37:03 +08:00
Your Name c5df7a05d2 refactor(gui): 抽 update_ocr_results 到 components/ocr_results_view (4148 → 4117) 2026-05-30 14:30:42 +08:00
Your Name b3380042b8 refactor(gui): 抽 _try_reconnect_last_wifi 到 components/wifi_adb_reconnect (4268 → 4148) 2026-05-30 14:24:19 +08:00
Your Name 4993fad004 refactor(gui): 抽 _open_scan_pick_dialog 到 components/wifi_adb_pick_dialog (4337 → 4268) 2026-05-30 14:18:19 +08:00
Your Name 44b091466d refactor(gui): 抽 actions_log 视图相关到 components/actions_log_view (4463 → 4337) 2026-05-30 14:10:30 +08:00
Your Name 8ea676562c refactor(gui): 抽 do_screenshot + OCR_REGIONS 到 components/screenshot_action (4635 → 4463) 2026-05-30 14:03:31 +08:00
Your Name a07ef00b5e refactor(gui): 抽 refresh_high_value_rooms 到 components/high_value_view (4656 → 4635) 2026-05-30 13:56:36 +08:00
Your Name 5329561b3a refactor(gui): 抽 refresh_reservations 到 components/reservations_view (4913 → 4656) 2026-05-30 13:52:39 +08:00
Your Name 6bffcae2de refactor(gui): 抽 open_wifi_adb_dialog 到 components/wifi_adb_dialog (5274 → 4913) 2026-05-30 13:48:22 +08:00
Your Name ac464788e1 refactor(gui): 抽 open_scan_dialog 到 components/wifi_adb_scan_dialog (5476 → 5274) 2026-05-30 13:43:17 +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 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 7fb0c3849c P0 死代码清理:删 .backup / 空文件 / GUI 占位桩 / 占位目录 / 失效测试
A. 删除 3 个 .backup 文件(约 3.4K 行)
  - douyin/detection/douyin_pixel.py.backup
  - douyin/stage/douyin_stage_handler.py.backup
  - gui/components/log_color_config.py.backup

B. 删除 0 字节文件
  - douyin/other/douyin_stuck_guard.py
  - docs/功能差异对比.md
  - docs/archive/模块化代码对比说明.md

C. 删除 9 个 TODO + pass 占位组件(全仓零外部引用)
  - gui/components/{config_manager,image_viewer,stats_display,
    reservation_display,high_value_rooms_display,ocr_panel,main_window}.py
  - gui/web_components/{proc_runner,http_handler}.py

D. 删除占位目录与失效测试入口
  - douyin/detection/core/  仅 re-export 占位
  - douyin/fudai/finder/    仅 re-export 占位
  - tests/run_test.py       指向已删的 deleted_tests_backup/

附加:tools/diagnostics/check_web_gui_config_sync.py --help 字符串里
      tools/web_gui_config_manifest.json 旧路径修正为 tools/dev/...

回归:154 → 141 个 .py,全量 compileall 通过;AST 扫描 0 处 import 残留;
gui.gui_app/web_gui/gui_core 仍可加载;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 10:36:59 +08:00