fix(hub): restore monitor host status panel after missing pref helpers
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -73,6 +73,21 @@
|
||||
const HOST_RESOURCE_ALERT_THRESHOLD = 85;
|
||||
const hostResourceAlertLatch = { cpu: false, mem: false };
|
||||
|
||||
function loadBoolPref(key, defaultValue) {
|
||||
try {
|
||||
const raw = localStorage.getItem(key);
|
||||
if (raw === "1" || raw === "true") return true;
|
||||
if (raw === "0" || raw === "false") return false;
|
||||
} catch (_) {}
|
||||
return !!defaultValue;
|
||||
}
|
||||
|
||||
function saveBoolPref(key, on) {
|
||||
try {
|
||||
localStorage.setItem(key, on ? "1" : "0");
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function fmtHostBytes(n) {
|
||||
const v = Number(n);
|
||||
if (!Number.isFinite(v)) return "—";
|
||||
@@ -153,13 +168,19 @@
|
||||
return parts.join(" · ") || "—";
|
||||
}
|
||||
|
||||
let hostStatusPanelInited = false;
|
||||
|
||||
function initHostStatusPanel() {
|
||||
const panel = document.getElementById("host-status-panel");
|
||||
if (!panel) return;
|
||||
panel.open = loadBoolPref(HOST_STATUS_OPEN_KEY, false);
|
||||
panel.addEventListener("toggle", function () {
|
||||
saveBoolPref(HOST_STATUS_OPEN_KEY, !!panel.open);
|
||||
});
|
||||
panel.classList.remove("hidden");
|
||||
if (!hostStatusPanelInited) {
|
||||
panel.open = loadBoolPref(HOST_STATUS_OPEN_KEY, false);
|
||||
panel.addEventListener("toggle", function () {
|
||||
saveBoolPref(HOST_STATUS_OPEN_KEY, !!panel.open);
|
||||
});
|
||||
hostStatusPanelInited = true;
|
||||
}
|
||||
}
|
||||
|
||||
function renderHostStatusBar(data) {
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<div class="page-head">
|
||||
<h1><span class="head-tag">MON</span> 监控区</h1>
|
||||
</div>
|
||||
<details id="host-status-panel" class="host-status-panel hidden" aria-label="服务器运行状态">
|
||||
<details id="host-status-panel" class="host-status-panel" aria-label="服务器运行状态">
|
||||
<summary class="host-status-summary">
|
||||
<span class="host-status-dot ok" id="host-status-dot" aria-hidden="true"></span>
|
||||
<span class="host-status-summary-title">服务器状态</span>
|
||||
@@ -653,6 +653,6 @@
|
||||
<script src="/assets/dashboard.js?v=20260612-dash-monitor-count"></script>
|
||||
<script src="/assets/ai_review_render.js?v=3"></script>
|
||||
<script src="/assets/time_close_ui.js?v=2"></script>
|
||||
<script src="/assets/app.js?v=20260613-host-status-fold-alert"></script>
|
||||
<script src="/assets/app.js?v=20260613-host-status-fix"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user