feat: 设备池默认只看在线——离线旧条目(IP 已变的幽灵设备)默认隐藏,在线优先排序;「只看在线」开关可切换查看全部(含离线/停用)
This commit is contained in:
@@ -393,9 +393,16 @@ async function loadDevPool(){
|
||||
tb.innerHTML='<tr><td colspan="7" class="empty">加载中...</td></tr>';
|
||||
const r=await apiGet('/api/devices/pool');
|
||||
if(!r||!r.ok){tb.innerHTML='<tr><td colspan="7" class="empty">加载失败</td></tr>';return;}
|
||||
const rows=r.devices||[];
|
||||
let rows=r.devices||[];
|
||||
// 在线优先排序;「只看在线」勾选时过滤掉离线(IP 换了/长期离线的旧条目不再碍眼)
|
||||
const onlyOnline=document.getElementById('devpool-filter-online')
|
||||
? document.getElementById('devpool-filter-online').checked : false;
|
||||
rows.sort((a,b)=>(b.online?1:0)-(a.online?1:0));
|
||||
if(onlyOnline)rows=rows.filter(x=>x.online);
|
||||
const onlineCnt=rows.filter(x=>x.online).length;
|
||||
status.textContent='共 '+rows.length+' 台,在线 '+onlineCnt+' 台';
|
||||
status.textContent=onlyOnline
|
||||
? '在线 '+rows.length+' 台(共 '+(r.devices||[]).length+' 台配置)'
|
||||
: '共 '+rows.length+' 台,在线 '+onlineCnt+' 台';
|
||||
tb.innerHTML=rows.map(d=>{
|
||||
const st= d.enabled
|
||||
? '<span class="label label-success">启用</span>'
|
||||
|
||||
@@ -680,6 +680,9 @@ body{background:var(--bg);font-family:var(--body);color:var(--text);font-size:14
|
||||
<button class="btn" onclick="reconnectPoolDevices()" title="并发 adb connect 池内全部设备">一键重连</button>
|
||||
<button class="btn" onclick="refreshPoolModels()" title="采集池内在线设备的型号(getprop)">采集型号</button>
|
||||
<button class="btn" onclick="loadDevPool()">刷新</button>
|
||||
<label style="display:inline-flex;align-items:center;gap:4px;margin:0 6px">
|
||||
<input type="checkbox" id="devpool-filter-online" checked onchange="loadDevPool()"> 只看在线
|
||||
</label>
|
||||
<span id="devpool-status" class="text-muted"></span>
|
||||
</div>
|
||||
<table class="table table-hover table-sm" style="margin-top:8px">
|
||||
|
||||
Reference in New Issue
Block a user