Commit Graph
47 Commits
Author SHA1 Message Date
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
zzz 6ef04c1f37 Merge branch 'main' into claude/wonderful-brattain-d1cfe0 2026-05-21 10:24:10 +08:00
CodexandClaude Opus 4.7 71f3653354 补回上次合并丢失的关键路径修复 + .gitignore 补强 + 依赖版本对齐
上次冲突解决时跳过了 982f57e (P0 清理) 和 b6ae970 (路径修复) 两个 commit,
本提交补回其中影响运行时正确性和文档一致性的 7 处。

E. 路径错位修复
  - douyin/core/douyin_fudai.py: _reservations_state_path 与 room_pos_map
    状态目录改为优先调用 path_config.get_reservations_path()
  - douyin/core/path_config.py: get_reservations_path 注释明确"实际位置 + 写入方"
  - gui/components/mapping_utils.py: 删除错误兜底 douyin/state/reservations.json
  - gui/components/mapping_table.py: 同步删除 douyin/state/room_pos_map.json 错误兜底
  - gui/web_gui.py: get_reservations() 内的兜底由 douyin/state/ 修正为 douyin/core/state/
  - bin/run_cli.py: 移除对已删空文件 douyin_reservation_ops.py 的 shim 加载
  - douyin/reservation/douyin_reservation_ops.py: 删除 0 字节空文件

F. .gitignore 补强
  - 新增 *.bak_* 拦截带日期后缀的备份命名(修复 *.bak 命中失败的场景)

G. 依赖版本对齐
  - requirements-minimal.txt: paddleocr/paddlepaddle 改为 >=3.0.0,与 requirements.txt 一致
  - README.md: 安装指引中 paddlepaddle==2.5.2 改为 >=3.0.0

回归:全量 .py compileall 通过;7 项断言(path_config 路径、douyin_fudai 切换、
3 处兜底已清、shim 已移除、空文件已删、.gitignore 补强、版本对齐)全部 PASS;
test_filter_logging / check_web_gui_config_sync 通过。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 10:18:17 +08:00
CodexandClaude Opus 4.5 7d63a36125 chore: 删除重复的 log_color_config_fixed.py
log_color_config.py (540行) 与 log_color_config_fixed.py (198行) 的
get_operation_type / get_color_config / apply_operation_color 行为完全一致。
保留前者(更完整),删除后者,简化 actions_log_viewer.py 的双 try import。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-21 10:12:38 +08:00
CodexandClaude Opus 4.7 96f8600d42 小批量收尾:删除零引用 scrcpy_screenshot + douyin_fudai/log_viewer print→logger
- 删除 operations/scrcpy_screenshot.py(100 行,仅自身定义自身使用,全仓零外部引用)
- douyin/core/douyin_fudai.py:3 处兜底 print → logging.info/warning(_log_kv 失败时的兜底路径)
- gui/components/log_viewer.py:2 处错误 print → _LOGVIEW_LOGGER.exception(日志线程异常 / 刷新显示异常)

回归:149→148 .py,全量编译通过;test_filter_logging / check_web_gui_config_sync 通过;
fudai_analyse 类正常导出,log_viewer 模块加载 OK。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 09:40:18 +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
Your Name 4903e50ff2 优化:调整代码格式,增强可读性 2026-01-23 15:29:09 +08:00
Your Name 0b5f150691 Refactor and clean up code across multiple scripts
- Removed trailing whitespace and ensured files end with a single newline in cleanup_unused_files.py.
- Added fix_trailing_whitespace.py to batch remove trailing whitespace from Python files.
- Updated install_dependencies.py to improve dependency installation prompts.
- Cleaned up pick_coords.py by removing unnecessary whitespace and improving code readability.
- Enhanced region_selector.py by disabling specific pylint checks for better compatibility with third-party libraries.
- Improved WPS流程图生成工具.py by cleaning up whitespace and enhancing readability.
- Updated __init__.py in typings to remove unnecessary lines.
- Modified app.js to adjust default configuration values and clean up unused code.
2026-01-02 23:57:03 +08:00
Your Name 9131c48633 Refactor screenshot service for improved performance and error handling; add simplified version to avoid linter issues. Update tests and documentation accordingly. 2026-01-02 02:17:33 +08:00
Your Name a0aad21835 feat: Optimize ADB exec-out and OCR performance
- Introduced performance enhancements for ADB exec-out, reducing execution time by 10-20% through the use of Popen with streaming reads, increased buffer sizes, and removal of unnecessary fsync calls.
- Implemented optimizations in OCR processing, cutting recognition time by 50% by refining button recognition logic and improving image loading and preprocessing methods.
- Added detailed performance diagnostics and configuration options to facilitate further optimizations.
- Created new documentation files outlining the performance improvements and recommendations for future enhancements.
2026-01-02 02:06:01 +08:00
Your Name c7b5d6be0f 后台保存debug图像 2026-01-01 13:25:50 +08:00
Your Name 7b93413af7 回退到直接截图 2026-01-01 11:30:59 +08:00
Your Name 478ae69052 chore: Clean up blank lines and enhance code organization
- Removed excessive blank lines from multiple Python scripts and configuration files to improve readability and maintainability.
- Ensured consistent formatting across the project, contributing to a more organized codebase.
- Added new files for testing and analysis, including `test_screenshot_error_handling.py` and `test_screenshot_reuse_optimization.py`, to improve testing coverage and functionality.
2026-01-01 10:04:32 +08:00
Your Name 07c387751d chore: Clean up blank lines across multiple files to enhance readability
- Removed excessive blank lines in various Python scripts, markdown files, and configuration files to improve overall code clarity and maintainability.
- Ensured consistent formatting throughout the project, contributing to a more organized codebase.
2025-12-31 17:00:58 +08:00
Your Name ace3bbfa04 优化后台截图功能 2025-12-31 11:55:01 +08:00
Your Name 223c127e11 chore: Clean up and refactor codebase for improved maintainability
- Removed obsolete command-line test parameters from `run_cli.py` to streamline functionality.
- Introduced a new `ocr_preprocess.py` module for unified OCR image preprocessing, enhancing recognition stability.
- Updated various components to utilize the new preprocessing function, improving code organization and readability.
- Adjusted configuration values in `config.json` for better performance and consistency.
- Added comprehensive technical documentation for the Douyin project, detailing code modification standards and operational guidelines.
- Cleaned up excessive blank lines across multiple files to enhance overall readability.
2025-12-30 23:11:34 +08:00
Your Name efe6e2252f feat: Add logging and error handling enhancements
- Introduced new logging modules for action tracking, error logging, and performance tracking to improve observability.
- Added functions for retrieving debug and error log paths in `path_config.py`.
- Updated various components to utilize the new logging system, enhancing error handling and performance diagnostics.
- Implemented a GUI component for viewing error logs, improving user experience in monitoring application issues.
- Cleaned up unnecessary blank lines and improved code readability across multiple files.
2025-12-29 20:48:09 +08:00
Your Name bdf9312bc9 chore: Remove obsolete scripts and enhance path configuration
- Deleted `check_md_files.py` and `fix_cursor_md_issue.py` as they are no longer needed.
- Added new functions in `path_config.py` for better path management, including actions log and run_cli paths.
- Updated various modules to utilize the new path configuration, ensuring consistency and maintainability across the project.
2025-12-28 20:55:34 +08:00
Your Name b9849b9f5a chore: Remove obsolete scripts and enhance path configuration
- Deleted `check_md_files.py` and `fix_cursor_md_issue.py` as they are no longer needed.
- Added new functions in `path_config.py` for better path management, including actions log and run_cli paths.
- Updated various modules to utilize the unified path configuration, ensuring backward compatibility and improved maintainability.
- Enhanced documentation in `README.md` to reflect changes in path management and project structure.
2025-12-28 20:47:30 +08:00
Your Name 26df350755 feat: Implement 30-minute timeout protection and unify path configurations
- Introduced a 30-minute timeout mechanism to prevent the script from getting stuck in invalid states, with configurable timeout settings.
- Unified path configurations across the project to enhance maintainability and avoid hardcoded paths.
- Updated documentation and flowcharts to reflect the new timeout feature and improved path management.
- Fixed issues with template and screenshot path configurations to ensure consistency across the project.
2025-12-28 14:47:31 +08:00