76 lines
2.4 KiB
HTML
76 lines
2.4 KiB
HTML
</main>
|
||
|
||
<!-- 页脚 -->
|
||
<footer class="border-top border-secondary mt-4 py-4">
|
||
<div class="container-fluid px-4">
|
||
<div class="row align-items-center">
|
||
<div class="col-md-6 text-muted small">
|
||
<span class="text-primary fw-bold">NAC NewAssetChain</span> 量子全息区块浏览器
|
||
| CBPP 共识 | NRPC/4.0 | CSNP 网络
|
||
</div>
|
||
<div class="col-md-6 text-end text-muted small">
|
||
<span id="ws-status" class="badge bg-secondary">WebSocket 连接中...</span>
|
||
© 2024 NewAssetChain Foundation
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
|
||
<!-- Bootstrap 5 JS 本地化 -->
|
||
<script src="/static/js/bootstrap.bundle.min.js"></script>
|
||
<!-- WebSocket 实时推送 -->
|
||
<script>
|
||
(function() {
|
||
var wsStatus = document.getElementById('ws-status');
|
||
var ws;
|
||
var reconnectTimer;
|
||
|
||
function connect() {
|
||
try {
|
||
ws = new WebSocket('wss://explorer.newassetchain.io/ws');
|
||
|
||
ws.onopen = function() {
|
||
if (wsStatus) {
|
||
wsStatus.className = 'badge bg-success';
|
||
wsStatus.textContent = '实时连接 ✓';
|
||
}
|
||
};
|
||
|
||
ws.onmessage = function(e) {
|
||
try {
|
||
var data = JSON.parse(e.data);
|
||
if (data.type === 'new_block' && typeof window.onNewBlock === 'function') {
|
||
window.onNewBlock(data.block);
|
||
}
|
||
} catch(err) {}
|
||
};
|
||
|
||
ws.onclose = function() {
|
||
if (wsStatus) {
|
||
wsStatus.className = 'badge bg-warning text-dark';
|
||
wsStatus.textContent = '重连中...';
|
||
}
|
||
reconnectTimer = setTimeout(connect, 5000);
|
||
};
|
||
|
||
ws.onerror = function() {
|
||
if (wsStatus) {
|
||
wsStatus.className = 'badge bg-danger';
|
||
wsStatus.textContent = '连接失败';
|
||
}
|
||
};
|
||
} catch(err) {
|
||
if (wsStatus) {
|
||
wsStatus.className = 'badge bg-secondary';
|
||
wsStatus.textContent = 'WebSocket 不可用';
|
||
}
|
||
}
|
||
}
|
||
|
||
// 页面加载后延迟1秒连接,避免影响首屏渲染
|
||
setTimeout(connect, 1000);
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|