修复排列

This commit is contained in:
dekun
2026-05-23 16:48:37 +08:00
parent 952d57ab6d
commit 80150227e3
3 changed files with 17 additions and 9 deletions
+13
View File
@@ -100,6 +100,18 @@
return (settingsCache?.exchanges || []).filter((x) => x.enabled);
}
/** 监控卡片列数:3 个一行;4 个 2×2;5/6 个两行(每行最多 3) */
function syncMonitorGridColumns(gridEl, count) {
if (!gridEl) return;
let cols = 3;
if (count <= 1) cols = 1;
else if (count === 2) cols = 2;
else if (count === 3) cols = 3;
else if (count === 4) cols = 2;
else cols = 3;
gridEl.style.gridTemplateColumns = `repeat(${cols}, minmax(0, 1fr))`;
}
async function loadMonitorBoard() {
const box = document.getElementById("monitor-grid");
try {
@@ -116,6 +128,7 @@
"UPD " + (data.updated_at || "").replace("T", " ");
const parts = rows.map(renderMonitorCard);
box.innerHTML = parts.join("") || '<div class="err">无已启用账户</div>';
syncMonitorGridColumns(box, rows.length);
box.querySelectorAll(".btn-close-ex").forEach((btn) => {
btn.onclick = () => closeOne(btn.dataset.id);
});