From 4e71d5ba85c84d9ec50c841fbdd5dc78f5143720 Mon Sep 17 00:00:00 2001 From: hmo Date: Tue, 14 Jul 2026 03:38:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DInfrastructure=E9=87=8D?= =?UTF-8?q?=E5=A4=8D:=20=E5=88=A0=E9=99=A4=E6=97=A7=E7=89=88fetchEasyTierS?= =?UTF-8?q?tatus/RdpStatus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 旧版函数与fI内的createElement冲突导致重复出现 - 删除旧函数+interval,所有逻辑归入fI - Playwright验证: 各section出现一次,无闪 --- gateway/scripts/templates/dashboard.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/scripts/templates/dashboard.html b/gateway/scripts/templates/dashboard.html index c5f599f..66d6657 100644 --- a/gateway/scripts/templates/dashboard.html +++ b/gateway/scripts/templates/dashboard.html @@ -165,7 +165,7 @@ h+='

'+inMd(block)+'

';} return h; function inMd(t){return t.replace(/\*\*([^*]+)\*\*/g,'$1').replace(/\*([^*]+)\*/g,'$1').replace(/`([^`]+)`/g,'$1').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'$1')}} init();loadAll();setInterval(loadAll,10000);setInterval(fK,15000); -async function fetchEasyTierStatus(){try{var r=await fetch('/api/easytier'),d=await r.json(),s=d.status||{};var c=document.getElementById('ct-infra');if(!c)return;var el=document.getElementById('easytier-section');if(!el){el=document.createElement('div');el.id='easytier-section';el.innerHTML='

EasyTier VPN

Windows
246
-
';c.appendChild(el);var ob=document.getElementById('btn-et-on');var ofb=document.getElementById('btn-et-off');if(ob)ob.onclick=function(){fetch('/api/easytier/toggle',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({action:'start'})}).then(function(){setTimeout(fetchEasyTierStatus,2000);toast('EasyTier On OK')}).catch(function(e){toast('EasyTier On FAIL','err')})};if(ofb)ofb.onclick=function(){fetch('/api/easytier/toggle',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({action:'stop'})}).then(function(){setTimeout(fetchEasyTierStatus,2000);toast('EasyTier Off OK')}).catch(function(e){toast('EasyTier Off FAIL','err')})};}var e1=document.getElementById('et-w');if(e1)e1.className='d '+(s.windows==='running'?'ok':'stopped');var e2=document.getElementById('et-246');if(e2)e2.className='d '+(s['246']==='running'?'ok':'stopped');if(d.virtual_ips){var w=document.getElementById('et-w-ip');if(w)w.textContent=d.virtual_ips.windows||'';var t=document.getElementById('et-246-ip');if(t)t.textContent=d.virtual_ips['246']||''}var allRunning=Object.values(s).every(function(v){return v==='running'||v==='pending'});var onBtn=document.getElementById('btn-et-on');var offBtn=document.getElementById('btn-et-off');var stxt=document.getElementById('et-status');if(onBtn)onBtn.disabled=allRunning;if(offBtn)offBtn.disabled=!allRunning;if(stxt)stxt.textContent=allRunning?'Connected':'Off'}catch(e){}} -async function fetchRdpStatus(){try{var r=await fetch('/api/rdp'),d=await r.json();var c=document.getElementById('ct-infra');if(!c)return;var el=document.getElementById('rdp-section');if(!el){el=document.createElement('div');el.id='rdp-section';el.innerHTML='

RDP Remote Desktop

RDP
Tunnel
-
';c.appendChild(el);var ob=document.getElementById('btn-rdp-on');var ofb=document.getElementById('btn-rdp-off');if(ob)ob.onclick=function(){fetch('/api/rdp/toggle',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({action:'start'})}).then(function(){setTimeout(fetchRdpStatus,2000);toast('RDP On OK')}).catch(function(e){toast('RDP On FAIL','err')})};if(ofb)ofb.onclick=function(){fetch('/api/rdp/toggle',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({action:'stop'})}).then(function(){setTimeout(fetchRdpStatus,2000);toast('RDP Off OK')}).catch(function(e){toast('RDP Off FAIL','err')})};}var e1=document.getElementById('rdp-st');if(e1)e1.className='d '+(d.rdp_enabled?'ok':'stopped');var e2=document.getElementById('rdp-tun');if(e2)e2.className='d '+(d.tunnel_running?'ok':'stopped');var info=document.getElementById('rdp-info');if(info)info.textContent=d.public_endpoint||'';var fullyOn=d.rdp_enabled&&d.tunnel_running;var onBtn=document.getElementById('btn-rdp-on');var offBtn=document.getElementById('btn-rdp-off');var stxt=document.getElementById('rdp-status-txt');if(onBtn)onBtn.disabled=fullyOn;if(offBtn)offBtn.disabled=!fullyOn;if(stxt)stxt.textContent=fullyOn?'Connected':d.rdp_enabled?'Tunnel pending':'Disconnected'}catch(e){}} -fetchEasyTierStatus();fetchRdpStatus();setInterval(fetchEasyTierStatus,10000);setInterval(fetchRdpStatus,10000);setInterval(fE,10000);setInterval(fR,10000); + + +setInterval(fE,10000);setInterval(fR,10000); \ No newline at end of file