v1.3.15: 四页测速加预计用时(标题/按钮/等待提示)
This commit is contained in:
1 parent
392f6a737c
commit
d53c616f34
3 files changed
+7
-7
No files matched your search
+5
-5
@@ -62,7 +62,7 @@ button.refresh{background:#20a53a;color:#fff;border:none;border-radius:3px;paddi
|
||||
<div class="tab" data-t="net">网络</div>
|
||||
<div style="margin-left:auto;display:flex;align-items:center;gap:12px;padding-right:16px;font-size:12px">
|
||||
<span id="licBell" onclick="toggleAnn()" title="公告" style="cursor:pointer;position:relative;font-size:15px">🔔<i id="licDot" style="display:none;position:absolute;top:-2px;right:-4px;width:8px;height:8px;border-radius:50%;background:#f00"></i></span>
|
||||
<span id="licVer" onclick="checkVer(true)" title="点击检查新版本" style="color:#999;cursor:pointer">v1.3.14</span>
|
||||
<span id="licVer" onclick="checkVer(true)" title="点击检查新版本" style="color:#999;cursor:pointer">v1.3.15</span>
|
||||
<label style="color:#999">刷新 <select id="ival" onchange="setIval(this.value)" style="border:1px solid #ddd;border-radius:3px;padding:2px 4px;color:#333"><option value="3">3s</option><option value="5">5s</option><option value="10">10s</option><option value="30">30s</option><option value="60">60s</option></select></label>
|
||||
<button id="pauseBtn" onclick="togglePause()" style="background:#ff9900;color:#fff;border:none;border-radius:3px;padding:3px 10px;cursor:pointer">⏸ 停止刷新</button>
|
||||
<a href="https://nav.88531.cn" target="_blank" style="color:#20a53a;text-decoration:none">资享导航站</a>
|
||||
@@ -224,12 +224,12 @@ showBench('net');
|
||||
}
|
||||
}catch(e){if(manual)alert('加载失败: '+e)}
|
||||
}
|
||||
const BENCH_TXT={cpu:['🏃 系统运行速度测试','20万次整数运算,分数越高越快;自动记录当前性能模式/governor/平均MHz,方便对比省电/平衡/高性能三档效果'],mem:['💾 内存读写测速','32MB内存写入/读取,测完即释放,不占内存'],disk:['💽 硬盘读写测速','32MB临时文件写(含落盘)/读,测完自动删除,不占空间'],net:['🌐 网络上下行测速','Cloudflare测速点:下行5MB/上行2MB,约需几秒到十几秒']};
|
||||
const BENCH_TXT={cpu:['🏃 系统运行速度测试','20万次整数运算,分数越高越快;自动记录当前性能模式/governor/平均MHz,方便对比省电/平衡/高性能三档效果','预计约1秒'],mem:['💾 内存读写测速','32MB内存写入/读取,测完即释放,不占内存','预计约1秒'],disk:['💽 硬盘读写测速','32MB临时文件写(含落盘)/读,测完自动删除,不占空间','预计约1~3秒'],net:['🌐 网络上下行测速','Cloudflare测速点:下行5MB/上行2MB','预计约5~15秒(看网速)']};
|
||||
function benchHist(k){try{return JSON.parse(localStorage.getItem('fnos_bench_'+k)||'[]')}catch(e){return[]}}
|
||||
function benchPush(k,t){try{const h=benchHist(k);h.unshift(t);localStorage.setItem('fnos_bench_'+k,JSON.stringify(h.slice(0,5)))}catch(e){}}
|
||||
function renderBench(k,msg){const el=document.getElementById(k+'bench');if(!el)return;const T=BENCH_TXT[k],h=benchHist(k);el.innerHTML='<div class="model">'+T[0]+'</div><div class="mut">'+T[1]+'</div><div style="margin-top:6px"><button class="benchbtn" id="benchbtn_'+k+'" onclick="runBench(\''+k+'\')">开始测速</button> <span id="benchmsg_'+k+'" class="mut">'+(msg||'')+'</span></div>'+(h.length?'<div class="benchhist">历史记录(最多5条,超出自动删旧):<br>'+h.map(x=>esc(x)).join('<br>')+'</div>':'<div class="benchhist">暂无测速记录,点「开始测速」跑一次</div>')}
|
||||
function renderBench(k,msg){const el=document.getElementById(k+'bench');if(!el)return;const T=BENCH_TXT[k],h=benchHist(k);el.innerHTML='<div class="model">'+T[0]+' <span class="mut">⏱ '+T[2]+'</span></div><div class="mut">'+T[1]+'</div><div style="margin-top:6px"><button class="benchbtn" id="benchbtn_'+k+'" onclick="runBench(\''+k+'\')">开始测速('+T[2]+')</button> <span id="benchmsg_'+k+'" class="mut">'+(msg||'')+'</span></div>'+(h.length?'<div class="benchhist">历史记录(最多5条,超出自动删旧):<br>'+h.map(x=>esc(x)).join('<br>')+'</div>':'<div class="benchhist">暂无测速记录,点「开始测速」跑一次</div>')}
|
||||
function showBench(k){const el=document.getElementById(k+'bench');if(!el)return;el.style.display='';if(!el.innerHTML)renderBench(k)}
|
||||
async function runBench(k){const b=document.getElementById('benchbtn_'+k),m=document.getElementById('benchmsg_'+k);if(b){b.disabled=true;b.textContent='测速中…'}if(m)m.textContent='正在测速,请稍候(网络测速约需十几秒)';try{const r=await fetch('/api/bench/'+k,{method:'POST'});const j=await r.json();let line='';if(j.ok){if(k==='cpu')line=j.at+' ['+j.mode+'|'+(j.governor||'-')+'] '+j.ms+'ms '+j.kops+'kops AVG'+j.mhz_avg+'MHz';else if(k==='mem')line=j.at+' W'+j.write_mbs+'MB/s R'+j.read_mbs+'MB/s';else if(k==='disk')line=j.at+' W'+j.write_mbs+'MB/s R'+j.read_mbs+'MB/s '+(j.file||'');else if(k==='net')line=j.at+' DOWN'+j.down_mbps+'Mbps'+(j.up_mbps?' UP'+j.up_mbps+'Mbps':' UPFAIL');benchPush(k,line);renderBench(k,'OK '+line)}else renderBench(k,'FAIL '+(j.error||'ERR'))}catch(e){renderBench(k,'FAIL '+e)}}
|
||||
async function runBench(k){const b=document.getElementById('benchbtn_'+k),m=document.getElementById('benchmsg_'+k);if(b){b.disabled=true;b.textContent='测速中…'}if(m)m.textContent='正在测速,请稍候('+BENCH_TXT[k][2]+')';try{const r=await fetch('/api/bench/'+k,{method:'POST'});const j=await r.json();let line='';if(j.ok){if(k==='cpu')line=j.at+' ['+j.mode+'|'+(j.governor||'-')+'] '+j.ms+'ms '+j.kops+'kops AVG'+j.mhz_avg+'MHz';else if(k==='mem')line=j.at+' W'+j.write_mbs+'MB/s R'+j.read_mbs+'MB/s';else if(k==='disk')line=j.at+' W'+j.write_mbs+'MB/s R'+j.read_mbs+'MB/s '+(j.file||'');else if(k==='net')line=j.at+' DOWN'+j.down_mbps+'Mbps'+(j.up_mbps?' UP'+j.up_mbps+'Mbps':' UPFAIL');benchPush(k,line);renderBench(k,'OK '+line)}else renderBench(k,'FAIL '+(j.error||'ERR'))}catch(e){renderBench(k,'FAIL '+e)}}
|
||||
load(true);
|
||||
let ivalSec=3,timer=null,paused=false;
|
||||
function startTimer(){if(timer)clearInterval(timer);if(!paused)timer=setInterval(()=>load(false),ivalSec*1000)}
|
||||
@@ -238,7 +238,7 @@ function togglePause(){paused=!paused;document.getElementById('pauseBtn').textCo
|
||||
startTimer();
|
||||
async function licPoll(){try{const r=await fetch('/api/license-config',{cache:'no-store'});const j=await r.json();LIC=j;
|
||||
const dot=document.getElementById('licDot');if(dot)dot.style.display=(j.announcements&&j.announcements.length)?'':'none';
|
||||
const v=document.getElementById('licVer');if(v)v.textContent='v'+(j.version||'1.3.14')+(j.update_available?' ●':'');
|
||||
const v=document.getElementById('licVer');if(v)v.textContent='v'+(j.version||'1.3.15')+(j.update_available?' ●':'');
|
||||
if(j.popup&&j.popup.length){try{const seen=JSON.parse(localStorage.getItem('fnos_ann_seen')||'[]');const fresh=j.popup.filter(a=>seen.indexOf(a.id)<0);if(fresh.length){const a=fresh[0];const el=document.getElementById('annPop');el.innerHTML=`<div style="display:flex;justify-content:space-between;align-items:center"><b>📢 ${esc(a.title||'公告')}</b><span onclick="dismissPop(${a.id})" style="cursor:pointer;color:#999">✕</span></div><div style="margin-top:6px">${a.content||''}</div>`;el.style.display='';}}catch(e){}}
|
||||
if(document.getElementById('annPanel').style.display!=='none')renderAnn();}catch(e){}}
|
||||
function renderAnn(){const el=document.getElementById('annPanel');const list=LIC.announcements||[];el.innerHTML=list.length?(`<b>📢 公告(${list.length})</b>`+list.map(a=>`<div style="margin-top:8px;padding-top:8px;border-top:1px dashed #eee"><div><b>${esc(a.title||'')}</b></div><div style="color:#666">${a.content||''}</div></div>`).join('')):'<span style="color:#999">暂无公告</span>';}
|
||||
|
||||
Reference in new issue
Block a user