Files
douyin_guaji-main/path_config.py
T
Your Name 8b47b506d6 feat: Enhance 福袋 detection and reservation logic
- Updated `config.json` to introduce new settings for infinite loop mode and adjust various thresholds for 福袋 detection.
- Refined the pixel detection logic in `douyin_detection.py` to improve error handling and retry mechanisms.
- Enhanced reservation handling in `douyin_flow_control.py` to prioritize high-value 福袋 and streamline the switching process.
- Improved the GUI in `gui_app.py` to support new configuration options and ensure better user experience.
- Added new tools for analyzing 福袋 colors and comparing them with coupon colors to aid in detection accuracy.
- Updated documentation to reflect changes in configuration and usage instructions.
2025-12-20 13:32:32 +08:00

180 lines
3.4 KiB
Python

"""
路径配置模块:统一管理所有文件路径,便于整理文件夹结构而不影响代码
"""
import os
# 项目根目录(所有路径的基准)
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
def get_project_root() -> str:
"""返回项目根目录(绝对路径)"""
return PROJECT_ROOT
def get_config_path() -> str:
"""返回 config.json 的路径"""
return os.path.join(PROJECT_ROOT, "config.json")
def get_logs_dir() -> str:
"""返回 logs 目录的路径"""
return os.path.join(PROJECT_ROOT, "logs")
def get_log_file_path() -> str:
"""返回统一日志文件的路径"""
return os.path.join(PROJECT_ROOT, "logs", "unified.log")
def get_pic_dir() -> str:
"""返回 pic 目录的路径(OCR截图、临时截图等)"""
return os.path.join(PROJECT_ROOT, "pic")
def get_screenshot_path() -> str:
"""返回 screenshot.png 的路径(当前屏幕截图)"""
return os.path.join(PROJECT_ROOT, "pic", "screenshot.png")
def get_state_dir() -> str:
"""返回 state 目录的路径(状态文件)"""
return os.path.join(PROJECT_ROOT, "state")
def get_reservations_path() -> str:
"""返回预约队列状态文件的路径"""
return os.path.join(PROJECT_ROOT, "state", "reservations.json")
def get_high_value_rooms_path() -> str:
"""返回高价值房间状态文件的路径"""
return os.path.join(PROJECT_ROOT, "state", "high_value_rooms.json")
def get_assets_dir() -> str:
"""返回 assets 目录的路径(模板图片等)"""
return os.path.join(PROJECT_ROOT, "assets")
def get_like_template_path() -> str:
"""返回点赞图标模板的路径"""
return os.path.join(PROJECT_ROOT, "assets", "like.png")
def get_fav_template_path() -> str:
"""返回收藏图标模板的路径"""
return os.path.join(PROJECT_ROOT, "assets", "fav.png")
def get_desktop_template_path() -> str:
"""返回桌面图标模板的路径"""
return os.path.join(PROJECT_ROOT, "assets", "desktop.png")
def get_webui_dir() -> str:
"""返回 webui 目录的路径"""
return os.path.join(PROJECT_ROOT, "webui")
def get_pic_file_path(filename: str) -> str:
"""获取 pic 目录下指定文件的路径
Args:
filename: 文件名,可以是子目录/文件名,如 'diag_live_plaza.png' 或 'start/latest.png'
"""
return os.path.join(PROJECT_ROOT, "pic", filename)
def get_cut_pic_path(cut_pic_name: str) -> str:
"""获取裁剪后的图片路径(用于OCR)
Args:
cut_pic_name: 图片名称(不含扩展名),如 '直播广场'
"""
return os.path.join(PROJECT_ROOT, "pic", f"{cut_pic_name}.png")
def get_window_dump_path() -> str:
"""返回 window_dump.xml 的路径"""
return os.path.join(PROJECT_ROOT, "pic", "window_dump.xml")
def get_robot_verify_pic_path(save_subdir: bool = False) -> str:
"""返回机器人验证图片的路径
Args:
save_subdir: 是否在 pic/save 子目录中
"""
if save_subdir:
return os.path.join(PROJECT_ROOT, "pic", "save", "机器人验证.png")
return os.path.join(PROJECT_ROOT, "pic", "机器人验证.png")
def ensure_dir(path: str) -> None:
"""确保目录存在,不存在则创建"""
dir_path = os.path.dirname(path) if os.path.isfile(path) else path
os.makedirs(dir_path, exist_ok=True)