ESP8266无睡眠轮询版 + 服务端推送记录
- 固件: 去掉 deepSleep(D0->RST 跳线依赖), 上电常驻每60秒轮询抓取上报; WiFi 掉线自动重连(30s超时), 失败也POST占位body让服务器记录fail - server: /api/raw 成功/失败均记 ReportRec(时间/来源/结果/客户端数/HTTP码), 持久化 reports.csv, /api/site 返回最近50条 - 看板: 新增"最近推送记录"面板(成功/失败徽标), 移动端兼容 - secrets.h.example 同步轮询版配置说明
This commit is contained in:
1 parent
da141e4c79
commit
e76d6984e0
4 files changed
+196
-60
No files matched your search
@@ -46,6 +46,13 @@
|
||||
.evt .time { color: var(--muted); white-space: nowrap; }
|
||||
.evt .name { font-weight: 600; }
|
||||
.evt .detail { color: var(--muted); font-size: 12px; }
|
||||
.rpt { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(51,65,85,.3); font-size: 13px; flex-wrap: wrap; }
|
||||
.rpt:last-child { border-bottom: none; }
|
||||
.rpt .time { color: var(--muted); white-space: nowrap; }
|
||||
.rpt .src { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
||||
.rpt .detail { color: var(--muted); font-size: 12px; flex-basis: 100%; padding-left: 16px; }
|
||||
.badge.ok { background: rgba(34,197,94,.15); color: var(--green); }
|
||||
.badge.fail { background: rgba(239,68,68,.15); color: var(--red); }
|
||||
.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; }
|
||||
@@ -115,6 +122,11 @@
|
||||
<div class="scroll" id="events"></div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>最近推送记录</h2>
|
||||
<div class="scroll" id="reports"></div>
|
||||
</div>
|
||||
|
||||
<div class="footer" id="footer"></div>
|
||||
|
||||
<script>
|
||||
@@ -212,6 +224,17 @@ async function loadSite() {
|
||||
</div>`;
|
||||
}).join('') || '<div class="empty">暂无事件</div>';
|
||||
|
||||
$('reports').innerHTML = (data.reports || []).map(rp => {
|
||||
const ok = rp.result === 'ok';
|
||||
return `<div class="rpt">
|
||||
<span class="badge ${ok ? 'ok' : 'fail'}">${ok ? '成功' : '失败'}</span>
|
||||
<span class="time">${fmtTime(rp.time)}</span>
|
||||
<span class="src">${esc(rp.source || '-')}</span>
|
||||
${rp.clients ? `<span class="muted">${rp.clients}客户端</span>` : ''}
|
||||
<span class="detail">${esc(rp.detail || '')}${rp.code ? ` (HTTP ${rp.code})` : ''}</span>
|
||||
</div>`;
|
||||
}).join('') || '<div class="empty">暂无推送记录</div>';
|
||||
|
||||
$('footer').textContent = `当前站点: ${currentSite} · 最近上报 ${fmtTime(data.last_seen)} · 页面自动刷新 · ${new Date().toLocaleString()}`;
|
||||
} catch (e) {
|
||||
$('footer').textContent = '加载站点失败: ' + e.message;
|
||||
|
||||
Reference in new issue
Block a user