总览:平仓按钮移到操作列,表格居中。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-02 16:07:23 +08:00
parent fb653c150c
commit 45464a6089
2 changed files with 52 additions and 30 deletions
+12 -7
View File
@@ -207,7 +207,6 @@ button, .btn {
cursor: not-allowed;
filter: none;
}
.pos-brief-main { min-width: 0; }
.panel {
background: var(--panel);
border: 1px solid var(--line);
@@ -227,7 +226,9 @@ button, .btn {
.inst-row { margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.overview-table-wrap {
overflow-x: auto;
margin-top: 12px;
margin: 12px auto 0;
width: fit-content;
max-width: 100%;
border: 1px solid var(--line);
border-radius: var(--radius);
background: var(--panel);
@@ -235,9 +236,17 @@ button, .btn {
backdrop-filter: blur(10px);
}
.overview-table {
width: 100%;
width: auto;
min-width: 720px;
border-collapse: collapse;
font-size: 0.88rem;
margin: 0 auto;
}
body.page-dashboard #overview-status {
text-align: center;
}
body.page-dashboard .page-head {
justify-content: center;
}
.overview-table th,
.overview-table td {
@@ -266,10 +275,6 @@ button, .btn {
}
.pos-brief li {
margin: 2px 0;
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.card-grid {
display: grid;
+40 -23
View File
@@ -24,39 +24,19 @@
.replace(/"/g, "&quot;");
}
function positionSummary(brief, instanceId, online) {
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 invalid = !!(p.bid_invalid || (p.bid_px == null && (p.bid_sz == null || p.bid_sz === "")));
const reason = (p.bid_invalid_reason || "买一无效,禁止平仓").toString();
let closeBtn = "";
if (online && id) {
if (invalid) {
closeBtn =
'<button type="button" class="btn btn-sm btn-danger" disabled title="' +
escapeHtml(reason) +
'">平仓</button>';
} else {
closeBtn =
'<button type="button" class="btn btn-sm btn-danger" data-close-inst="' +
encodeURIComponent(String(instanceId)) +
'" data-close-opt="' +
encodeURIComponent(id) +
'" title="买一限价全平">平仓</button>';
}
}
return (
"<li><span class=\"pos-brief-main\">" +
"<li>" +
escapeHtml(id) +
" · " +
sheets +
"张 · " +
fmtPnlHtml(p.pnl_usdt) +
"</span>" +
closeBtn +
"</li>"
);
});
@@ -67,6 +47,42 @@
return "<ul class=\"pos-brief\">" + items.join("") + more + "</ul>";
}
function closeActionButtons(brief, instanceId, online) {
if (!online) return "";
const list = (brief || []).filter(function (p) {
return !!(p && p.inst_id);
});
if (!list.length) return "";
return list
.slice(0, 8)
.map(function (p) {
const id = p.inst_id || "";
const invalid = !!(
p.bid_invalid ||
(p.bid_px == null && (p.bid_sz == null || p.bid_sz === ""))
);
const reason = (p.bid_invalid_reason || "买一无效,禁止平仓").toString();
const tip = list.length > 1 ? id + " · 买一限价全平" : "买一限价全平";
if (invalid) {
return (
'<button type="button" class="btn btn-danger" disabled title="' +
escapeHtml(reason) +
'">平仓</button>'
);
}
return (
'<button type="button" class="btn btn-danger" data-close-inst="' +
encodeURIComponent(String(instanceId)) +
'" data-close-opt="' +
encodeURIComponent(id) +
'" title="' +
escapeHtml(tip) +
'">平仓</button>'
);
})
.join("");
}
function fmtBidPx(v) {
if (v == null || v === "") return "—";
const n = Number(v);
@@ -148,7 +164,7 @@
fmtPnlHtml(pnl) +
"</td>" +
"<td>" +
positionSummary(brief, row.id, online) +
positionSummary(brief) +
"</td>" +
"<td>" +
bidLiquiditySummary(brief) +
@@ -163,6 +179,7 @@
'<button type="button" class="btn" data-open-tab="' +
encodeURIComponent(row.id) +
'">新标签</button>' +
closeActionButtons(brief, row.id, online) +
"</div></td>" +
"</tr>"
);