总览持仓展示出场;内嵌打开改为打开并去掉新标签。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-03 04:02:58 +08:00
parent 17bb5462ec
commit 5396fcd1f0
3 changed files with 41 additions and 15 deletions
+10
View File
@@ -403,6 +403,16 @@ button, .btn {
.pos-brief li {
margin: 2px 0;
}
.pos-exit {
margin-top: 2px;
font-size: 0.76rem;
color: var(--text);
opacity: 0.9;
}
.pos-exit.muted {
color: var(--muted);
opacity: 1;
}
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
+30 -14
View File
@@ -24,12 +24,36 @@
.replace(/"/g, "&quot;");
}
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);
+1 -1
View File
@@ -14,6 +14,6 @@
<div id="overview-grid"></div>
{% endblock %}
{% block scripts %}
<script src="{{ url_for('static', filename='hub.js') }}?v=10"></script>
<script src="{{ url_for('static', filename='hub.js') }}?v=11"></script>
<script>HubOverview.boot();</script>
{% endblock %}