feat(link): ConnectionHub 统一 WiFi/ECAT/BLE 端点与健康态

各页不再各自读写 dcu_esp_ip / dcu_ecat_adapter:deviceLink 提供
wifiBaseUrl/ecatPost/adapter API,OTA/CAN/motor/ecat_load/lab 走同一入口。
连接灯只覆盖在线布尔,保留调用方语义文案。
This commit is contained in:
cbb
2026-09-16 12:12:24 +08:00
parent 353d936abb
commit 033ece2cca
11 changed files with 210 additions and 110 deletions
+7
View File
@@ -53,6 +53,7 @@ import {
import { escapeHtml as sanitizeHtml, formatUptime } from './common/utils.js';
import { showToast } from './common/toast.js';
import { initCanMonitor } from './can_monitor.js';
import { deviceLink } from './common/device-link.js';
// ==================== 本地工具 ====================
// 原 can.js 的 formatUptime 输出格式与 common/utils.js 略有差异(d>0 时只到 h),
@@ -413,6 +414,12 @@ function init() {
setTimeout(testConnection, 150);
/* 周期性刷新顶栏 STA/IP/RSSI/运行时间(与监控 1Hz 解耦,避免重复 pill) */
setInterval(testConnection, 5000);
/* ConnectionHub 快照只覆盖在线布尔,不改 testConnection 写的语义文案(STA/HTTP…) */
deviceLink.subscribe(function (s) {
if (!s || !s.ts || (Date.now() - s.ts) >= 5000) return;
var on = !!(s.links && s.links.esp32 && s.links.esp32.online);
if (el.canConnPill) el.canConnPill.className = 'pill ' + (on ? 'online' : 'offline');
});
/* 右侧抽屉:CAN 接收监控 */
initCanMonitor();
}