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

+1 -1
View File
@@ -19,7 +19,7 @@ from .screenshot_operations import (
# 从原文件导入以保持向后兼容
# TODO: 逐步迁移后改为从子模块导入
from Underlying_Operations import (
from douyin.core.underlying_operations import (
_safe_replace_file,
_ensure_parent_dir,
_mirror_screenshot_to_external,
+1 -1
View File
@@ -9,7 +9,7 @@ from typing import Any, Optional
# 临时导入:从原文件导入,后续会逐步迁移
# TODO: 迁移完成后,移除此导入并在此文件中实现
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
# 导出设备操作相关方法
# TODO: 实现这些函数后添加到__all__列表中
+1 -1
View File
@@ -9,7 +9,7 @@ from typing import Any, Optional, Tuple
# 临时导入:从原文件导入,后续会逐步迁移
# TODO: 迁移完成后,移除此导入并在此文件中实现
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
# 导出图像处理相关方法
# TODO: 实现这些函数后添加到__all__列表中
+3 -3
View File
@@ -185,7 +185,7 @@ def _ensure_ocr():
def analyse_pic_word(picname, change_color=0, pic_path=None):
"""文字OCR识别(向后兼容接口)"""
# 使用全局复用的 underlying_operations 实例,避免每次调用都初始化 OCR(耗时)
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
global _UNDERLYING_OPS_SINGLETON # type: ignore[name-defined]
try:
_UNDERLYING_OPS_SINGLETON # type: ignore[name-defined]
@@ -197,7 +197,7 @@ def analyse_pic_word(picname, change_color=0, pic_path=None):
def analyse_pic_digits(picname, change_color=1, pic_path=None):
"""数字OCR识别(向后兼容接口)"""
# 使用全局复用的 underlying_operations 实例,避免每次调用都初始化 OCR(耗时)
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
global _UNDERLYING_OPS_SINGLETON # type: ignore[name-defined]
try:
_UNDERLYING_OPS_SINGLETON # type: ignore[name-defined]
@@ -209,7 +209,7 @@ def analyse_pic_digits(picname, change_color=1, pic_path=None):
def extract_ocr_content(content=[], return_confidence=False):
"""提取OCR内容(向后兼容接口)"""
# 使用全局复用的 underlying_operations 实例
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
global _UNDERLYING_OPS_SINGLETON # type: ignore[name-defined]
try:
_UNDERLYING_OPS_SINGLETON # type: ignore[name-defined]
+6 -6
View File
@@ -13,7 +13,7 @@ import time
from datetime import datetime
from typing import Optional
from Underlying_Operations import _safe_replace_file, _mirror_screenshot_to_external
from douyin.core.underlying_operations import _safe_replace_file, _mirror_screenshot_to_external
# 日志节流:当后台服务不可用并回退到直接截图时,避免每次都打印相同的日志
_last_service_fallback_log_ts: float = 0.0
@@ -87,7 +87,7 @@ class ScreenshotOperations:
direct_start = time.time()
if path == "pic":
try:
import path_config
from douyin.core import path_config
out_dir = path_config.get_pic_dir()
except Exception: # type: ignore
# 回退到旧路径(向后兼容)
@@ -305,10 +305,10 @@ class ScreenshotOperations:
"""
# 搜索目录优先级
try:
import path_config
from douyin.core import path_config
pic_dir = path_config.get_pic_dir()
except Exception:
import path_config
from douyin.core import path_config
pic_dir = path_config.get_pic_dir()
search_dirs = []
@@ -340,7 +340,7 @@ class ScreenshotOperations:
"""裁剪图片:保持与原 fudai1.cut_pic 相同的坐标语义(1080x2400 基准)。"""
# 这里应该实现图片裁剪逻辑
# 暂时从原文件导入以保持功能
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
instance = underlying_operations()
return instance.cut_pic(left_up, right_down, target, name)
@@ -348,7 +348,7 @@ class ScreenshotOperations:
"""保存奖励图片"""
# 这里应该实现奖励图片保存逻辑
# 暂时从原文件导入以保持功能
from Underlying_Operations import underlying_operations
from douyin.core.underlying_operations import underlying_operations
instance = underlying_operations()
return instance.save_reward_pic(device_id)
+1 -1
View File
@@ -14,7 +14,7 @@ import threading
import time
from typing import Optional
from datetime import datetime
import path_config
from douyin.core import path_config
from operations.screenshot_operations import ScreenshotOperations
+1 -1
View File
@@ -7,7 +7,7 @@ import threading
import time
from typing import Optional
from datetime import datetime
import path_config
from douyin.core import path_config
from operations.screenshot_operations import ScreenshotOperations