refactor: 重构为纯云端版本,移除所有本地ML库依赖

重大更改:
1. requirements.txt - 移除 paddleocr/paddlepaddle,使用纯 API 版本
2. src/core/ocr.py - 完全重写
   - 移除 PaddleOCREngine 和 ensure_paddleocr()
   - 移除 numpy 依赖(不再需要)
   - 实现完整的 CloudOCREngine
   - 支持百度/腾讯/阿里云 OCR API
   - 添加自定义 API 支持
3. src/config/settings.py - 简化 OCR 配置
   - OCRMode 枚举仅保留 CLOUD
   - OCRConfig 添加 provider 字段
4. src/core/__init__.py - 移除 PaddleOCREngine 导出
5. src/gui/main_window.py - 移除 ensure_paddleocr 导入
6. build.bat/build.sh - 简化构建参数
   - 移除所有 ML 库的 --exclude-module
   - 移除 pyi_hooks 依赖
   - 添加 openai/anthropic hidden-import

测试:
- ✓ 所有核心模块导入成功
- ✓ 没有 PaddleOCR 相关错误

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
congsh
2026-02-12 13:42:46 +08:00
parent 6fc126b0fe
commit 313e1f40d8
7 changed files with 312 additions and 351 deletions

View File

@@ -31,7 +31,6 @@ class AIProvider(str, Enum):
class OCRMode(str, Enum):
"""OCR 模式枚举"""
LOCAL = "local" # 本地 PaddleOCR
CLOUD = "cloud" # 云端 OCR API
@@ -80,11 +79,12 @@ class AIConfig:
@dataclass
class OCRConfig:
"""OCR 配置"""
mode: OCRMode = OCRMode.LOCAL
"""OCR 配置 - 纯云端版本"""
mode: OCRMode = OCRMode.CLOUD
provider: str = "custom" # OCR 提供商: baidu/tencent/aliyun/custom
api_key: str = "" # 云端 OCR API key
api_secret: str = "" # 云端 OCR API secret部分服务商需要
api_endpoint: str = "" # 云端 OCR endpoint
use_gpu: bool = False # 本地 OCR 是否使用 GPU
lang: str = "ch" # 语言ch(中文), en(英文), etc.
timeout: int = 30