fix: 兼容 ocr_plugin 的嵌套目录结构

This commit is contained in:
HONOR
2026-09-16 13:06:18 +08:00
parent 926a5b7dd1
commit edb390e4f8
+14 -7
View File
@@ -139,14 +139,21 @@ def export_pdf_image_tables_local(excel_app, file_path, excel_path, pages_str, l
import os
import sys
# 查找插件路径
plugin_exe = os.path.join(os.getcwd(), "ocr_plugin", "ocr_worker.exe")
if not os.path.exists(plugin_exe):
# 尝试查找相对 main.py / exe 的路径
app_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
plugin_exe = os.path.join(app_dir, "ocr_plugin", "ocr_worker.exe")
# 查找插件路径 (支持直接在 ocr_plugin 下,也支持嵌套在 ocr_worker 下)
plugin_paths = [
os.path.join(os.getcwd(), "ocr_plugin", "ocr_worker.exe"),
os.path.join(os.getcwd(), "ocr_plugin", "ocr_worker", "ocr_worker.exe"),
os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "ocr_plugin", "ocr_worker.exe"),
os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "ocr_plugin", "ocr_worker", "ocr_worker.exe")
]
if not os.path.exists(plugin_exe):
plugin_exe = None
for p in plugin_paths:
if os.path.exists(p):
plugin_exe = p
break
if not plugin_exe:
raise Exception("未检测到本地 AI 插件!请下载 'ocr_plugin' 文件夹并放置在程序同一目录下。")
if log_func: