From 4c337b60ae4f83cfd1025949140a0e477226245f Mon Sep 17 00:00:00 2001 From: wangfq Date: Wed, 10 Jun 2026 14:29:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=99=A8=E7=BC=93=E5=AD=98=E5=AF=BC=E8=87=B4=E5=B7=A5=E8=A3=85?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20GET=20=E8=AF=B7=E6=B1=82=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=97=A7=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: /api/fixture/param/ GET 没有 Cache-Control 头,F5 刷新时 浏览器直接用磁盘缓存返回旧 TestMode,导致测试页显示旧模式。 修复: - 服务端 fixture.py: GET 响应加 Cache-Control: no-store/no-cache/must-revalidate - 客户端 test_op.js + fixture.js: 4 处 GET fetch 全部加 ?_=Date.now() 缓存破坏参数 --- edc-web/app/routes/fixture.py | 4 +++- edc-web/app/static/js/fixture.js | 6 +++--- edc-web/app/static/js/test_op.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/edc-web/app/routes/fixture.py b/edc-web/app/routes/fixture.py index c58df62..0333214 100644 --- a/edc-web/app/routes/fixture.py +++ b/edc-web/app/routes/fixture.py @@ -217,7 +217,9 @@ def api_get_serialnet(record_id): def api_get_fixture_param(dnt_id): """获取工装测试参数""" param = get_fixture_param(dnt_id) - return jsonify(param or {}) + resp = jsonify(param or {}) + resp.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0" + return resp @bp.route("/api/fixture/param/", methods=["POST"]) diff --git a/edc-web/app/static/js/fixture.js b/edc-web/app/static/js/fixture.js index 20221a3..43bebe0 100644 --- a/edc-web/app/static/js/fixture.js +++ b/edc-web/app/static/js/fixture.js @@ -196,7 +196,7 @@ function onCarChange() { async function loadFixtureParam() { try { - const resp = await fetch(`/api/fixture/param/${DNT_ID}`); + const resp = await fetch(`/api/fixture/param/${DNT_ID}?_=${Date.now()}`); const param = await resp.json(); if (param && param.dnt_id) { fillFormFromParam(param); @@ -239,7 +239,7 @@ function fillFormFromParam(param) { } async function refreshParams() { - const param = await (await fetch(`/api/fixture/param/${DNT_ID}`)).json(); + const param = await (await fetch(`/api/fixture/param/${DNT_ID}?_=${Date.now()}`)).json(); if (param && param.dnt_id) { fillFormFromParam(param); commLog('info', null, '已刷新:从数据库加载工装参数'); @@ -360,7 +360,7 @@ function startRespPolling(recordId, cmd) { if (cmd === '4C') { // 参数已在后端 upsert,直接从 DB 加载 setTimeout(async () => { - const p = await (await fetch(`/api/fixture/param/${DNT_ID}`)).json(); + const p = await (await fetch(`/api/fixture/param/${DNT_ID}?_=${Date.now()}`)).json(); if (p && p.dnt_id) fillFormFromParam(p); }, 500); } diff --git a/edc-web/app/static/js/test_op.js b/edc-web/app/static/js/test_op.js index 171f2cb..d626a28 100644 --- a/edc-web/app/static/js/test_op.js +++ b/edc-web/app/static/js/test_op.js @@ -275,7 +275,7 @@ async function pollProgress() { async function loadTestMode() { try { - const resp = await fetch(`/api/fixture/param/${DNT_ID}`); + const resp = await fetch(`/api/fixture/param/${DNT_ID}?_=${Date.now()}`); const param = await resp.json(); if (param && param.dnt_id) { updateTestModeUI(param.TestMode);