diff --git a/internal/lua/plugins/quota.lua b/internal/lua/plugins/quota.lua index c72ce47..6317b21 100644 --- a/internal/lua/plugins/quota.lua +++ b/internal/lua/plugins/quota.lua @@ -682,6 +682,23 @@ PLUGIN.ui = { if(meta.length) h+='
'; return h+""; } + // paintSnapshot renders the persisted snapshot WITHOUT touching the network. + // Called on load so the page has content immediately. + async function showSnapshot(){ + try{ + var st = await pluginAPI.fetchState("quota"); + var rs = (st && st.reports) || []; + if(!rs.length) return false; + var real = rs.filter(function(r){ return r && !r.skipped; }); + var skipped = rs.filter(function(r){ return r && r.skipped; }).map(function(r){ return r.name; }); + render(real, skipped); + var sub=document.getElementById("qa-sub"); + if(sub && st.updated_at){ + sub.textContent = real.length+" 个源 · 快照 "+new Date(st.updated_at).toLocaleTimeString()+"(点刷新取实时)"; + } + return true; + }catch(e){ return false; } + } function render(reports, skipped){ var host=document.getElementById("qa-list"); if(!host) return; var real=(reports||[]).filter(function(r){return !r.skipped;}); @@ -754,7 +771,18 @@ PLUGIN.ui = { var b=document.getElementById("qa-refresh"); if(b && !b.__qaWired){ b.__qaWired=true; b.addEventListener("click",refresh); } } - mount(); refresh(); + mount(); + showSnapshot(); + // Do NOT auto-refresh on load. + // + // Probing is network-bound and every request takes the plugin's write lock, so + // a page open that fires one call per source serialises them: measured 19s to + // first paint and 22-100s to finish, with the whole WebUI held in its loading + // state meanwhile. A balance the operator did not ask for is not worth the + // first paint of the page they opened. + // + // What IS shown automatically is the last snapshot, so an operator who hits + // refresh once sees a card immediately and a fresh number behind it. if (window.pluginAPI && pluginAPI.onTabShown) pluginAPI.onTabShown(mount); window.__qaRefresh=refresh; window.__qaRender=render; })();