Replace dashboard perp profit column with stop-loss and take-profit.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-20 12:47:16 +08:00
parent 913c7d5be6
commit f467f94fe9
4 changed files with 50 additions and 12 deletions
+6
View File
@@ -278,6 +278,12 @@ body.hub-page-dashboard .page#page-dashboard {
font-variant-numeric: tabular-nums;
}
.dash-tp-program {
color: var(--dash-accent);
font-size: 0.72rem;
font-weight: 600;
}
.dash-side {
font-weight: 700;
}
+16 -8
View File
@@ -130,18 +130,25 @@
return "—";
}
function tpProfitCell(ln) {
const n = ln && ln.reward_at_tp_usdt != null ? Number(ln.reward_at_tp_usdt) : NaN;
if (!Number.isFinite(n)) return "—";
return `<span class="dash-tp-profit">${fmt(n, 2)}U</span>`;
}
function floatPnlCell(ln) {
const pnl = ln && ln.pnl != null ? Number(ln.pnl) : NaN;
if (!Number.isFinite(pnl)) return "—";
return `<span class="${pnlClass(pnl)}">${fmt(pnl, 2)}</span>`;
}
function slTpCell(ln, kind) {
if (kind === "tp") {
const note = String((ln && ln.tp_note) || "").trim();
if (note) return `<span class="dash-tp-program">${esc(note)}</span>`;
}
const raw = kind === "sl" ? ln && ln.stop_loss : ln && ln.take_profit;
if (raw == null || raw === "") return "—";
if (Number.isFinite(Number(raw))) {
return esc(fmt(raw, 4).replace(/\.?0+$/, ""));
}
return esc(String(raw));
}
function collectUnifiedPositions(accounts) {
const perp = [];
const options = [];
@@ -204,7 +211,8 @@
<td>${priceCell(ln && ln.entry_price_fmt, ln && ln.entry_price)}</td>
<td>${priceCell(ln && ln.mark_price_fmt, ln && ln.mark_price)}</td>
<td>${contracts}</td>
<td>${tpProfitCell(ln)}</td>
<td>${slTpCell(ln, "sl")}</td>
<td>${slTpCell(ln, "tp")}</td>
<td>${floatPnlCell(ln)}</td>
</tr>`;
})
@@ -214,7 +222,7 @@
<div class="dash-table-wrap">
<table class="dash-table dash-pos-table">
<thead><tr>
<th>交易所</th><th>类型</th><th>合约</th><th>方向</th><th>开仓价</th><th>标记价</th><th>张数</th><th>盈利金额</th><th>浮盈</th>
<th>交易所</th><th>类型</th><th>合约</th><th>方向</th><th>开仓价</th><th>标记价</th><th>张数</th><th>止损</th><th>止盈</th><th>浮盈</th>
</tr></thead>
<tbody>${body}</tbody>
</table>
+2 -2
View File
@@ -20,7 +20,7 @@
<link rel="stylesheet" href="/assets/trade_stats_calendar.css?v=4" />
<link rel="stylesheet" href="/assets/account_risk_badge.css?v=4" />
<script src="/assets/account_risk_badge.js?v=4"></script>
<link rel="stylesheet" href="/assets/dashboard.css?v=20260720-dash-hedge-type" />
<link rel="stylesheet" href="/assets/dashboard.css?v=20260720-dash-sl-tp" />
</head>
<body>
<div class="app-bg" aria-hidden="true"></div>
@@ -1385,7 +1385,7 @@
<script src="/assets/archive.js?v=20260717-archive-cal-chart"></script>
<script src="/assets/quotes.js?v=20260717-quotes-feed"></script>
<script src="/assets/funds.js?v=20260717-funds-scroll-fix"></script>
<script src="/assets/dashboard.js?v=20260720-dash-hedge-type"></script>
<script src="/assets/dashboard.js?v=20260720-dash-sl-tp"></script>
<script src="/assets/strategy.js?v=8"></script>
<script src="/assets/help.js?v=1"></script>
<script src="/assets/logs.js?v=1"></script>