Tighten options position bar grouping and compact history table status layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-09 17:43:24 +08:00
parent af7a397816
commit 08a61fd4ae
3 changed files with 101 additions and 15 deletions
+82 -7
View File
@@ -3305,16 +3305,25 @@ html[data-theme="light"] .options-estimate-row {
align-items: center;
gap: 6px;
min-width: 0;
flex: 1 1 auto;
flex-wrap: nowrap;
flex: 0 1 auto;
overflow: hidden;
}
.opt-pos-bar-id-group {
display: inline-flex;
align-items: center;
gap: 6px;
min-width: 0;
max-width: 100%;
overflow: hidden;
}
.opt-pos-bar .pos-side-badge {
display: inline-flex;
align-items: center;
white-space: nowrap;
flex-shrink: 0;
padding: 2px 6px;
font-size: 0.62rem;
line-height: 1.15;
line-height: 1;
}
.opt-pos-cards--accordion .opt-pos-bar-meta {
display: none;
@@ -3325,9 +3334,9 @@ html[data-theme="light"] .options-estimate-row {
align-items: flex-end;
justify-content: center;
gap: 1px;
flex-shrink: 0;
flex: 0 0 auto;
margin-left: auto;
font-variant-numeric: tabular-nums;
min-width: 3.6rem;
}
.opt-pos-bar-title {
font-size: 0.68rem;
@@ -3336,8 +3345,8 @@ html[data-theme="light"] .options-estimate-row {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
flex: 1 1 auto;
min-width: 5.5rem;
flex: 0 1 auto;
min-width: 0;
}
.opt-pos-bar-meta {
font-size: 0.66rem;
@@ -3392,8 +3401,74 @@ html[data-theme="light"] .options-estimate-row {
.options-history-table-wrap {
flex: 1;
overflow-y: auto;
overflow-x: auto;
min-height: 120px;
}
.opt-history-table {
table-layout: fixed;
width: 100%;
}
.opt-history-table .opt-hist-inst code {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.opt-history-table th:nth-child(1),
.opt-history-table td:nth-child(1) {
width: 34%;
}
.opt-history-table th:nth-child(2),
.opt-history-table td:nth-child(2) {
width: 7%;
}
.opt-history-table th:nth-child(3),
.opt-history-table td:nth-child(3) {
width: 11%;
}
.opt-history-table th:nth-child(4),
.opt-history-table td:nth-child(4) {
width: 9%;
}
.opt-history-table th:nth-child(5),
.opt-history-table td:nth-child(5) {
width: 11%;
}
.opt-history-table th:nth-child(6),
.opt-history-table td:nth-child(6) {
width: 20%;
}
.opt-history-table th:nth-child(7),
.opt-history-table td:nth-child(7) {
width: 8%;
text-align: center;
}
.opt-hist-time {
font-size: 0.64rem;
white-space: nowrap;
}
.opt-hist-status {
display: inline-flex;
align-items: center;
padding: 1px 6px;
border-radius: 4px;
font-size: 0.62rem;
font-weight: 600;
line-height: 1.3;
white-space: nowrap;
}
.opt-hist-status--closed {
background: rgba(74, 124, 255, 0.2);
color: #9ec0ff;
}
.opt-hist-status--expired {
background: rgba(255, 179, 71, 0.15);
color: #ffb347;
}
.opt-hist-status--open {
background: rgba(94, 232, 154, 0.12);
color: #5ee89a;
}
@media (max-width: 1100px) {
.options-dual-grid {
grid-template-columns: 1fr;
+17 -6
View File
@@ -482,10 +482,10 @@
'<button type="button" class="opt-pos-bar" aria-expanded="' + (expanded ? "true" : "false") + '">' +
'<span class="opt-pos-bar-main">' +
'<span class="opt-pos-bar-chevron" aria-hidden="true">▶</span>' +
'<span class="opt-pos-bar-id-group">' +
'<strong class="opt-pos-bar-title" title="' + inst + '">' + inst + "</strong>" +
'<span class="pos-side-badge ' + sideCls + '">' + optTypeLabel(p.opt_type) + "</span>" +
'<span class="opt-pos-bar-meta">行权 ' + fmt(p.strike, 0) + " · " + fmt(p.pos, 0) + "张</span>" +
"</span>" +
"</span></span>" +
'<span class="opt-pos-bar-side">' +
(expAttr
? '<span class="opt-pos-bar-cd"><span class="opt-expiry-cd" data-opt-exp-ms="' + expAttr + '">—</span></span>'
@@ -659,6 +659,15 @@
return "已平";
}
function optHistoryStatusHtml(h) {
const s = optHistoryStatus(h);
let cls = "opt-hist-status";
if (s === "已平") cls += " opt-hist-status--closed";
else if (s === "到期") cls += " opt-hist-status--expired";
else cls += " opt-hist-status--open";
return '<span class="' + cls + '">' + s + "</span>";
}
async function refreshHistory() {
const d = await apiJson("/api/options/history");
const tbody = document.getElementById("opt-history-tbody");
@@ -671,16 +680,18 @@
list.forEach(function (h) {
const tr = document.createElement("tr");
const prem = h.status === "closed" ? h.premium_received : h.premium_paid;
const premTxt = prem != null ? fmt(prem, 2) : "—";
const pnl = h.realized_pnl;
const pnlTxt = pnl != null ? fmt(pnl, 2) : "—";
const pnlCls = pnl > 0 ? "pos-pnl-profit" : pnl < 0 ? "pos-pnl-loss" : "";
const timeTxt = (h.closed_at || h.created_at || "—").replace("T", " ").slice(0, 19);
tr.innerHTML =
"<td><code>" + (h.inst_id || "") + "</code></td>" +
'<td class="opt-hist-inst"><code>' + (h.inst_id || "") + "</code></td>" +
"<td>" + fmt(h.sheets, 0) + "</td>" +
"<td>" + fmt(prem, 4) + "</td>" +
"<td>" + optHistoryStatus(h) + "</td>" +
"<td>" + premTxt + "</td>" +
"<td>" + optHistoryStatusHtml(h) + "</td>" +
'<td class="' + pnlCls + '">' + pnlTxt + "</td>" +
"<td>" + (h.closed_at || h.created_at || "—") + "</td>" +
"<td class=\"opt-hist-time\">" + timeTxt + "</td>" +
'<td><button type="button" class="btn-secondary btn-sm opt-history-del" data-id="' + h.id + '" data-status="' + (h.status || "") + '">删除</button></td>';
tbody.appendChild(tr);
});