fix(ui): 断线清指标加强——DeviceLink 离线也清 + 模块缓存版本戳

入口/stages/polling 带 ?v=20260916d,避免深层 import 被浏览器缓存成旧版;
外壳快照 ESP32 offline 时同样 clearLiveMetricsOnDisconnect。
This commit is contained in:
cbb
2026-09-16 20:29:29 +08:00
parent d73e2fb5b8
commit 5459bdeff7
2 changed files with 16 additions and 4 deletions
+14 -2
View File
@@ -17,7 +17,7 @@ import {
import { import {
scheduleStatusPoll, startPolling, pausePollingForUpload, scheduleStatusPoll, startPolling, pausePollingForUpload,
resumePollingAfterUpload, pollStatus, pollLogs, setStatusPollIntervalMs resumePollingAfterUpload, pollStatus, pollLogs, setStatusPollIntervalMs
} from './common/polling.js'; } from './common/polling.js?v=20260916d';
import { import {
OtaSessionState, otaSessionState, otaSessionTarget, otaFailReason, OtaSessionState, otaSessionState, otaSessionTarget, otaFailReason,
@@ -32,7 +32,7 @@ import {
} from './ota/progress.js'; } from './ota/progress.js';
import { import {
updateStagesFromRelayState, updateSystemStatusUi, clearLiveMetricsOnDisconnect updateStagesFromRelayState, updateSystemStatusUi, clearLiveMetricsOnDisconnect
} from './ota/stages.js'; } from './ota/stages.js?v=20260916d';
import { startEcatLoadPoller } from './ota/ecat_load.js'; import { startEcatLoadPoller } from './ota/ecat_load.js';
import { deviceLink } from './common/device-link.js'; import { deviceLink } from './common/device-link.js';
import { import {
@@ -293,6 +293,18 @@ setupDropZone('uploadZoneGd32', 'gd32');
// 否则 polling.js 的 scheduleStatusPoll 会因 window.OtaSessionState 未定义而抛 TypeError) // 否则 polling.js 的 scheduleStatusPoll 会因 window.OtaSessionState 未定义而抛 TypeError)
startPolling(); startPolling();
/* DeviceLink 快照判 ESP32 离线时也清指标:
* 本页 pollStatus 可能 AbortError 静默返回,或 iframe 里旧模块未清——
* 外壳 Owner 是更权威的「设备在线」来源,离线布尔一翻就清。 */
deviceLink.subscribe(function (s) {
try {
if (!s || !s.ts || !s.links || !s.links.esp32) return;
if ((Date.now() - s.ts) >= 5000) return;
if (s.links.esp32.online) return;
clearLiveMetricsOnDisconnect();
} catch (_) {}
});
// GD32 CPU 负载率(EtherCAT 通道,独立于 /system/status 轮询;页面上无该指标则自动空转) // GD32 CPU 负载率(EtherCAT 通道,独立于 /system/status 轮询;页面上无该指标则自动空转)
startEcatLoadPoller(); startEcatLoadPoller();
+2 -2
View File
@@ -569,8 +569,8 @@
必须持有租约,否则服务端在租约归零宽限期后会把循环又停掉。 必须持有租约,否则服务端在租约归零宽限期后会把循环又停掉。
与 tabs.html / motor.html 并存时连接数>1,互不影响。 --> 与 tabs.html / motor.html 并存时连接数>1,互不影响。 -->
<script src="../js/common/app-lease.js"></script> <script src="../js/common/app-lease.js"></script>
<script type="module" src="../js/app.js?v=20260915a"></script> <script type="module" src="../js/app.js?v=20260916d"></script>
<script type="module" src="../js/ota/console-mode.js?v=20260914b"></script> <script type="module" src="../js/ota/console-mode.js?v=20260916d"></script>
<script type="module" src="../js/ble_ota.js?v=20260901d"></script> <script type="module" src="../js/ble_ota.js?v=20260901d"></script>
<!-- 内联兜底:同步 BLE 按钮 data-ble-state 与 checkbox.checked <!-- 内联兜底:同步 BLE 按钮 data-ble-state 与 checkbox.checked
不依赖 ES 模块(子模块可能被浏览器缓存为旧版,不含 data-ble-state 逻辑)。 不依赖 ES 模块(子模块可能被浏览器缓存为旧版,不含 data-ble-state 逻辑)。