feat: 优化代理准备并完善远端部署
- 增加严格代理、两分钟预取、白名单去重与分组状态展示\n- 增加远端注册令牌和安全地址校验\n- 增加 Docker Compose、Caddy 示例与控制中心部署文档
This commit is contained in:
@@ -310,6 +310,7 @@
|
||||
for (const item of instances) {
|
||||
machine.append(renderInstance(item));
|
||||
machine.append(renderResults(item));
|
||||
machine.append(renderProxyDetails(item));
|
||||
}
|
||||
machinesRoot.append(machine);
|
||||
}
|
||||
@@ -329,11 +330,17 @@
|
||||
const success = results.filter(value => String(value).startsWith('已抢到') || String(value).startsWith('成功') || String(value).includes('|积分-')).length;
|
||||
const resultCell = textNode('div', `结果 ${success}/${results.length || item.accountCount || 0}`);
|
||||
|
||||
const meta = textNode('div', `${item.accountCount || 0} 账号 · ${item.version || ''}`, 'muted');
|
||||
const proxy = item.proxyStatus;
|
||||
const proxyText = proxy?.enabled
|
||||
? `代理 ${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 actions = element('div', 'actions');
|
||||
actions.append(
|
||||
resultButton(item),
|
||||
proxyButton(item),
|
||||
logButton(item),
|
||||
commandButton(item, 'status', '刷新'),
|
||||
commandButton(item, 'stop', '停止', 'danger'),
|
||||
@@ -343,6 +350,42 @@
|
||||
return row;
|
||||
}
|
||||
|
||||
function renderProxyDetails(item) {
|
||||
const panel = element('div', 'results-details');
|
||||
panel.dataset.proxy = encodeURIComponent(`${item.machineId}:${item.instanceId}`);
|
||||
const proxy = item.proxyStatus;
|
||||
if (!proxy?.enabled) {
|
||||
panel.append(textNode('div', '当前实例未启用代理', 'muted'));
|
||||
return panel;
|
||||
}
|
||||
const summary = element('div', 'result-line');
|
||||
summary.append(
|
||||
textNode('span', `状态 ${proxy.state || 'unknown'}${proxy.required ? ' · 严格代理' : ''}`, ['direct_fallback', 'failed', 'degraded'].includes(proxy.state) ? 'bad' : 'ok'),
|
||||
textNode('span', `活动 ${proxy.activeCount || 0} · 备用 ${proxy.standbyCount || 0}/${proxy.standbyTarget || 0} · 直连 ${proxy.directCount || 0}`, 'muted')
|
||||
);
|
||||
panel.append(summary);
|
||||
for (const group of proxy.groups || []) {
|
||||
const line = element('div', 'result-line');
|
||||
line.append(
|
||||
textNode('span', `G${group.groupIndex} · ${group.accountCount || 0}号 · ${group.state || ''}`, group.state === 'direct' || group.state === 'failed' ? 'bad' : 'muted'),
|
||||
textNode('span', `${group.proxy || '-'} ${group.region ? '· ' + group.region : ''} ${group.rttMs ? '· ' + group.rttMs + 'ms' : ''} ${group.switchCount ? '· 切换 ' + group.switchCount : ''}`, 'muted')
|
||||
);
|
||||
panel.append(line);
|
||||
}
|
||||
if (proxy.lastError) panel.append(textNode('div', proxy.lastError, 'bad'));
|
||||
return panel;
|
||||
}
|
||||
|
||||
function proxyButton(item) {
|
||||
const button = element('button', '', '代理');
|
||||
button.addEventListener('click', () => {
|
||||
const key = encodeURIComponent(`${item.machineId}:${item.instanceId}`);
|
||||
const panel = machinesRoot.querySelector(`.results-details[data-proxy="${key}"]`);
|
||||
if (panel) panel.classList.toggle('open');
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
function logButton(item) {
|
||||
const button = element('button', '', '日志');
|
||||
button.addEventListener('click', () => {
|
||||
|
||||
Reference in New Issue
Block a user