总览与客户端实例按 sim 在上 live 在下排序,实例表增加模式列。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-04 10:17:05 +08:00
parent d9bf3f7915
commit 50963a25fc
5 changed files with 184 additions and 98 deletions
+32 -2
View File
@@ -255,7 +255,19 @@
status +
"</td>" +
"<td>" +
escapeHtml(inst.mode || "—") +
(function () {
const m = String(inst.mode || "").toLowerCase();
if (m === "sim" || m === "live") {
return (
'<span class="overview-mode-tag overview-mode-tag--' +
m +
'">' +
escapeHtml(m) +
"</span>"
);
}
return escapeHtml(inst.mode || "—");
})() +
"</td>" +
"<td>" +
fmtPnlHtml(pnl) +
@@ -472,6 +484,24 @@
"</tbody></table></div>";
}
function modeSortKey(mode) {
const m = String(mode || "").toLowerCase();
if (m === "sim") return 0;
if (m === "live") return 1;
return 2;
}
function sortInstancesByMode(list) {
return (list || []).slice().sort(function (a, b) {
const ma = modeSortKey((((a || {}).snapshot || {}).instance || {}).mode);
const mb = modeSortKey((((b || {}).snapshot || {}).instance || {}).mode);
if (ma !== mb) return ma - mb;
const ia = Number((a && a.id) || 0);
const ib = Number((b && b.id) || 0);
return ia - ib;
});
}
async function refresh() {
const status = document.getElementById("overview-status");
const grid = document.getElementById("overview-grid");
@@ -481,7 +511,7 @@
const r = await fetch("/api/overview");
const d = await r.json();
if (!d.ok) throw new Error(d.msg || "失败");
const list = d.instances || [];
const list = sortInstancesByMode(d.instances || []);
renderOverviewSummary(list);
if (!list.length) {
grid.innerHTML =