feat(remote): 显示控制中心和实例版本

This commit is contained in:
yml
2026-11-22 15:26:41 +08:00
parent 0940dd8f85
commit 9ed41d6551
6 changed files with 86 additions and 6 deletions
+15 -1
View File
@@ -21,6 +21,10 @@
}
header h1 { font-size: 16px; margin: 0; white-space: nowrap; }
.muted { color: #8f9baa; }
.version-pill {
padding: 4px 8px; border: 1px solid #35404c; border-radius: 999px;
color: #9dabba; font-size: 11px; white-space: nowrap;
}
.grow { flex: 1; }
.token-box { display: flex; gap: 8px; align-items: center; }
input {
@@ -132,6 +136,7 @@
<div class="shell">
<header>
<h1>斗鱼抢购远端控制台</h1>
<span id="control-version" class="version-pill">控制中心版本加载中</span>
<span id="connection" class="muted">未连接</span>
<div class="grow"></div>
<div class="token-box">
@@ -170,6 +175,7 @@
const tokenInput = document.getElementById('token');
const connectButton = document.getElementById('connect');
const connection = document.getElementById('connection');
const controlVersion = document.getElementById('control-version');
const machinesRoot = document.getElementById('machines');
const runsRoot = document.getElementById('runs');
const summary = document.getElementById('summary');
@@ -301,6 +307,11 @@
}
function renderDashboard(data) {
const controlVersionText = String(data.controlVersion || '').split(' ')[0].replace(/^v/, '');
controlVersion.textContent = controlVersionText
? `控制中心 v${controlVersionText}`
: '控制中心版本未知';
controlVersion.title = data.controlBuildTime ? `构建时间: ${data.controlBuildTime}` : '';
const groups = new Map();
for (const item of data.instances || []) {
const key = item.machineId || item.machineName;
@@ -359,7 +370,10 @@
? `代理 ${proxy.activeCount || 0} · 备用 ${proxy.standbyCount || 0}/${proxy.standbyTarget || 0} · 直连 ${proxy.directCount || 0}`
: '本地直连';
const proxyWarning = ['direct_fallback', 'failed', 'degraded'].includes(proxy?.state);
const meta = textNode('div', `${item.accountCount || 0} 账号 · ${proxyText}`, proxyWarning ? 'bad' : 'muted');
const instanceVersion = String(item.version || '').split(' ')[0].replace(/^v/, '');
const versionText = instanceVersion ? ` · v${instanceVersion}` : '';
const meta = textNode('div', `${item.accountCount || 0} 账号 · ${proxyText}${versionText}`, proxyWarning ? 'bad' : 'muted');
meta.title = item.version ? `实例版本: ${item.version}` : '';
const actions = element('div', 'actions');
actions.append(