移动端优化: 720px以下设备表转卡片、统计2x2、站点栏横滚、事件紧凑; 两处模板加 data-label
This commit is contained in:
1 parent
88a35ea427
commit
da141e4c79
2 files changed
+77
-18
No files matched your search
+40
-9
@@ -49,7 +49,38 @@
|
||||
.footer { color: var(--muted); font-size: 12px; text-align: center; padding: 10px 0 30px; }
|
||||
.scroll { max-height: 460px; overflow-y: auto; }
|
||||
.empty { color: var(--muted); padding: 20px 0; text-align: center; }
|
||||
@media (max-width: 640px) { body { padding: 10px; } table { font-size: 12px; } }
|
||||
@media (max-width: 720px) {
|
||||
body { padding: 12px 10px; }
|
||||
h1 { font-size: 18px; }
|
||||
.top { gap: 10px; }
|
||||
/* 站点栏横向滚动 */
|
||||
.sitebar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; margin: 0 -10px; padding-left: 10px; padding-right: 10px; }
|
||||
.sitebtn { flex-shrink: 0; padding: 7px 12px; }
|
||||
/* 统计卡片 2x2 */
|
||||
.stats { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
|
||||
.stat { padding: 10px 12px; }
|
||||
.stat .num { font-size: 22px; }
|
||||
/* 设备表 → 卡片列表 */
|
||||
.card { padding: 12px; margin-bottom: 16px; }
|
||||
table { display: block; font-size: 13px; }
|
||||
thead { display: none; }
|
||||
tbody { display: block; }
|
||||
tr { display: block; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
|
||||
tr:hover td { background: transparent; }
|
||||
td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; border-bottom: 1px solid rgba(51,65,85,.25); white-space: normal; }
|
||||
td:last-child { border-bottom: none; }
|
||||
td::before { content: attr(data-label); color: var(--muted); font-size: 12px; flex-shrink: 0; }
|
||||
td:first-child { display: inline-flex; justify-content: flex-start; border-bottom: 1px solid rgba(51,65,85,.25); }
|
||||
td:first-child::before { content: none; }
|
||||
td .badge { font-size: 11px; padding: 2px 8px; }
|
||||
/* 时间信息用紧凑小字,但值自身换行 */
|
||||
td:not(:first-child) { font-size: 12.5px; }
|
||||
.mac { word-break: break-all; text-align: right; }
|
||||
/* 紧凑事件 */
|
||||
.evt { flex-wrap: wrap; gap: 4px 8px; padding: 8px 0; font-size: 12.5px; }
|
||||
.evt .time { width: 100%; font-size: 12px; }
|
||||
.evt .detail { flex-basis: 100%; padding-left: 16px; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -159,14 +190,14 @@ async function loadSite() {
|
||||
$('devices').innerHTML = (data.devices || []).map(d => `
|
||||
<tr>
|
||||
<td><span class="badge ${d.status === 'online' ? 'online' : 'offline'}">${d.status === 'online' ? '在线' : '离线'}</span></td>
|
||||
<td>${esc(d.name || '-')}</td>
|
||||
<td class="mac">${esc(d.mac)}</td>
|
||||
<td class="mac">${esc(d.last_ip || '-')}</td>
|
||||
<td>${fmtTime(d.first_seen)}</td>
|
||||
<td>${fmtTime(d.last_online)}</td>
|
||||
<td>${fmtTime(d.last_offline)}</td>
|
||||
<td>${d.online_count ?? 0}</td>
|
||||
<td>${fmtDur(d.total_online_seconds)}</td>
|
||||
<td data-label="设备名">${esc(d.name || '-')}</td>
|
||||
<td data-label="MAC">${esc(d.mac)}</td>
|
||||
<td data-label="IP">${esc(d.last_ip || '-')}</td>
|
||||
<td data-label="首次发现">${fmtTime(d.first_seen)}</td>
|
||||
<td data-label="最近上线">${fmtTime(d.last_online)}</td>
|
||||
<td data-label="最近下线">${fmtTime(d.last_offline)}</td>
|
||||
<td data-label="在线次数">${d.online_count ?? 0}</td>
|
||||
<td data-label="累计在线">${fmtDur(d.total_online_seconds)}</td>
|
||||
</tr>`).join('') || '<tr><td colspan="9" class="empty">暂无设备</td></tr>';
|
||||
|
||||
$('events').innerHTML = (data.events || []).map(e => {
|
||||
|
||||
Reference in new issue
Block a user