总览持仓展示出场;内嵌打开改为打开并去掉新标签。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+30
-14
@@ -24,12 +24,36 @@
|
||||
.replace(/"/g, """);
|
||||
}
|
||||
|
||||
function formatExitBrief(p) {
|
||||
if (p && p.target_monitor_text && String(p.target_monitor_text).trim() && p.target_monitor_text !== "—") {
|
||||
return String(p.target_monitor_text).trim();
|
||||
}
|
||||
const parts = [];
|
||||
const tgt = Number(p && p.target_index);
|
||||
if (Number.isFinite(tgt) && tgt > 0) {
|
||||
const ot = String((p && p.opt_type) || "").toUpperCase();
|
||||
const side = ot === "P" ? "Put≤" : ot === "C" ? "Call≥" : "目标";
|
||||
parts.push(side + " " + tgt);
|
||||
}
|
||||
if (p && p.profit_exit_enabled) {
|
||||
const m = Number(p.profit_exit_mult);
|
||||
if (Number.isFinite(m) && m > 0) {
|
||||
parts.push(Math.abs(m - Math.round(m)) < 1e-9 ? Math.round(m) + "倍" : m + "倍");
|
||||
} else {
|
||||
parts.push("利润出场");
|
||||
}
|
||||
}
|
||||
return parts.length ? parts.join(" · ") : "未设出场";
|
||||
}
|
||||
|
||||
function positionSummary(brief) {
|
||||
const list = brief || [];
|
||||
if (!list.length) return '<span class="muted">暂无持仓</span>';
|
||||
const items = list.slice(0, 8).map(function (p) {
|
||||
const id = p.inst_id || "";
|
||||
const sheets = escapeHtml(String(p.sheets != null ? p.sheets : "—"));
|
||||
const exitText = formatExitBrief(p);
|
||||
const exitCls = exitText === "未设出场" ? "muted" : "";
|
||||
return (
|
||||
"<li>" +
|
||||
escapeHtml(id) +
|
||||
@@ -37,7 +61,11 @@
|
||||
sheets +
|
||||
"张 · " +
|
||||
fmtPnlHtml(p.pnl_usdt) +
|
||||
"</li>"
|
||||
'<div class="pos-exit ' +
|
||||
exitCls +
|
||||
'">出场: ' +
|
||||
escapeHtml(exitText) +
|
||||
"</div></li>"
|
||||
);
|
||||
});
|
||||
const more =
|
||||
@@ -233,10 +261,7 @@
|
||||
'<td><div class="overview-actions">' +
|
||||
'<a class="btn" href="/desk?id=' +
|
||||
encodeURIComponent(row.id) +
|
||||
'">内嵌打开</a>' +
|
||||
'<button type="button" class="btn" data-open-tab="' +
|
||||
encodeURIComponent(row.id) +
|
||||
'">新标签</button>' +
|
||||
'">打开</a>' +
|
||||
closeActionButtons(brief, row.id, online) +
|
||||
"</div></td>" +
|
||||
"</tr>"
|
||||
@@ -442,15 +467,6 @@
|
||||
"</tr></thead><tbody>" +
|
||||
list.map(renderRow).join("") +
|
||||
"</tbody></table></div>";
|
||||
grid.querySelectorAll("[data-open-tab]").forEach(function (btn) {
|
||||
btn.addEventListener("click", async function () {
|
||||
const id = btn.getAttribute("data-open-tab");
|
||||
const rr = await fetch("/api/instances/" + id + "/open_url");
|
||||
const dd = await rr.json();
|
||||
if (dd.ok && dd.url) window.open(dd.url, "_blank", "noopener");
|
||||
else alert(dd.msg || "无法打开");
|
||||
});
|
||||
});
|
||||
grid.querySelectorAll("[data-close-opt]").forEach(function (btn) {
|
||||
btn.addEventListener("click", function () {
|
||||
requestClose(btn);
|
||||
|
||||
Reference in New Issue
Block a user