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>
This commit is contained in:
CodexandClaude Opus 4.5 committed 2026-05-21 00:23:14 +08:00
1 parent e3e399da70
commit 8fe7ff0585
51 files changed
+136 -132

No files matched your search

+2 -2
View File
@@ -63,11 +63,11 @@ def create_actions_log_viewer(
"""刷新行为日志:读取 logs/actions.log 的尾部若干行,在 GUI 中展示关键行为日志(支持简单关键字筛选)。"""
# 使用统一的路径配置
try:
import path_config
from douyin.core import path_config
path = path_config.get_actions_log_path()
except Exception:
# 回退到旧路径(向后兼容)
import path_config
from douyin.core import path_config
path = path_config.get_actions_log_path()
try:
+1 -1
View File
@@ -9,7 +9,7 @@ from datetime import datetime, timedelta
import re
try:
from path_config import get_error_log_path # type: ignore[assignment]
from douyin.core.path_config import get_error_log_path # type: ignore[assignment]
HAS_LOGGING = True
except ImportError:
# 如果导入失败,提供占位符函数
+26 -26
View File
@@ -32,7 +32,7 @@ from gui.gui_core import (
read_config,
write_config,
)
from path_config import get_logs_dir
from douyin.core.path_config import get_logs_dir
from gui.components.mapping_table import create_mapping_tab
# 导入日志颜色配置模块
@@ -188,7 +188,7 @@ def main():
# 获取日志文件路径配置
log_path = cfg.get("log_unified_path") or "logs/unified.log"
if not os.path.isabs(log_path):
from path_config import PROJECT_ROOT
from douyin.core.path_config import PROJECT_ROOT
log_path = os.path.join(PROJECT_ROOT, log_path)
@@ -3037,7 +3037,7 @@ def main():
# 在后台线程中执行截图和OCR识别,避免阻塞GUI
def screenshot_thread():
try:
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
# 使用模块级别导入的 Image 与 os,避免重复导入导致 Pylance 警告
@@ -3059,12 +3059,12 @@ def main():
# 读取截图以获取实际尺寸
try:
from path_config import get_screenshot_path
from douyin.core.path_config import get_screenshot_path
screenshot_path = get_screenshot_path()
except Exception:
# 回退到旧路径(向后兼容)
import path_config
from douyin.core import path_config
screenshot_path = path_config.get_screenshot_path()
if not os.path.exists(screenshot_path):
@@ -3338,11 +3338,11 @@ def main():
if show_screenshot_var.get():
try:
try:
from path_config import get_screenshot_path
from douyin.core.path_config import get_screenshot_path
screenshot_path = get_screenshot_path()
except Exception:
import path_config
from douyin.core import path_config
screenshot_path = path_config.get_screenshot_path()
@@ -3498,11 +3498,11 @@ def main():
# update image
try:
try:
from path_config import get_screenshot_path
from douyin.core.path_config import get_screenshot_path
screenshot_path = get_screenshot_path()
except Exception:
import path_config
from douyin.core import path_config
screenshot_path = path_config.get_screenshot_path()
@@ -3862,12 +3862,12 @@ def main():
preview_top.pack(fill=X, padx=10, pady=10)
try:
from path_config import get_pic_dir
from douyin.core.path_config import get_pic_dir
images_dir = get_pic_dir()
except Exception:
# 回退到旧路径(向后兼容)
import path_config
from douyin.core import path_config
images_dir = path_config.get_pic_dir()
@@ -4958,12 +4958,12 @@ def main():
def refresh_reservations():
try:
from path_config import get_reservations_path
from douyin.core.path_config import get_reservations_path
path = get_reservations_path()
except Exception:
# 回退到旧路径(向后兼容)
import path_config
from douyin.core import path_config
path = path_config.get_reservations_path()
try:
@@ -5233,12 +5233,12 @@ def main():
def refresh_high_value_rooms():
try:
from path_config import get_high_value_rooms_path
from douyin.core.path_config import get_high_value_rooms_path
path = get_high_value_rooms_path()
except Exception:
# 回退到旧路径(向后兼容)
import path_config
from douyin.core import path_config
path = path_config.get_high_value_rooms_path()
try:
@@ -5322,13 +5322,13 @@ def main():
"""读取 logs/actions.log 的尾部若干行,在 GUI 中展示关键行为日志(支持简单关键字筛选)。"""
# 使用统一的路径配置
try:
from path_config import get_actions_log_path
from douyin.core.path_config import get_actions_log_path
path = get_actions_log_path()
except Exception:
# 回退到旧路径(向后兼容)
# 修正路径:GUI应该读取根目录的logs/actions.log
import path_config
from douyin.core import path_config
path = path_config.get_actions_log_path()
try:
@@ -5582,11 +5582,11 @@ def main():
def scan_win_images():
"""扫描中奖截图目录"""
try:
from path_config import get_pic_dir
from douyin.core.path_config import get_pic_dir
pic_dir = get_pic_dir()
except Exception:
import path_config
from douyin.core import path_config
pic_dir = path_config.get_pic_dir()
@@ -5697,11 +5697,11 @@ def main():
def open_win_folder():
"""打开中奖截图目录"""
try:
from path_config import get_pic_dir
from douyin.core.path_config import get_pic_dir
pic_dir = get_pic_dir()
except Exception:
import path_config
from douyin.core import path_config
pic_dir = path_config.get_pic_dir()
@@ -5735,11 +5735,11 @@ def main():
def load_false_positives():
"""加载误识别记录"""
try:
from path_config import get_pic_dir
from douyin.core.path_config import get_pic_dir
pic_dir = get_pic_dir()
except Exception:
import path_config
from douyin.core import path_config
pic_dir = path_config.get_pic_dir()
@@ -5767,11 +5767,11 @@ def main():
def save_false_positives():
"""保存误识别记录"""
try:
from path_config import get_pic_dir
from douyin.core.path_config import get_pic_dir
pic_dir = get_pic_dir()
except Exception:
import path_config
from douyin.core import path_config
pic_dir = path_config.get_pic_dir()
@@ -5849,7 +5849,7 @@ def main():
if __name__ == "__main__":
try:
from version import print_version_banner
from douyin.core.version import print_version_banner
print_version_banner("gui_app")
except Exception:
+1 -1
View File
@@ -10,7 +10,7 @@ import time
from dataclasses import dataclass
from typing import Optional
import path_config
from douyin.core import path_config
CONFIG_PATH = path_config.get_config_path()
+4 -4
View File
@@ -17,7 +17,7 @@ project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_root not in sys.path:
sys.path.insert(0, project_root)
import path_config
from douyin.core import path_config
BASE_DIR = path_config.PROJECT_ROOT
CONFIG_PATH = path_config.get_config_path()
@@ -1359,7 +1359,7 @@ class ProcRunner:
# 启动时自动截图
if device_id:
try:
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
ops = underlying_operations()
self._append_log(f"[启动] 自动截图: device={device_id}")
@@ -2203,7 +2203,7 @@ class Handler(BaseHTTPRequestHandler):
body = self._read_json()
device_id = str(body.get("device_id") or "").strip()
try:
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
ops = underlying_operations()
result = ops.get_screenshot(device_id, use_service=False)
@@ -2249,7 +2249,7 @@ def main() -> int:
if __name__ == "__main__":
try:
from version import print_version_banner
from douyin.core.version import print_version_banner
print_version_banner("web_gui")
except Exception: