diff --git a/.gitignore b/.gitignore index 8491508..cc9debe 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ tests/ docutranslate/output/ # Virtual environments .venv +*.spec diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 29280b9..451554a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,9 +5,12 @@ + - - + + + + @@ -33,66 +36,66 @@ - { - "keyToString": { - "DefaultHtmlFileTemplate": "HTML File", - "JavaScript 调试.output.html (1).executor": "Run", - "JavaScript 调试.output.html.executor": "Run", - "JavaScript 调试.regex_中文.html.executor": "Run", - "JavaScript 调试.test2.html.executor": "Run", - "JavaScript 调试.test2_英文.html.executor": "Run", - "JavaScript 调试.test4-1_中文.html.executor": "Run", - "JavaScript 调试.互联网认证授权机制.html.executor": "Run", - "JavaScript 调试.互联网认证授权机制_英文.html.executor": "Run", - "JavaScript 调试.毕业论文_英文.html.executor": "Run", - "ModuleVcsDetector.initialDetectionPerformed": "true", - "Python 测试.Python 测试 (markdown_mask.py 内).executor": "Run", - "Python 测试.markdown_mask.Test.test_basic_link_masking 的 Python 测试.executor": "Run", - "Python.PDFtranslater (1).executor": "Run", - "Python.PDFtranslater (2).executor": "Run", - "Python.agent.executor": "Debug", - "Python.agent_utils.executor": "Run", - "Python.app.executor": "Run", - "Python.convert.executor": "Run", - "Python.markdown_splitter.executor": "Debug", - "Python.markdown_utils.executor": "Run", - "Python.test.executor": "Run", - "Python.test1.executor": "Run", - "Python.test2.executor": "Run", - "Python.test3.executor": "Run", - "Python.test4.executor": "Run", - "Python.translater.executor": "Run", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true", - "RunOnceActivity.git.unshallow": "true", - "git-widget-placeholder": "main", - "last_opened_file_path": "C:/Users/jxgm/Desktop/FileTranslate/tests", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "settings.editor.selected.configurable": "preferences.pluginManager", - "vue.rearranger.settings.migration": "true" + +}]]> + + - - + - - + @@ -567,8 +570,8 @@ - + @@ -632,6 +635,7 @@ + @@ -646,7 +650,7 @@ - + @@ -656,7 +660,7 @@ - + diff --git a/app.spec b/app备份.spec similarity index 95% rename from app.spec rename to app备份.spec index 6216a53..059c036 100644 --- a/app.spec +++ b/app备份.spec @@ -28,12 +28,12 @@ a = Analysis( 'docling.datamodel.pipeline_options', # 非常重要,为了 EasyOcrOptions 'docling.models.easyocr_model', # 猜测的路径,你需要确认 docling 中 easyocr 集成模型的实际模块路径 # 根据需要添加 easyocr 的其他依赖,例如: - 'cv2', - 'torch', - 'torchvision', - 'skimage', - 'yaml', - 'PIL', +# 'cv2', +# 'torch', +# 'torchvision', +# 'skimage', +# 'yaml', +# 'PIL', # 添加任何其他 docling 可能动态加载的模块或工厂类中引用的模块 ], # collect_submodules 已经通过上面的 collect_submodules() 函数处理并添加到 hiddenimports diff --git a/docutranslate/app.py b/docutranslate/app.py index b5bd949..cf88f7b 100644 --- a/docutranslate/app.py +++ b/docutranslate/app.py @@ -12,7 +12,6 @@ from fastapi.templating import Jinja2Templates # 导入文档翻译相关模块 from docutranslate import FileTranslater from docutranslate.logger import translater_logger - # 设置FastAPI运行标识 app = FastAPI() @@ -105,11 +104,64 @@ HTML_TEMPLATE = """ select, input[type="text"], input[type="password"], input[type="file"] { padding: 0.5rem; border: 1px solid #ddd; border-radius: var(--border-radius); background-color: white; } button, a[role="button"] { border-radius: var(--border-radius); padding: 0.5rem 1rem; } .options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; } + /* 打印样式 */ + @media print { + .no-print { display: none !important; } + body { padding: 0; background-color: white; } + .container { box-shadow: none; max-width: 100%; padding: 0; } + } + /* 预览模态窗口样式 */ + .modal { + display: none; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.6); + z-index: 1000; + overflow: auto; + } + .modal-content { + position: relative; + background-color: #fff; + margin: 2% auto; + padding: 20px; + width: 90%; + max-width: 900px; + max-height: 90vh; + border-radius: 8px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); + overflow: auto; + } + .close-modal { + position: absolute; + top: 10px; + right: 10px; + font-size: 24px; + font-weight: bold; + color: #666; + cursor: pointer; + } + .modal-actions { + display: flex; + justify-content: flex-end; + margin-top: 20px; + gap: 10px; + } + #previewFrame { + width: 100%; + min-height: 500px; + border: 1px solid #ddd; + border-radius: var(--border-radius); + } + /* 嵌入式iframe样式 */ + #printFrame { display: none; } @media (max-width: 768px) { .form-grid, .options-grid { grid-template-columns: 1fr; } .container { padding: 1rem; } } - + @@ -165,7 +217,7 @@ HTML_TEMPLATE = """ 公式识别 代码识别 - 优化 Markdown + 修正文本(耗时) @@ -179,6 +231,8 @@ HTML_TEMPLATE = """ 翻译结果 下载 Markdown 下载 HTML + 下载 PDF + 预览 @@ -186,6 +240,22 @@ HTML_TEMPLATE = """ + + + + × + HTML 预览 + + + 打印/保存为PDF + 关闭 + + + + + + +