feat: 完成 issue #157 移动端只读驾驶舱补充手动刷新(KPI 时间桶滚动)

This commit is contained in:
2026-08-05 10:50:05 +08:00
parent 3a6ef57592
commit 253ebe7b0b
3 changed files with 21 additions and 10 deletions
+14 -8
View File
@@ -71,7 +71,8 @@ function renderMobileCockpit(plan) {
kpiBox.innerHTML = "";
plan.widgets.forEach(function (w) {
if (w.type !== "kpi_card") return;
var rnd = seededRandom(w.props.metric || "");
// 30s 时间桶入种子:刷新/定时重渲染时数值滚动(接真实总线后替换)
var rnd = seededRandom((w.props.metric || "") + "|" + Math.floor(Date.now() / 30000));
var card = el("div", "kpi");
card.appendChild(el("div", "v", (60 + rnd() * 40).toFixed(2)));
card.appendChild(el("div", "l", w.props.label || w.props.metric));
@@ -231,11 +232,16 @@ function generateBrief() {
fetch(ALARM_PLAN_URL).then(function (r) { return r.ok ? r.json() : null; })
.then(function (p) { if (p && p.severityStyles) severityStyles = p.severityStyles; })
.catch(function () {});
fetch(PLAN_URL).then(function (r) { return r.json(); })
.then(renderMobileCockpit)
.catch(function (e) {
document.getElementById("m-stages").innerHTML = "";
document.getElementById("m-stages").appendChild(
el("div", "hint", "布局资产加载失败:" + e.message + "(请从 web/ 根目录起服务)"));
});
// issue #157:只读数据手动刷新(重新加载布局资产并重渲染 KPI/告警)
function loadPlan() {
fetch(PLAN_URL).then(function (r) { return r.json(); })
.then(renderMobileCockpit)
.catch(function (e) {
document.getElementById("m-stages").innerHTML = "";
document.getElementById("m-stages").appendChild(
el("div", "hint", "布局资产加载失败:" + e.message + "(请从 web/ 根目录起服务)"));
});
}
document.getElementById("btn-refresh").onclick = loadPlan;
loadPlan();
})();