From 71f365335434c149dc3364477642ed6634f02b86 Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 21 May 2026 10:17:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=9B=9E=E4=B8=8A=E6=AC=A1=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E4=B8=A2=E5=A4=B1=E7=9A=84=E5=85=B3=E9=94=AE=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=BF=AE=E5=A4=8D=20+=20.gitignore=20=E8=A1=A5?= =?UTF-8?q?=E5=BC=BA=20+=20=E4=BE=9D=E8=B5=96=E7=89=88=E6=9C=AC=E5=AF=B9?= =?UTF-8?q?=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上次冲突解决时跳过了 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 --- .gitignore | 1 + README.md | 4 ++-- bin/run_cli.py | 3 --- douyin/core/douyin_fudai.py | 12 ++++++++---- douyin/core/path_config.py | 6 +++++- douyin/reservation/douyin_reservation_ops.py | 0 gui/components/mapping_table.py | 1 - gui/components/mapping_utils.py | 1 - gui/web_gui.py | 5 ++++- requirements-minimal.txt | 10 +++++----- 10 files changed, 25 insertions(+), 18 deletions(-) delete mode 100644 douyin/reservation/douyin_reservation_ops.py 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 451e99d..a55b4fa 100644 --- a/gui/web_gui.py +++ b/gui/web_gui.py @@ -985,11 +985,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依赖(可选)