| | |
| | | <div class="sidebar"> |
| | | <div class="sidebar-header"> |
| | | <h1>📡 Station</h1> |
| | | <span class="refresh-badge" id="refreshBadge">⏳ 5s</span> |
| | | <button class="btn btn-outline" onclick="refreshInstanceList()" style="font-size:11px;padding:3px 10px">🔄 刷新</button> |
| | | </div> |
| | | <div class="instance-list" id="instanceList"> |
| | | <div class="empty-state"> |
| | |
| | | let instances = {}; |
| | | let eventsCache = {}; |
| | | let pnlChart = null; |
| | | let pollingTimer = null; |
| | | let pendingAction = null; |
| | | let pnlData = []; |
| | | |
| | |
| | | } |
| | | instances = newInstances; |
| | | renderInstanceList(); |
| | | // 实例数据已更新,同步刷新选中实例的概览统计与参数页状态条 |
| | | if (selectedMd5 && instances[selectedMd5]) { |
| | | renderStats(instances[selectedMd5]); |
| | | renderConfigStatusBar(); |
| | | } |
| | | } catch (e) { |
| | | // 静默失败,保留旧数据 |
| | | } |
| | | } |
| | | |
| | | // 手动刷新事件日志(对应「事件日志」Tab 的刷新按钮) |
| | | function refreshEvents() { |
| | | if (!selectedMd5) return; |
| | | loadEvents(selectedMd5); |
| | | } |
| | | |
| | | function renderInstanceList() { |
| | |
| | | header.querySelector('.instance-title').innerHTML = ` |
| | | <h2>${inst.contract || '—'} <span style="font-size:12px;color:var(--dim);font-weight:400">${md5.substring(0,12)}...</span></h2> |
| | | <span class="state-badge ${sanitizeState(inst.state)}">${inst.state || 'UNKNOWN'}</span> |
| | | <button class="btn btn-outline" onclick="refreshEvents()" style="font-size:11px;padding:3px 10px">🔄 刷新</button> |
| | | `; |
| | | $('btnStart').disabled = false; |
| | | $('btnStop').disabled = false; |
| | |
| | | |
| | | // ==================== 初始化 ==================== |
| | | function startPolling() { |
| | | poll(); // 立即执行一次 |
| | | pollingTimer = setInterval(poll, 5000); |
| | | poll(); // 页面加载时立即加载一次实例列表(不再自动轮询,改为手动刷新) |
| | | } |
| | | |
| | | // 倒计时显示 |
| | | setInterval(() => { |
| | | const badge = $('refreshBadge'); |
| | | if (badge) badge.textContent = '⏳ 5s'; |
| | | setTimeout(() => { if (badge) badge.textContent = '⏳ 4s'; }, 1000); |
| | | setTimeout(() => { if (badge) badge.textContent = '⏳ 3s'; }, 2000); |
| | | setTimeout(() => { if (badge) badge.textContent = '⏳ 2s'; }, 3000); |
| | | setTimeout(() => { if (badge) badge.textContent = '⏳ 1s'; }, 4000); |
| | | }, 5000); |
| | | |
| | | startPolling(); |
| | | </script> |