diff --git a/.gitignore b/.gitignore index 29076fb..57a6f1a 100644 --- a/.gitignore +++ b/.gitignore @@ -85,6 +85,7 @@ temp/ config/*.json !config/README.md *.bak +*.bak_* *.backup *.orig *.swp diff --git a/README.md b/README.md index ffbe361..7068f6c 100644 --- a/README.md +++ b/README.md @@ -399,10 +399,10 @@ pip install pillow paddlepaddle paddleocr numpy opencv-python # 如果 paddlepaddle 安装失败,可以尝试: # CPU 版本(推荐) -pip install paddlepaddle==2.5.2 -i https://pypi.tuna.tsinghua.edu.cn/simple +pip install "paddlepaddle>=3.0.0" -i https://pypi.tuna.tsinghua.edu.cn/simple # 或 GPU 版本(需要 CUDA) -pip install paddlepaddle-gpu==2.5.2 -i https://pypi.tuna.tsinghua.edu.cn/simple +pip install "paddlepaddle-gpu>=3.0.0" -i https://pypi.tuna.tsinghua.edu.cn/simple # 安装 GUI 依赖(可选) pip install ttkbootstrap diff --git a/bin/run_cli.py b/bin/run_cli.py index f1bda67..f21b991 100644 --- a/bin/run_cli.py +++ b/bin/run_cli.py @@ -77,9 +77,6 @@ def _load_local_shim(mod_name: str, rel_path: str) -> None: # 1) 先加载本地 shim 模块,确保后续 import 优先使用这些实现 _load_local_shim("douyin_text_utils", "douyin/utils/douyin_text_utils.py") _load_local_shim("douyin_swipe_ops", "douyin/handlers/douyin_swipe_ops.py") -_load_local_shim( - "douyin_reservation_ops", "douyin/reservation/douyin_reservation_ops.py" -) # 2) 再把完整逻辑所在目录追加到 sys.path,供 `douyin_fudai` 等模块导入 try: diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index 85a4bbf..715f7d8 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -291,9 +291,13 @@ class fudai_analyse: self.queue_full_waiting_at_earliest: bool = False # 预约队列状态文件(供 WebGUI / 其他进程查看) - self._reservations_state_path: str = os.path.join( - os.path.dirname(__file__), "state", "reservations.json" - ) + try: + from douyin.core import path_config as _pc + self._reservations_state_path: str = _pc.get_reservations_path() + except Exception: + self._reservations_state_path = os.path.join( + os.path.dirname(__file__), "state", "reservations.json" + ) # 运行时直播间标题和位置映射表(用于回退校验) # 格式:{room_pos: {"title": str, "title_raw": str, "has_fudai": bool, "fudai_content": str, "fudai_detail": Any}} @@ -301,7 +305,7 @@ class fudai_analyse: # 每次重新运行时丢弃磁盘上旧的映射表,确保只记录本次运行的结果。 # 同时尝试删除旧的导出文件(JSON/CSV/MD),以避免 GUI 在未写入新数据前显示过期内容。 try: - state_dir = os.path.join(os.path.dirname(__file__), "state") + state_dir = os.path.dirname(self._reservations_state_path) state_path = os.path.join(state_dir, "room_pos_map.json") csv_path = os.path.join(state_dir, "room_pos_map.csv") md_path = os.path.join(state_dir, "room_pos_map.md") diff --git a/douyin/core/path_config.py b/douyin/core/path_config.py index 02557e2..5d64225 100644 --- a/douyin/core/path_config.py +++ b/douyin/core/path_config.py @@ -61,7 +61,11 @@ def get_state_dir() -> str: def get_reservations_path() -> str: - """返回预约队列状态文件的路径(实际位置在douyin/core/state/reservations.json)""" + """返回预约队列状态文件的路径(实际位置:douyin/core/state/reservations.json)。 + + 该文件由 fudai_analyse 在 douyin/core/douyin_fudai.py 中写入, + 供 WebGUI / 桌面 GUI 跨进程读取。 + """ return os.path.join(PROJECT_ROOT, "douyin", "core", "state", "reservations.json") diff --git a/douyin/reservation/douyin_reservation_ops.py b/douyin/reservation/douyin_reservation_ops.py deleted file mode 100644 index e69de29..0000000 diff --git a/gui/components/mapping_table.py b/gui/components/mapping_table.py index 4bc9ca4..b976f85 100644 --- a/gui/components/mapping_table.py +++ b/gui/components/mapping_table.py @@ -191,7 +191,6 @@ def create_mapping_tab(root: tk.Tk, notebook: ttk.Notebook, cfg: dict) -> ttk.Fr possible_paths = [ os.path.join(base_dir, "douyin", "core", "state", "room_pos_map.json"), os.path.join(base_dir, "douyin", "core", "state", "reservations.json"), - os.path.join(base_dir, "douyin", "state", "room_pos_map.json"), os.path.join(os.getcwd(), "douyin", "core", "state", "room_pos_map.json"), ] diff --git a/gui/components/mapping_utils.py b/gui/components/mapping_utils.py index 25188ff..6cb8cb7 100644 --- a/gui/components/mapping_utils.py +++ b/gui/components/mapping_utils.py @@ -17,7 +17,6 @@ def load_reservations(base_dir: str | None = None) -> Dict[int, Any]: reservations_data: Dict[int, Any] = {} reservations_paths = [ os.path.join(base_dir, "douyin", "core", "state", "reservations.json"), - os.path.join(base_dir, "douyin", "state", "reservations.json"), os.path.join(os.getcwd(), "douyin", "core", "state", "reservations.json"), ] for res_path in reservations_paths: diff --git a/gui/web_gui.py b/gui/web_gui.py index 4ff9ebe..c4e6ef4 100644 --- a/gui/web_gui.py +++ b/gui/web_gui.py @@ -938,11 +938,14 @@ class ProcRunner: else os.getcwd() ), "douyin", + "core", "state", "reservations.json", ) else: - path = os.path.join(os.getcwd(), "douyin", "state", "reservations.json") + path = os.path.join( + os.getcwd(), "douyin", "core", "state", "reservations.json" + ) try: if os.path.exists(path): with open(path, "r", encoding="utf-8") as f: diff --git a/requirements-minimal.txt b/requirements-minimal.txt index 148f44d..d18f66d 100644 --- a/requirements-minimal.txt +++ b/requirements-minimal.txt @@ -11,12 +11,12 @@ numpy>=1.20.0 # 计算机视觉库 opencv-python>=4.5.0 -# OCR识别 - 只需一个OCR引擎即可 -# 选项1: PaddleOCR(推荐,中文识别效果好) -paddleocr>=2.7.0 -paddlepaddle>=2.5.0,<3.0.0 +# OCR识别(与 requirements.txt 保持一致) +# PaddleOCR 3.0+ 需要 PaddlePaddle 3.0+ +paddleocr>=3.0.0 +paddlepaddle>=3.0.0 -# 选项2: EasyOCR(更快,但识别准确度可能略低) +# 选项2:EasyOCR(更快,但识别准确度可能略低) # easyocr>=1.7.0 # GUI依赖(可选)