diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a77d0d1..0d6f066 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,22 +5,10 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -31,9 +19,9 @@
@@ -581,7 +569,7 @@
-
+
@@ -589,7 +577,7 @@
-
+
diff --git a/app.spec b/app.spec
index 5f534f2..935b508 100644
--- a/app.spec
+++ b/app.spec
@@ -1,7 +1,8 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_all
-datas = [('C:\\\\Users\\\\jxgm\\\\Desktop\\\\FileTranslate\\\\.venv\\\\Lib\\\\site-packages\\\\docling_parse\\\\pdf_resources_v2', 'docling_parse/pdf_resources_v2')]
+datas = [('C:/Users/jxgm/Desktop/FileTranslate/.venv/Lib/site-packages/docling_parse/pdf_resources_v2', 'docling_parse/pdf_resources_v2'),
+('C:/Users/jxgm\Desktop/FileTranslate/docutranslate/static', 'docutranslate/static')]
binaries = []
hiddenimports = []
tmp_ret = collect_all('easyocr')
diff --git a/docutranslate/app.py b/docutranslate/app.py
index cb4db9b..3495a9a 100644
--- a/docutranslate/app.py
+++ b/docutranslate/app.py
@@ -13,13 +13,13 @@ from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles
from docutranslate import FileTranslater
from docutranslate.logger import translater_logger
+from docutranslate.utils.resource_utils import resource_path
app = FastAPI()
-BASE_DIR = Path(__file__).resolve().parent
-STATIC_DIR=BASE_DIR/"static"
-
+STATIC_DIR=resource_path("static")
+# print(f"__file__:{Path(__file__).resolve()}")
app.mount("/static",StaticFiles(directory=STATIC_DIR), name="static")
# --- 全局配置 ---
diff --git a/docutranslate/utils/resource_utils.py b/docutranslate/utils/resource_utils.py
new file mode 100644
index 0000000..89ca5c2
--- /dev/null
+++ b/docutranslate/utils/resource_utils.py
@@ -0,0 +1,15 @@
+import sys
+from pathlib import Path
+
+def resource_path(relative_path):
+ """ 获取资源的绝对路径,适用于开发环境和 PyInstaller 打包后的环境 """
+ try:
+ base_path = Path(sys._MEIPASS)/"docutranslate"
+ except Exception:
+ base_path = Path(__file__).resolve().parent.parent # 开发时
+ # 更健壮的开发时路径(如果你的资源相对于项目根目录)
+ # base_path = Path(os.path.abspath("."))
+ # 或者,如果你的 static 目录总是和 app.py 在同一级(开发时)
+ # base_path = Path(__file__).resolve().parent
+ # print(f"base_path:{base_path}")
+ return base_path / relative_path
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 928aae0..43d56c2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "docutranslate"
-version = "0.2.18"
+version = "0.2.19"
description = "文件翻译工具"
readme = "README.md"
requires-python = ">=3.10"