fix: 表格完整显示 + 事件区块样式重做 + 探测范围可选(probeScope)
1) 表格显示不全 table-layout:fixed 保证不横向滚动后,列内仍是 nowrap,实测长 URL 被截 388px、名称截 219px、可用率条截 35px(1440 宽共 14 个单元格)。 改为允许换行(地址 break-all)并重排列宽 —— 数据完整且仍零横向滚动。 2) 最近事件完全没样式 根因:上次追加 CSS 的命令是 `node --check app.js && cat >> style.css`, --check 报错导致 && 短路,CSS 从未写入(只有 HTML 裸奔)。 本次用编辑器写入;同时重做为时间线样式(竖线 + 类型着色圆点 + 左描边)、 名称列按内容自适应(消除大片空白)、默认折叠最近 8 条可展开全部。 3) dataFilter=uptimerobot 时仍在探测本地目标 新增 settings.probeScope(all|config|uptimerobot),不填则跟随 dataFilter; 显式设 all 可保留探测。启动日志打印当前口径与范围。 顺带修复两个连带问题: - UR 镜像目标此前不产生事件也不告警(evaluateRound 只遍历本地目标), 配 uptimerobot 口径等于收不到任何提醒 —— 现在两类目标统一纳入 - 去抖计数被评估频率放大:evaluateRound 每秒执行,原实现每次评估都 failStreak+1,持续离线目标 1 秒即达阈值告警。改为按探测时间戳去重, 且无状态变化时不再反复落盘 测试:verify-views [J] 扩到 11 条(长内容不截断/仍不滚动/时间线布局/ 类型着色/折叠展开),verify-notify 新增 [D3] 4 条(范围跟随、不再探测本地、 显式 all 恢复、与展示口径解耦)+ 去抖计数断言。六套 170 项全通过。
This commit is contained in:
+27
-6
@@ -1,4 +1,4 @@
|
||||
const VERSION = '0.11.0';
|
||||
const VERSION = '0.11.1';
|
||||
const HB_LIMIT = 48;
|
||||
const UPTIME_DAYS = 90;
|
||||
const BROWSER_CONCURRENCY = 6;
|
||||
@@ -16,6 +16,7 @@ const state = {
|
||||
filter: 'all',
|
||||
view: 'cards',
|
||||
theme: 'default',
|
||||
eventsExpanded: false,
|
||||
refreshTimer: null,
|
||||
nextRefreshAt: 0,
|
||||
loading: false,
|
||||
@@ -243,18 +244,26 @@ function latTrendBar(lat) {
|
||||
}
|
||||
|
||||
// 最近事件区块(故障 / 恢复 / 证书阈值 / 维护窗口内的事件)
|
||||
// 默认只列最近 EVENTS_COLLAPSED 条,其余折叠在「展开全部」后面,避免长列表把页面撑得过长
|
||||
const EVENTS_COLLAPSED = 8;
|
||||
|
||||
function renderEvents() {
|
||||
const box = $('events');
|
||||
if (!box) return;
|
||||
const list = $('events-list');
|
||||
const empty = $('events-empty');
|
||||
const events = (state.status?.events ?? []).slice(0, 20);
|
||||
box.hidden = events.length === 0;
|
||||
empty.hidden = events.length > 0;
|
||||
const all = state.status?.events ?? [];
|
||||
box.hidden = all.length === 0;
|
||||
empty.hidden = all.length > 0;
|
||||
if (!all.length) return;
|
||||
|
||||
const expanded = state.eventsExpanded === true;
|
||||
const shown = expanded ? all : all.slice(0, EVENTS_COLLAPSED);
|
||||
const count = $('events-count');
|
||||
if (count) count.textContent = events.length ? `最近 ${events.length} 条` : '';
|
||||
if (count) count.textContent = all.length > shown.length ? `最近 ${shown.length} / ${all.length} 条` : `最近 ${all.length} 条`;
|
||||
|
||||
const label = { down: '故障', up: '恢复', tls: '证书', maintenance: '维护' };
|
||||
list.innerHTML = events.map((e) => {
|
||||
list.innerHTML = shown.map((e) => {
|
||||
const maint = e.maintenance ? '<span class="ev-maint" title="维护窗口内,未计入可用率、未发送告警">维护</span>' : '';
|
||||
return `<li class="ev ev-${escapeHtml(e.type)}">
|
||||
<span class="ev-time" title="${escapeHtml(fmtTime(e.t))}">${escapeHtml(fmtRelative(e.t))}</span>
|
||||
@@ -263,6 +272,14 @@ function renderEvents() {
|
||||
<span class="ev-detail" title="${escapeHtml(e.detail ?? '')}">${escapeHtml(e.detail ?? '')}</span>
|
||||
</li>`;
|
||||
}).join('');
|
||||
|
||||
const more = $('events-more');
|
||||
if (more) {
|
||||
const hidden = all.length - shown.length;
|
||||
more.hidden = all.length <= EVENTS_COLLAPSED;
|
||||
more.textContent = expanded ? '收起' : `展开全部 ${all.length} 条`;
|
||||
more.dataset.hidden = String(hidden);
|
||||
}
|
||||
}
|
||||
|
||||
function uptimeBar(st) {
|
||||
@@ -896,6 +913,10 @@ function bindEvents() {
|
||||
// 只有手动点「刷新」才会触发一次重新检测;自动刷新是只读的
|
||||
$('refresh-btn').addEventListener('click', () => refresh({ force: true }));
|
||||
$('theme-btn')?.addEventListener('click', () => applyTheme(state.theme === 'shiroko' ? 'default' : 'shiroko'));
|
||||
$('events-more')?.addEventListener('click', () => {
|
||||
state.eventsExpanded = !state.eventsExpanded;
|
||||
renderEvents();
|
||||
});
|
||||
// 横竖屏切换 / 窗口缩放时重算视图(不覆盖用户显式选择,故 persist: false)
|
||||
window.addEventListener('resize', () => {
|
||||
const next = resolveView();
|
||||
|
||||
+113
-18
@@ -368,15 +368,16 @@ body[data-view="table"] .grid { display: block; }
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
}
|
||||
/* 列宽:状态 / 服务 / 目标 / 延迟 / 结果 / 最近检测 / 心率 / 90天可用率 = 100% */
|
||||
.monitor-table th:nth-child(1) { width: 8%; }
|
||||
.monitor-table th:nth-child(2) { width: 16%; }
|
||||
.monitor-table th:nth-child(3) { width: 21%; }
|
||||
.monitor-table th:nth-child(4) { width: 8%; }
|
||||
.monitor-table th:nth-child(5) { width: 7%; }
|
||||
.monitor-table th:nth-child(6) { width: 11%; }
|
||||
.monitor-table th:nth-child(7) { width: 17%; }
|
||||
.monitor-table th:nth-child(8) { width: 12%; }
|
||||
/* 表格列宽:状态 / 服务 / 目标 / 延迟 / 结果 / 最近检测 / 心率 / 90天可用率 = 100%
|
||||
地址与结果列给足比例,避免长 URL、长名称被截断 */
|
||||
.monitor-table th:nth-child(1) { width: 7%; }
|
||||
.monitor-table th:nth-child(2) { width: 15%; }
|
||||
.monitor-table th:nth-child(3) { width: 24%; }
|
||||
.monitor-table th:nth-child(4) { width: 7%; }
|
||||
.monitor-table th:nth-child(5) { width: 9%; }
|
||||
.monitor-table th:nth-child(6) { width: 10%; }
|
||||
.monitor-table th:nth-child(7) { width: 15%; }
|
||||
.monitor-table th:nth-child(8) { width: 13%; }
|
||||
.monitor-table th {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
@@ -400,18 +401,18 @@ body[data-view="table"] .grid { display: block; }
|
||||
tr[data-status="up"] .t-state { color: var(--up-text); }
|
||||
tr[data-status="down"] .t-state { color: var(--down-text); }
|
||||
tr[data-status="pending"] .t-state { color: var(--pending-text); }
|
||||
.t-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.t-name { white-space: normal; overflow-wrap: anywhere; }
|
||||
.t-name .type-badge { margin-left: 8px; }
|
||||
.t-target {
|
||||
max-width: 280px;
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
font-size: 11.5px;
|
||||
line-height: 1.45;
|
||||
color: var(--text-2);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
word-break: break-all;
|
||||
}
|
||||
.t-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.t-num { font-variant-numeric: tabular-nums; white-space: normal; overflow-wrap: anywhere; }
|
||||
|
||||
/* 证书 / 维护徽标:出现在名称旁,不占独立列 */
|
||||
.tls-badge, .maint-badge {
|
||||
@@ -429,11 +430,105 @@ tr[data-status="pending"] .t-state { color: var(--pending-text); }
|
||||
.maint-badge { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
|
||||
.card-head .tls-badge, .card-head .maint-badge { flex: none; }
|
||||
.t-hb svg { display: block; width: 100%; max-width: 150px; height: 24px; }
|
||||
.t-uptime { white-space: nowrap; }
|
||||
.t-uptime { white-space: normal; }
|
||||
/* 可用率条随视口伸缩;极窄时只留百分比,避免挤压其他列 */
|
||||
.uptime-bar-mini { display: inline-flex; width: clamp(40px, 8vw, 110px); height: 8px; margin-right: 8px; vertical-align: middle; }
|
||||
.uptime-bar-mini { display: inline-flex; width: clamp(32px, 6vw, 84px); height: 8px; margin-right: 6px; vertical-align: middle; }
|
||||
.t-pct { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
|
||||
@media (max-width: 640px) {
|
||||
.uptime-bar-mini { display: none; }
|
||||
}
|
||||
|
||||
/* ---------- 最近事件:时间线风格(故障 / 恢复 / 证书提醒) ---------- */
|
||||
.events {
|
||||
max-width: 1200px;
|
||||
margin: 18px auto 0;
|
||||
padding: 0 20px;
|
||||
}
|
||||
.events-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
|
||||
.events-head h2 { margin: 0; font-size: 13px; font-weight: 650; color: var(--text); letter-spacing: 0.02em; }
|
||||
.events-count { font-size: 11px; color: var(--text-2); }
|
||||
.events-more {
|
||||
margin-left: auto;
|
||||
padding: 3px 10px;
|
||||
font-size: 11px;
|
||||
color: var(--accent);
|
||||
background: color-mix(in srgb, var(--accent) 8%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.events-more:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
|
||||
|
||||
/* 左侧竖线 + 每行圆点,构成时间线;行本身仍是浅色卡片 */
|
||||
.events-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 2px 0 2px 16px;
|
||||
position: relative;
|
||||
}
|
||||
.events-list::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 8px;
|
||||
bottom: 8px;
|
||||
width: 1px;
|
||||
background: var(--border);
|
||||
}
|
||||
.ev {
|
||||
position: relative;
|
||||
display: grid;
|
||||
/* 名称列按内容自适应,详情列吃掉剩余宽度 —— 避免短名称后面拖出一大片空白 */
|
||||
grid-template-columns: 62px 46px auto minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
border-radius: 9px;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
font-size: 12px;
|
||||
min-width: 0;
|
||||
}
|
||||
.ev + .ev { margin-top: 4px; }
|
||||
.ev::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: -14px;
|
||||
top: 50%;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
margin-top: -3.5px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-2);
|
||||
box-shadow: 0 0 0 3px var(--bg);
|
||||
}
|
||||
.ev-down { border-left: 3px solid var(--down); }
|
||||
.ev-up { border-left: 3px solid var(--up); }
|
||||
.ev-tls { border-left: 3px solid var(--pending); }
|
||||
.ev-down::before { background: var(--down); }
|
||||
.ev-up::before { background: var(--up); }
|
||||
.ev-tls::before { background: var(--pending); }
|
||||
.ev-time { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.ev-type { font-weight: 650; text-align: center; border-radius: 999px; padding: 2px 0; font-size: 11px; }
|
||||
.ev-down .ev-type { background: var(--down-bg); color: var(--down-text); }
|
||||
.ev-up .ev-type { background: var(--up-bg); color: var(--up-text); }
|
||||
.ev-tls .ev-type { background: var(--pending-bg); color: var(--pending-text); }
|
||||
.ev-maint { margin-left: 6px; border-radius: 999px; padding: 0 6px; font-size: 10px; font-weight: 650; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
|
||||
.ev-name { font-weight: 600; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
||||
.ev-detail { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
||||
.events-empty { margin: 0; padding: 12px; font-size: 12px; color: var(--text-2); background: var(--surface); border: 1px dashed var(--border); border-radius: 10px; }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.ev { grid-template-columns: 56px 44px minmax(0, 1fr); gap: 8px; }
|
||||
.ev-detail { display: none; }
|
||||
.events { padding: 0 14px; }
|
||||
}
|
||||
|
||||
/* ---------- 卡片:90 天日均延迟趋势 ---------- */
|
||||
.lat-trend { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
|
||||
.lat-label { font-size: 11px; color: var(--text-2); flex: none; }
|
||||
.lat-bars { display: flex; align-items: flex-end; gap: 1px; height: 20px; flex: 1; min-width: 0; }
|
||||
.lat-cell { flex: 1; min-width: 2px; background: color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 1px; }
|
||||
.lat-cell:hover { background: var(--accent); }
|
||||
.lat-avg { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; flex: none; }
|
||||
|
||||
|
||||
+2
-1
@@ -55,6 +55,7 @@
|
||||
<div class="events-head">
|
||||
<h2>最近事件</h2>
|
||||
<span class="events-count" id="events-count"></span>
|
||||
<button type="button" class="events-more" id="events-more" hidden>展开全部</button>
|
||||
</div>
|
||||
<ul class="events-list" id="events-list"></ul>
|
||||
<p class="events-empty" id="events-empty" hidden>暂无事件记录(故障、恢复与证书提醒会出现在这里)</p>
|
||||
@@ -67,7 +68,7 @@
|
||||
<span id="notify-badge" class="footer-item" hidden>通知 –</span>
|
||||
<span id="updated-at" class="footer-item">–</span>
|
||||
<span id="countdown" class="footer-item">–</span>
|
||||
<span class="footer-item version">shiroko-monitor v0.11.0</span>
|
||||
<span class="footer-item version">shiroko-monitor v0.11.1</span>
|
||||
</footer>
|
||||
|
||||
<script type="module" src="assets/app.js"></script>
|
||||
|
||||
+536
-629
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user