修复「重试卖回」按钮:有持仓时正确隐藏,标的按 BTC/ETH 残留与当前选择显示。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-04 07:05:13 +08:00
parent 886ef82573
commit b79f309c5b
5 changed files with 21 additions and 7 deletions
+13 -3
View File
@@ -2270,13 +2270,21 @@
}
function spotSellUnderlying(ss) {
if (!ss) return (state.underlying || "ETH").toUpperCase();
if (ss.bridge_underlying) return String(ss.bridge_underlying).toUpperCase();
const selected = (state.underlying || "ETH").toUpperCase();
if (!ss) return selected;
const bridgeUly = String(ss.bridge_underlying || "").trim().toUpperCase();
const eth = Number(ss.trading_eth || 0);
const btc = Number(ss.trading_btc || 0);
// 待卖回桥优先;否则优先当前选中标的上的残留,再比大小
if (bridgeUly === "BTC" || bridgeUly === "ETH") {
if (ss.bridge_status === "pending_sell_spot") return bridgeUly;
}
if (selected === "BTC" && btc > 1e-12) return "BTC";
if (selected === "ETH" && eth > 1e-12) return "ETH";
if (btc > eth && btc > 1e-12) return "BTC";
if (eth > 1e-12) return "ETH";
return (ss.default_underly || state.underlying || "ETH").toUpperCase();
if (bridgeUly === "BTC" || bridgeUly === "ETH") return bridgeUly;
return (ss.default_underly || selected || "ETH").toUpperCase();
}
function paintSpotSellBanner(d, positions) {
@@ -2784,6 +2792,8 @@
btn.classList.add("active");
state.underlying = btn.getAttribute("data-uly");
loadChain();
// 切换 ETH/BTC 时重刷持仓区,以便「重试卖回」标的与当前选择同步
refreshAllPositions();
});
});