fix(hub): archive chart perpetual label and trade row highlight

Label archive K-lines as USDT swap in title and API; highlight the full trade row when opening its chart.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-11 19:56:55 +08:00
parent a9637fafb2
commit a87234f627
5 changed files with 52 additions and 6 deletions
+28 -2
View File
@@ -66,6 +66,8 @@
let inited = false;
let markAuto = true;
let lastCandles = [];
let chartExchangeSymbol = "";
let chartMarketType = "swap";
let searchTimer = null;
function esc(s) {
@@ -309,13 +311,27 @@
scheduleChartResize();
}
function formatChartContractLabel(sym, exchangeSymbol, marketType) {
const base = String(sym || "—");
const mt = String(marketType || "").toLowerCase();
if (mt === "swap" || (exchangeSymbol && String(exchangeSymbol).indexOf(":") >= 0)) {
return base + " 永续";
}
return base;
}
function updateChartTitle() {
if (!elChartTitle) return;
if (!selected) {
elChartTitle.textContent = "—";
return;
}
elChartTitle.textContent = selected.symbol + " · " + exchangeLabel(selected.exchange_key);
const label = formatChartContractLabel(
selected.symbol,
chartExchangeSymbol,
chartMarketType
);
elChartTitle.textContent = label + " · " + exchangeLabel(selected.exchange_key);
}
async function apiFetch(url, opts) {
@@ -871,6 +887,8 @@
setStatus(j.detail || "K 线加载失败");
return;
}
chartExchangeSymbol = j.exchange_symbol || "";
chartMarketType = j.market_type || "swap";
if (chart) {
destroyChart();
}
@@ -900,7 +918,14 @@
}
updateChartTitle();
scheduleChartResize();
setStatus("K 线 " + candles.length + " 根 · " + timeframe);
setStatus(
"K 线 " +
candles.length +
" 根 · " +
timeframe +
" · " +
formatChartContractLabel(selected.symbol, chartExchangeSymbol, chartMarketType)
);
}
async function openTradeChart(tr) {
@@ -913,6 +938,7 @@
}
selected = { exchange_key: exKey, symbol: sym };
selectedTradeId = String(tr.trade_id || tr.id);
renderTrades();
setChartOpen(true);
await loadSymbolTradesForChart(exKey, sym);
await loadChart();