修复登记借出按钮并更新前端缓存版本
This commit is contained in:
Vendored
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>WorkLog · 活动记录</title>
|
<title>WorkLog · 活动记录</title>
|
||||||
<meta name="theme-color" content="#f5f7f5" />
|
<meta name="theme-color" content="#f5f7f5" />
|
||||||
<link rel="stylesheet" href="/assets/styles.css?v=24" />
|
<link rel="stylesheet" href="/assets/styles.css?v=25" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
@@ -323,7 +323,7 @@
|
|||||||
|
|
||||||
<div id="toast" class="toast hidden" role="status" aria-live="polite"></div>
|
<div id="toast" class="toast hidden" role="status" aria-live="polite"></div>
|
||||||
|
|
||||||
<script src="/js/app.js?v=36"></script>
|
<script src="/js/app.js?v=37"></script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Vendored
+9
-2
@@ -1548,7 +1548,8 @@
|
|||||||
loadCenter();
|
loadCenter();
|
||||||
}));
|
}));
|
||||||
$('#center-new').addEventListener('click', () => openActivityForm(null, 'center'));
|
$('#center-new').addEventListener('click', () => openActivityForm(null, 'center'));
|
||||||
$('#center-new-loan').addEventListener('click', () => centerForm('登记借出',
|
function openLoanForm() {
|
||||||
|
centerForm('登记借出',
|
||||||
`<p class="muted">这里只保存借出记录,不占用库存,也不要求物品已加入库存清单。借出理由全员可见,联系方式仅本人可见。</p>
|
`<p class="muted">这里只保存借出记录,不占用库存,也不要求物品已加入库存清单。借出理由全员可见,联系方式仅本人可见。</p>
|
||||||
<label>借出物品<input name="item_name" required maxlength="100" placeholder="例如:投影仪、音箱" /></label>
|
<label>借出物品<input name="item_name" required maxlength="100" placeholder="例如:投影仪、音箱" /></label>
|
||||||
<label>数量<input name="quantity" type="number" min="1" max="100000" value="1" required /></label>
|
<label>数量<input name="quantity" type="number" min="1" max="100000" value="1" required /></label>
|
||||||
@@ -1559,7 +1560,13 @@
|
|||||||
quantity: Number(f.quantity.value),
|
quantity: Number(f.quantity.value),
|
||||||
reason: f.reason.value,
|
reason: f.reason.value,
|
||||||
contact: f.contact.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-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);
|
for (const id of ['center-from', 'center-to', 'center-loan-status']) $('#' + id).addEventListener('change', loadCenter);
|
||||||
$('#center-refresh').addEventListener('click', loadCenter);
|
$('#center-refresh').addEventListener('click', loadCenter);
|
||||||
|
|||||||
@@ -808,6 +808,16 @@ async def security_headers(request: Request, call_next):
|
|||||||
)
|
)
|
||||||
if request.url.path.startswith(("/api/", "/join/", "/duty-confirm/", "/mail-test/")):
|
if request.url.path.startswith(("/api/", "/join/", "/duty-confirm/", "/mail-test/")):
|
||||||
response.headers["Cache-Control"] = "no-store"
|
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/")):
|
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")
|
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"))
|
origin_kind = "none" if not origin else ("null" if origin == "null" else ("trusted" if origin in (own_origin, trusted_origin) else "other"))
|
||||||
|
|||||||
Reference in New Issue
Block a user