增加手机自适应
This commit is contained in:
@@ -430,7 +430,14 @@ async function saveDailyReportSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
function isPanelFolded(foldId) {
|
||||
const panel = document.querySelector(`.matrix-panel-fold[data-fold-id="${foldId}"]`);
|
||||
return !!(panel && panel.classList.contains("is-folded"));
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
if (document.visibilityState !== "visible") return;
|
||||
const mobileLite = isMobileLite();
|
||||
try {
|
||||
const funnelWindowH = getFunnelWindowHours();
|
||||
const [status, alerts, logs, config, funnel, dailyReport] = await Promise.all([
|
||||
@@ -445,8 +452,16 @@ async function refresh() {
|
||||
|
||||
const statusPre = document.getElementById("status");
|
||||
const cf = document.getElementById("config");
|
||||
if (statusPre) statusPre.textContent = pretty(status);
|
||||
if (cf) cf.textContent = pretty(config);
|
||||
if (!mobileLite) {
|
||||
if (statusPre) {
|
||||
const st = pretty(status);
|
||||
if (statusPre.textContent !== st) statusPre.textContent = st;
|
||||
}
|
||||
if (cf) {
|
||||
const cfgTxt = pretty(config);
|
||||
if (cf.textContent !== cfgTxt) cf.textContent = cfgTxt;
|
||||
}
|
||||
}
|
||||
|
||||
const runState = (status && status.state) || {};
|
||||
const funnelWindowApplied =
|
||||
@@ -497,7 +512,8 @@ async function refresh() {
|
||||
const watchRows = allAlerts.filter((a) => (a.details && a.details.signal_level) === "WATCH");
|
||||
const triggerRows = allAlerts.filter((a) => (a.details && a.details.signal_level) === "TRIGGER");
|
||||
|
||||
renderItems("watchAlerts", watchRows, (a) => `
|
||||
if (!mobileLite || !isPanelFolded("scan-layers")) {
|
||||
renderItems("watchAlerts", watchRows, (a) => `
|
||||
<div class="matrix-row-title"><strong>${a.symbol}</strong> <span class="matrix-dim">${escapeHtml(a.chain || "")}</span></div>
|
||||
<div>级别: ${(a.details && a.details.signal_level) || "N/A"}</div>
|
||||
<div>信号: ${(a.trigger_types || []).join(" · ")}</div>
|
||||
@@ -523,11 +539,14 @@ async function refresh() {
|
||||
<div class="time">${formatIsoToBeijing(a.created_at)}</div>
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
renderItems("logs", logs.items || [], (l) => `
|
||||
if (!mobileLite || !isPanelFolded("runtime-logs")) {
|
||||
renderItems("logs", logs.items || [], (l) => `
|
||||
<div><strong class="matrix-log-lvl-${(l.level || "").toLowerCase()}">[${l.level}]</strong> ${escapeHtml(l.message)}</div>
|
||||
<div class="time">${formatIsoToBeijing(l.created_at)}</div>
|
||||
`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("refresh failed", error);
|
||||
setText("hudLink", "ERR");
|
||||
@@ -536,8 +555,25 @@ async function refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 轻量 Canvas 代码雨(仅 dashboard 有 canvas) */
|
||||
/** 手机 / 触控:关闭重动画与代码雨,减轻闪屏与发热 */
|
||||
function isMobileLite() {
|
||||
return (
|
||||
document.documentElement.classList.contains("matrix-lite") ||
|
||||
window.matchMedia("(max-width: 640px), (hover: none) and (pointer: coarse)").matches
|
||||
);
|
||||
}
|
||||
|
||||
function applyMobileLiteClass() {
|
||||
if (isMobileLite()) {
|
||||
document.documentElement.classList.add("matrix-lite");
|
||||
document.body.classList.add("matrix-lite");
|
||||
}
|
||||
}
|
||||
|
||||
/** 轻量 Canvas 代码雨(仅 dashboard 有 canvas;手机端不启动) */
|
||||
function initMatrixRain() {
|
||||
applyMobileLiteClass();
|
||||
if (isMobileLite()) return;
|
||||
const canvas = document.getElementById("matrixRain");
|
||||
if (!canvas || !canvas.getContext) return;
|
||||
const ctx = canvas.getContext("2d");
|
||||
@@ -843,7 +879,8 @@ initMatrixRain();
|
||||
initFunnelWindowControls();
|
||||
initPanelFolds();
|
||||
refresh();
|
||||
setInterval(refresh, 4000);
|
||||
const REFRESH_MS = isMobileLite() ? 10000 : 4000;
|
||||
setInterval(refresh, REFRESH_MS);
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (document.visibilityState === "visible") refresh();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user