Fix proxy/projects pages: error handling when API unavailable

- proxy: .catch() shows 'service not ready' instead of stuck loading
- projects: shows 'engine not ready' on API error
- Both: show 'no items' placeholder instead of blank
This commit is contained in:
qinglong
2026-06-11 12:47:39 +08:00
parent a1dd401efc
commit 885929f3ff
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -14,12 +14,14 @@
<script>
function refresh(){
fetch("/SenSu/api/proxy").then(r=>r.json()).then(d=>{
fetch("/SenSu/api/proxy").then(r=>{if(!r.ok)throw new Error(r.status);return r.json()}).then(d=>{
var h="";
for(var p of d.proxies||[]){
h+='<div class="mgmt-card"><div class="status-dot status-running"></div><div class="info"><b>'+p.path+'</b><br><small>→ '+p.target+(p.description?" ("+p.description+")":"")+(p.external?" 🌐":"")+'</small></div><div class="actions"><button class="btn btn-sm btn-danger" onclick="delP(\"'+p.path+'\")">删除</button></div></div>';
}
document.getElementById("proxy-list").innerHTML=h||"暂无代理"
document.getElementById("proxy-list").innerHTML=h||"<div style=\"color:var(--text-dim);text-align:center;padding:40px\">暂无代理配置</div>"
}).catch(function(e){
document.getElementById("proxy-list").innerHTML="<div style=\"color:var(--error);text-align:center;padding:40px\">代理服务未就绪 (API 返回 "+e.message+")</div>"
})
}
function addP(){