From 885929f3fff08a1e9f4d9b6d15a2cc9c58e431c2 Mon Sep 17 00:00:00 2001 From: qinglong Date: Thu, 11 Jun 2026 12:47:39 +0800 Subject: [PATCH] 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 --- static/web_panel/pages/projects.html | 2 +- static/web_panel/pages/proxy.html | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/static/web_panel/pages/projects.html b/static/web_panel/pages/projects.html index 7b778fa..7b0347e 100644 --- a/static/web_panel/pages/projects.html +++ b/static/web_panel/pages/projects.html @@ -38,7 +38,7 @@ var projects=[]; function showTab(e,t){document.querySelectorAll("#tab-running,#tab-add,#tab-git").forEach(el=>el.style.display="none");document.getElementById("tab-"+t).style.display="block";document.querySelectorAll(".tab").forEach(el=>el.classList.remove("active"));e.target.classList.add("active")} async function refresh(){ - try{var r=await fetch("/SenSu/api/projects");var d=await r.json();projects=d.projects;var h="";for(var p of projects){var cls=p.status==="running"?"status-running":p.status==="error"?"status-error":"status-stopped";h+='
'+p.name+'
'+p.status+" PID:"+(p.pid||"-")+" :"+(p.port||"-")+" "+(p.uptime?p.uptime+"s":"")+(p.proxy?" → "+p.proxy:"")+'
'}document.getElementById("project-list").innerHTML=h||"暂无项目"}catch(e){console.error(e)} + try{var r=await fetch("/SenSu/api/projects");var d=await r.json();projects=d.projects;var h="";for(var p of projects){var cls=p.status==="running"?"status-running":p.status==="error"?"status-error":"status-stopped";h+='
'+p.name+'
'+p.status+" PID:"+(p.pid||"-")+" :"+(p.port||"-")+" "+(p.uptime?p.uptime+"s":"")+(p.proxy?" → "+p.proxy:"")+'
'}document.getElementById("project-list").innerHTML=h||"
暂无项目
"}catch(e){document.getElementById("project-list").innerHTML="
引擎未就绪 (API 错误)
"} } async function addProject(){ var n=document.getElementById("proj-name").value,cmd=document.getElementById("proj-cmd").value; diff --git a/static/web_panel/pages/proxy.html b/static/web_panel/pages/proxy.html index 8637ce0..2a94408 100644 --- a/static/web_panel/pages/proxy.html +++ b/static/web_panel/pages/proxy.html @@ -14,12 +14,14 @@