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.
This commit is contained in:
1 parent
a0162e3b81
commit
b9849b9f5a
9 files changed
+264
-344
No files matched your search
@@ -43,10 +43,15 @@
|
||||
- 🔧 优化:路径配置统一化
|
||||
- 使用 `path_config.py` 统一管理所有文件路径
|
||||
- 简化路径配置逻辑,提高代码可维护性
|
||||
- 🔧 优化:行为日志系统
|
||||
- 修复行为日志路径问题,统一使用 `path_config.get_actions_log_path()`
|
||||
- 修复 GUI 和 Web GUI 中的日志读取路径
|
||||
- 实现完整的行为日志查看器组件
|
||||
- 📝 更新:完善文档和流程图
|
||||
- 更新流程图以反映30分钟超时检查
|
||||
- 修正阶段诊断步骤编号
|
||||
- 完善预约回退子流程图
|
||||
- 更新代码结构说明,反映模块化重构
|
||||
|
||||
### V3.3.2 (2025-12-25)
|
||||
|
||||
@@ -294,35 +299,46 @@ pytest tests/unit/test_example.py::test_some_behavior -q
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────┐
|
||||
│ GUI / Web GUI / CLI │
|
||||
│ (用户界面层) │
|
||||
│ GUI / Web GUI / CLI (用户界面层) │
|
||||
│ gui_app.py / web_gui.py / run_cli.py │
|
||||
└──────────────┬──────────────────────────┘
|
||||
│
|
||||
┌──────────────▼──────────────────────────┐
|
||||
│ douyin_fudai.py │
|
||||
│ (核心调度器 - 主流程控制) │
|
||||
│ douyin/core/douyin_fudai.py │
|
||||
│ fudai_analyse (Mixin 组合模式) │
|
||||
│ (核心调度器 - 主流程控制) │
|
||||
└──────────────┬──────────────────────────┘
|
||||
│
|
||||
┌──────────┼──────────┐
|
||||
│ │ │
|
||||
┌───▼───┐ ┌───▼───┐ ┌───▼───┐
|
||||
│阶段诊断│ │福袋核心│ │弹窗处理│
|
||||
│stage │ │core │ │popups │
|
||||
│stage/ │ │fudai/ │ │handlers│
|
||||
└───────┘ └───────┘ └───────┘
|
||||
│ │ │
|
||||
└──────────┼──────────┘
|
||||
│
|
||||
┌──────────────▼──────────────────────────┐
|
||||
│ Underlying_Operations.py │
|
||||
│ (底层操作封装 - ADB/OCR) │
|
||||
│ operations/ (底层操作模块) │
|
||||
│ device / screenshot / ocr │
|
||||
└──────────────┬──────────────────────────┘
|
||||
│
|
||||
┌──────────────▼──────────────────────────┐
|
||||
│ ADB / PaddleOCR │
|
||||
│ (系统底层接口) │
|
||||
│ path_config.py (路径配置) │
|
||||
│ 统一管理所有文件路径 │
|
||||
└──────────────┬──────────────────────────┘
|
||||
│
|
||||
┌──────────────▼──────────────────────────┐
|
||||
│ ADB / PaddleOCR (系统底层接口) │
|
||||
└─────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**设计特点**:
|
||||
- **模块化设计**:功能按模块划分,便于维护和扩展
|
||||
- **Mixin 模式**:核心类使用 Mixin 组合,功能解耦
|
||||
- **路径统一管理**:所有路径通过 `path_config.py` 统一配置
|
||||
- **日志系统**:统一日志和行为日志分离,便于调试和分析
|
||||
|
||||
---
|
||||
|
||||
## 💻 环境要求与安装
|
||||
@@ -852,77 +868,160 @@ python run_cli.py \
|
||||
|
||||
## 📁 代码结构
|
||||
|
||||
### 核心模块
|
||||
### 项目架构
|
||||
|
||||
#### `douyin_fudai.py`
|
||||
项目采用模块化设计,主要代码位于 `douyin/` 目录下,按功能划分为多个子模块:
|
||||
|
||||
```
|
||||
douyin_guaji-main/
|
||||
├── douyin/ # 核心业务逻辑模块
|
||||
│ ├── core/ # 核心调度和主流程
|
||||
│ │ ├── douyin_fudai.py # 主类 fudai_analyse(Mixin 组合)
|
||||
│ │ ├── douyin_main_flow.py # 主流程控制器
|
||||
│ │ ├── douyin_flow_control.py # 流程控制
|
||||
│ │ └── fudai_modules/ # 功能模块(Mixin)
|
||||
│ │ ├── fudai_navigation.py # 导航功能
|
||||
│ │ ├── fudai_stage_detection.py # 阶段检测
|
||||
│ │ ├── fudai_popup_handler.py # 弹窗处理
|
||||
│ │ ├── fudai_lottery_result.py # 抽奖结果
|
||||
│ │ ├── fudai_room_utils.py # 直播间工具
|
||||
│ │ └── fudai_main_logic.py # 主逻辑
|
||||
│ ├── detection/ # 检测模块
|
||||
│ │ ├── douyin_detection.py # 综合检测逻辑
|
||||
│ │ └── douyin_pixel.py # 像素检测
|
||||
│ ├── stage/ # 阶段诊断模块
|
||||
│ │ ├── douyin_stage.py # 阶段诊断核心
|
||||
│ │ └── douyin_stage_handler.py # 阶段处理
|
||||
│ ├── fudai/ # 福袋相关模块
|
||||
│ │ ├── douyin_fudai_core.py # 福袋核心逻辑
|
||||
│ │ ├── douyin_fudai_detail.py # 福袋详情
|
||||
│ │ ├── douyin_fudai_finder.py # 福袋查找
|
||||
│ │ └── core/ # 福袋核心子模块
|
||||
│ ├── handlers/ # 处理器模块
|
||||
│ │ ├── douyin_popup_handler.py # 弹窗处理
|
||||
│ │ ├── douyin_screenshot_handler.py # 截图处理
|
||||
│ │ └── douyin_swipe_handler.py # 滑动处理
|
||||
│ ├── reservation/ # 预约模块
|
||||
│ │ ├── douyin_reservation_logic.py # 预约逻辑
|
||||
│ │ └── douyin_reservation_handler.py # 预约处理
|
||||
│ ├── logging/ # 日志模块
|
||||
│ │ ├── douyin_logging.py # 日志系统
|
||||
│ │ ├── douyin_logging_wrapper.py # 日志包装器
|
||||
│ │ └── douyin_logger.py # 日志器
|
||||
│ ├── other/ # 其他功能模块
|
||||
│ │ ├── douyin_yanghao.py # 养号功能
|
||||
│ │ ├── douyin_robot.py # 人机验证
|
||||
│ │ └── douyin_popups.py # 弹窗检测
|
||||
│ └── utils/ # 工具模块
|
||||
│ ├── douyin_config.py # 配置工具
|
||||
│ └── douyin_helpers.py # 辅助函数
|
||||
├── gui/ # GUI 界面模块
|
||||
│ ├── gui_app.py # 桌面 GUI
|
||||
│ ├── web_gui.py # Web GUI 服务
|
||||
│ └── components/ # GUI 组件
|
||||
├── operations/ # 底层操作模块
|
||||
│ ├── device_operations.py # 设备操作
|
||||
│ ├── screenshot_operations.py # 截图操作
|
||||
│ └── ocr_operations.py # OCR 操作
|
||||
├── fudai_detail_modules/ # 福袋详情页模块
|
||||
├── path_config.py # 路径配置统一管理
|
||||
├── Underlying_Operations.py # 底层操作封装(兼容旧代码)
|
||||
└── run_cli.py # 命令行入口
|
||||
```
|
||||
|
||||
### 核心模块说明
|
||||
|
||||
#### `douyin/core/douyin_fudai.py`
|
||||
- **职责**:核心调度器,主流程控制
|
||||
- **主要类**:`fudai_analyse`
|
||||
- **主要类**:`fudai_analyse`(使用 Mixin 模式组合功能)
|
||||
- **设计模式**:Mixin 组合模式,将功能拆分到 `fudai_modules/` 下的各个模块
|
||||
- **主要方法**:
|
||||
- `fudai_choujiang()`:主循环入口
|
||||
- `run_once_basic()`:单次循环执行
|
||||
- `load_config()`:加载配置
|
||||
- `_diagnose_stage_from_current_screen()`:阶段诊断入口
|
||||
- `_check_in_live_room_by_icon()`:直播间检测
|
||||
|
||||
#### `douyin_stage.py`
|
||||
- **职责**:阶段诊断模块
|
||||
- **主要函数**:`diagnose_stage_from_current_screen()`
|
||||
- **检测阶段**:
|
||||
#### `douyin/stage/` - 阶段诊断模块
|
||||
- **`douyin_stage.py`**:阶段诊断核心逻辑
|
||||
- `diagnose_stage_from_current_screen()`:综合诊断函数
|
||||
- 支持的阶段类型:
|
||||
- `IN_LIVE_ROOM`:直播间
|
||||
- `RECOMMEND_PAGE`:推荐页
|
||||
- `FOLLOW_LIST`:关注列表
|
||||
- `LIVE_LIST`:直播列表
|
||||
- `FUDai_DETAIL`:福袋详情页
|
||||
- `FUDai_RESULT`:抽奖结果页
|
||||
- `LIVE_LIST`:直播列表
|
||||
- `FUDai_DETAIL`:福袋详情页
|
||||
- `FUDai_RESULT`:抽奖结果页
|
||||
- `FANSCLUB_JOIN`:粉丝团加入页
|
||||
- `LIVE_CLOSED`:直播已结束
|
||||
- `LIVE_CLOSED`:直播已结束
|
||||
- **`douyin_stage_handler.py`**:阶段处理逻辑,包括直播间检测等
|
||||
|
||||
#### `douyin_pixel.py`
|
||||
- **职责**:像素检测模块
|
||||
- **主要功能**:
|
||||
#### `douyin/detection/` - 检测模块
|
||||
- **`douyin_pixel.py`**:像素检测模块
|
||||
- 检测弹窗背景颜色
|
||||
- 检测按钮区域颜色
|
||||
- 并行采集像素特征
|
||||
- **`douyin_detection.py`**:综合检测逻辑,整合像素、模板、OCR 检测
|
||||
|
||||
#### `douyin_fudai_core.py`
|
||||
- **职责**:福袋核心业务逻辑
|
||||
- **主要函数**:
|
||||
#### `douyin/fudai/` - 福袋模块
|
||||
- **`douyin_fudai_core.py`**:福袋核心业务逻辑
|
||||
- `get_fudai_contain()`:获取福袋信息
|
||||
- `check_contain()`:检查福袋内容
|
||||
- `attend_choujiang()`:参与抽奖
|
||||
- `check_lucky_draw_result()`:检查开奖结果
|
||||
- `get_reward()`:领取奖品
|
||||
- **`douyin_fudai_detail.py`**:福袋详情页处理
|
||||
- **`douyin_fudai_finder.py`**:福袋图标查找
|
||||
- **`core/`**:福袋核心子模块
|
||||
- `fudai_filter.py`:福袋筛选逻辑
|
||||
- `fudai_result_checker.py`:开奖结果检查
|
||||
- `fudai_attend.py`:参与抽奖逻辑
|
||||
|
||||
#### `douyin_popups.py`
|
||||
- **职责**:弹窗检测与处理
|
||||
- **主要函数**:
|
||||
#### `douyin/handlers/` - 处理器模块
|
||||
- **`douyin_popup_handler.py`**:弹窗检测与处理
|
||||
- `check_coupon_popup()`:检测优惠券弹窗
|
||||
- `check_shopping_redpacket_popup()`:检测购物红包弹窗
|
||||
- **`douyin_screenshot_handler.py`**:截图处理和管理
|
||||
- **`douyin_swipe_handler.py`**:滑动操作处理
|
||||
|
||||
#### `douyin_robot.py`
|
||||
- **职责**:人机验证处理
|
||||
- **主要函数**:
|
||||
- `check_have_robot_analyse()`:检测人机验证
|
||||
- `deal_robot_analyse()`:处理人机验证
|
||||
- `deal_swipe_robot_analyse()`:处理滑块验证
|
||||
|
||||
#### `douyin_yanghao.py`
|
||||
- **职责**:推荐页养号逻辑
|
||||
- **主要功能**:
|
||||
- 点赞操作
|
||||
- 收藏操作
|
||||
- 评论操作
|
||||
- 关键词触发
|
||||
|
||||
#### `douyin_reservation.py`
|
||||
- **职责**:高价值福袋预约管理
|
||||
- **主要功能**:
|
||||
#### `douyin/reservation/` - 预约模块
|
||||
- **`douyin_reservation_logic.py`**:高价值福袋预约管理
|
||||
- 预约记录管理
|
||||
- 高价值直播间记录
|
||||
- 状态持久化
|
||||
- **`douyin_reservation_handler.py`**:预约处理逻辑
|
||||
|
||||
#### `douyin/logging/` - 日志模块
|
||||
- **`douyin_logging.py`**:统一日志系统
|
||||
- **`douyin_logging_wrapper.py`**:日志包装器,支持行为日志(actions.log)
|
||||
- **`douyin_logger.py`**:日志器实现
|
||||
|
||||
#### `douyin/other/` - 其他功能模块
|
||||
- **`douyin_yanghao.py`**:推荐页养号逻辑
|
||||
- 点赞、收藏、评论操作
|
||||
- 关键词触发
|
||||
- **`douyin_robot.py`**:人机验证处理
|
||||
- `check_have_robot_analyse()`:检测人机验证
|
||||
- `deal_robot_analyse()`:处理人机验证
|
||||
- **`douyin_popups.py`**:弹窗检测(兼容旧代码)
|
||||
|
||||
#### `path_config.py` - 路径配置模块
|
||||
- **职责**:统一管理所有文件路径
|
||||
- **主要函数**:
|
||||
- `get_project_root()`:项目根目录
|
||||
- `get_assets_dir()`:模板图片目录
|
||||
- `get_pic_dir()`:截图目录
|
||||
- `get_screenshot_path()`:截图文件路径
|
||||
- `get_logs_dir()`:日志目录
|
||||
- `get_actions_log_path()`:行为日志路径
|
||||
- `get_state_dir()`:状态文件目录
|
||||
- `get_reservations_path()`:预约状态文件路径
|
||||
- **优势**:统一路径管理,便于维护和迁移
|
||||
|
||||
#### `operations/` - 底层操作模块
|
||||
- **`device_operations.py`**:设备连接和操作
|
||||
- **`screenshot_operations.py`**:截图获取和处理
|
||||
- **`ocr_operations.py`**:OCR 识别操作
|
||||
|
||||
#### `Underlying_Operations.py`
|
||||
- **职责**:底层操作封装
|
||||
- **职责**:底层操作封装(兼容旧代码)
|
||||
- **主要类**:`underlying_operations`
|
||||
- **主要方法**:
|
||||
- `get_screenshot()`:获取截图
|
||||
@@ -1000,7 +1099,8 @@ python run_cli.py \
|
||||
|
||||
#### `logs/`
|
||||
- **内容**:
|
||||
- `unified.log`:统一日志文件
|
||||
- `unified.log`:统一日志文件(所有日志)
|
||||
- `actions.log`:行为日志文件(关键操作记录,用于性能分析和调试)
|
||||
|
||||
#### `state/`
|
||||
- **内容**:
|
||||
@@ -1283,9 +1383,10 @@ python run_cli.py \
|
||||
### Q9: 如何查看运行日志?
|
||||
|
||||
**A**:
|
||||
1. GUI/Web GUI 界面实时显示日志
|
||||
2. 查看 `logs/unified.log` 文件
|
||||
3. 命令行运行时直接在终端查看
|
||||
1. **统一日志**:查看 `logs/unified.log` 文件,包含所有运行日志
|
||||
2. **行为日志**:查看 `logs/actions.log` 文件,包含关键操作记录(用于性能分析)
|
||||
3. **GUI/Web GUI**:界面实时显示日志,支持筛选和搜索
|
||||
4. **命令行**:运行时直接在终端查看
|
||||
|
||||
### Q10: 脚本卡住了怎么办?
|
||||
|
||||
|
||||
Reference in new issue
Block a user