fix: Sentinel 动态加载 chart.js + 空节点容错 + 默认为网格模式
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
<script src="/SenSu/static/js/chart.js?v=0705"></script>
|
|
||||||
<div class="plugin-page-root" style="padding:16px">
|
<div class="plugin-page-root" style="padding:16px">
|
||||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
|
||||||
<h2 style="margin:0">🛡️ Sentinel 集群监控</h2>
|
<h2 style="margin:0">🛡️ Sentinel 集群监控</h2>
|
||||||
@@ -84,6 +83,13 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// 确保 chart.js 已加载 (SPA 导航时可能未加载)
|
||||||
|
if (typeof MiniChart === 'undefined') {
|
||||||
|
var cs = document.createElement('script');
|
||||||
|
cs.src = '/SenSu/static/js/chart.js?v=0705';
|
||||||
|
document.head.appendChild(cs);
|
||||||
|
}
|
||||||
|
|
||||||
var pollTimer = null;
|
var pollTimer = null;
|
||||||
var editingId = null;
|
var editingId = null;
|
||||||
var _chartInstances = {};
|
var _chartInstances = {};
|
||||||
@@ -293,8 +299,13 @@ card.querySelector('.node-time').innerHTML = '<div style="font-size:.7rem;color:
|
|||||||
|
|
||||||
function pollNodes() {
|
function pollNodes() {
|
||||||
fetch("/sentinel/api/nodes").then(function(r){return r.json()}).then(function(d){
|
fetch("/sentinel/api/nodes").then(function(r){return r.json()}).then(function(d){
|
||||||
if (d.nodes) renderNodes(d.nodes);
|
renderNodes(d.nodes || []);
|
||||||
}).catch(function(){});
|
}).catch(function(e){
|
||||||
|
var grid = document.getElementById("sentinel-grid");
|
||||||
|
if (grid && _firstRender) {
|
||||||
|
grid.innerHTML = '<div class="card" style="text-align:center;padding:24px;color:var(--error)">连接失败 — 检查节点配置</div>';
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pollNodes();
|
pollNodes();
|
||||||
|
|||||||
Reference in New Issue
Block a user