From 6f81e0d07a375d2faa2f682226dfbe47f82b92c4 Mon Sep 17 00:00:00 2001 From: ClovertaTheTrilobita Date: Thu, 18 Sep 2025 00:12:10 +0300 Subject: [PATCH] =?UTF-8?q?feature(preview):=20=E5=A2=9E=E5=8A=A0=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=20fix(flask):=20=E4=BF=AE=E6=94=B9=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E5=80=9F=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/flaskApp.py | 5 ++- frontend/preview.html | 86 ++++++++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 39 deletions(-) diff --git a/backend/flaskApp.py b/backend/flaskApp.py index ef300d6..ed4f710 100644 --- a/backend/flaskApp.py +++ b/backend/flaskApp.py @@ -37,8 +37,9 @@ def index(): def test_download(): return send_from_directory("test_output/2025-09-16-20-03-51", "img_overlay.png", as_attachment=True) -@app.get("/dl/") -def download(timestamp): +@app.get("/dl") +def download(): + timestamp = request.args.get("id") input_dir = os.path.join(BASE_DIR, "output", timestamp) output_dir = os.path.join(BASE_DIR, "output/tmp", timestamp) # 不要加 .zip,make_archive 会自动加 os.makedirs(BASE_DIR / "output/tmp", exist_ok=True) # 确保 tmp 存在 diff --git a/frontend/preview.html b/frontend/preview.html index 724be7a..6645602 100644 --- a/frontend/preview.html +++ b/frontend/preview.html @@ -1,50 +1,62 @@ -

This is preview

+

运行结果预览

+ + + window.downloadTif = function () { + const a = document.createElement("a"); + a.href = API_DL + "?id=" + encodeURIComponent(ID); + a.download = ID; // 留空:文件名由服务端决定;可写具体名称 + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + } + \ No newline at end of file