Fold chain/account/PnL hints into rules; hide dust sell-coin.

Move the three noisy help lines into 规则说明, and show 手动卖回币 only when trading-coin balance meets the exchange min size.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-14 19:31:14 +08:00
parent 1d71414c56
commit ab7a2309ad
3 changed files with 110 additions and 18 deletions
+44 -13
View File
@@ -1097,7 +1097,7 @@
"</div></div>" +
"</div>" +
'<div class="hp-live-combo">' +
'<span class="muted">组合净盈亏(扣开平手续费·永续盘口均价)</span>' +
'<span class="muted" title="扣开平手续费·永续盘口均价(详见左侧规则说明)">组合净盈亏</span>' +
'<strong class="' +
comboCls +
'">' +
@@ -1577,18 +1577,55 @@
function setSellCoinMsg(text, kind) {
const el = $("hp-sell-coin-msg");
if (!el) return;
const show = !!(text || "").trim();
el.hidden = !show;
el.textContent = text || "";
el.classList.toggle("is-err", kind === "err");
el.classList.toggle("is-ok", kind === "ok");
el.classList.toggle("muted", !kind);
}
function setSellCoinVisible(visible, meta) {
const btn = $("hp-sell-coin-btn");
if (!btn) return;
const on = !!visible;
btn.hidden = !on;
btn.disabled = !on;
if (on && meta) {
const uly = String(meta.underlying || state.underlying || "ETH").toUpperCase();
const avail = meta.available != null ? Number(meta.available) : null;
const minSz = meta.min_sz != null ? Number(meta.min_sz) : null;
let tip = "市价卖出交易账户全部可用 " + uly + " 换回 USDT";
if (avail != null && !Number.isNaN(avail)) tip += " · 可用 " + avail;
if (minSz != null && !Number.isNaN(minSz)) tip += " · 最小 " + minSz;
btn.title = tip;
}
if (!on) setSellCoinMsg("", null);
}
async function refreshSellCoinVisibility() {
const uly = String(state.underlying || "ETH").toUpperCase();
try {
const d = await apiJson(
"/api/hedge-plan/sell-coin-status?underlying=" + encodeURIComponent(uly)
);
if (!d || !d.ok) {
setSellCoinVisible(false);
return;
}
setSellCoinVisible(!!d.sellable, d);
} catch (_) {
setSellCoinVisible(false);
}
}
async function submitSellCoin() {
const uly = String(state.underlying || "ETH").toUpperCase();
const btn = $("hp-sell-coin-btn");
if (!btn || btn.hidden) return;
if (!window.confirm("确认市价卖出交易账户全部可用 " + uly + " 换回 USDT?")) return;
setSellCoinMsg("卖回中…", null);
const btn = $("hp-sell-coin-btn");
if (btn) btn.disabled = true;
btn.disabled = true;
try {
const d = await apiJson("/api/hedge-plan/sell-coin", {
method: "POST",
@@ -1597,6 +1634,7 @@
});
if (!d.ok) {
setSellCoinMsg(d.msg || "卖回失败", "err");
await refreshSellCoinVisibility();
return;
}
const sold =
@@ -1606,10 +1644,10 @@
setSellCoinMsg(sold, "ok");
await loadChain();
void loadLivePositions();
await refreshSellCoinVisibility();
} catch (e) {
setSellCoinMsg(e.message || "卖回失败", "err");
} finally {
if (btn) btn.disabled = false;
await refreshSellCoinVisibility();
}
}
@@ -2059,6 +2097,7 @@
$("hp-profit-rr").value = "2";
}
}
void refreshSellCoinVisibility();
}
function currentExp(selectId) {
@@ -2186,14 +2225,6 @@
}
tbody.appendChild(tr);
});
if (isOptionPrimary() && !state.poStrikeExpandAll && state.moneyFilter === "all") {
const hintTr = document.createElement("tr");
hintTr.innerHTML =
'<td colspan="' +
cols +
'" class="muted opt-strike-hint">默认显示约 5 档(平值 + 实值2 + 虚值2) · 勾选「展开全部」查看该到期更多行权价</td>';
tbody.appendChild(hintTr);
}
tbody.querySelectorAll(".hp-pick").forEach(function (btn) {
btn.addEventListener("click", function () {
const inst = btn.getAttribute("data-inst");