From 5b3dd674de6d65dc6eb1b67d0f225ff0335199d1 Mon Sep 17 00:00:00 2001 From: soehi <811446351@qq.com> Date: Tue, 17 Nov 2026 14:35:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E8=AE=B0=E5=80=9F?= =?UTF-8?q?=E5=87=BA=E6=8C=89=E9=92=AE=E5=B9=B6=E6=9B=B4=E6=96=B0=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E7=BC=93=E5=AD=98=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/index.html | 4 ++-- dist/js/app.js | 11 +++++++++-- server/main.py | 10 ++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/dist/index.html b/dist/index.html index 418684a..75f2e4c 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ WorkLog · 活动记录 - +
@@ -323,7 +323,7 @@ - +
diff --git a/dist/js/app.js b/dist/js/app.js index e407031..8af204d 100644 --- a/dist/js/app.js +++ b/dist/js/app.js @@ -1548,7 +1548,8 @@ loadCenter(); })); $('#center-new').addEventListener('click', () => openActivityForm(null, 'center')); - $('#center-new-loan').addEventListener('click', () => centerForm('登记借出', + function openLoanForm() { + centerForm('登记借出', `

这里只保存借出记录,不占用库存,也不要求物品已加入库存清单。借出理由全员可见,联系方式仅本人可见。

@@ -1559,7 +1560,13 @@ quantity: Number(f.quantity.value), reason: f.reason.value, contact: f.contact.value, - }}))); + }})); + } + document.addEventListener('click', event => { + const button = event.target.closest('#center-new-loan'); + if (!button || button.disabled) return; + openLoanForm(); + }); for (const id of ['center-q', 'center-item-q']) $('#' + id).addEventListener('input', debounce(loadCenter, 300)); for (const id of ['center-from', 'center-to', 'center-loan-status']) $('#' + id).addEventListener('change', loadCenter); $('#center-refresh').addEventListener('click', loadCenter); diff --git a/server/main.py b/server/main.py index 6dfd851..4740861 100644 --- a/server/main.py +++ b/server/main.py @@ -808,6 +808,16 @@ async def security_headers(request: Request, call_next): ) if request.url.path.startswith(("/api/", "/join/", "/duty-confirm/", "/mail-test/")): response.headers["Cache-Control"] = "no-store" + elif request.method in ("GET", "HEAD") and ( + request.url.path == "/" + or request.url.path.endswith(".html") + or not Path(request.url.path).suffix + ): + # 让入口 HTML 每次重新校验,避免新脚本上线后仍被旧页面长期引用。 + response.headers["Cache-Control"] = "no-cache" + elif request.method in ("GET", "HEAD") and Path(request.url.path).suffix in (".js", ".css"): + # 前端资源通过 ?v= 更新版本号;保留 ETag 校验以便紧急修复时立即生效。 + response.headers["Cache-Control"] = "public, max-age=0, must-revalidate" if request.url.path.startswith(("/join/", "/duty-confirm/", "/mail-test/")): kind = "test" if request.url.path.startswith("/mail-test/") else ("duty" if request.url.path.startswith("/duty-confirm/") else "activity") origin_kind = "none" if not origin else ("null" if origin == "null" else ("trusted" if origin in (own_origin, trusted_origin) else "other"))