币本位顶栏去掉期权资金/交易列,交易账户显示USDT/ETH/BTC
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1137,27 +1137,35 @@ function paintRealtimePnlFromSnapshot(data){
|
||||
}
|
||||
|
||||
function formatOptionsFundingLabel(usdc, usdt, eth, marginMode, underly) {
|
||||
const mode = String(marginMode || "usdc").toLowerCase();
|
||||
if (mode === "coin") {
|
||||
const parts = [];
|
||||
if (usdt !== null && usdt !== undefined && usdt !== "") {
|
||||
const n = Number(usdt);
|
||||
if (!Number.isNaN(n)) parts.push(`${n.toFixed(2)} USDT`);
|
||||
}
|
||||
if (eth !== null && eth !== undefined && eth !== "") {
|
||||
const n = Number(eth);
|
||||
if (!Number.isNaN(n)) {
|
||||
const txt = String(n.toFixed(6)).replace(/\.?0+$/, "");
|
||||
parts.push(`${txt || "0"} ${String(underly || "ETH").toUpperCase()}`);
|
||||
}
|
||||
}
|
||||
return parts.length ? parts.join(" / ") : "—";
|
||||
}
|
||||
if (usdc === null || usdc === undefined || usdc === "") return "—";
|
||||
const n = Number(usdc);
|
||||
if (Number.isNaN(n)) return "—";
|
||||
return `${n.toFixed(2)} USDC`;
|
||||
}
|
||||
function formatTradingAccountLabel(usdt, eth, btc, marginMode) {
|
||||
const mode = String(marginMode || "usdc").toLowerCase();
|
||||
if (mode !== "coin") {
|
||||
if (usdt === null || usdt === undefined || usdt === "") return "—";
|
||||
const n = Number(usdt);
|
||||
if (Number.isNaN(n)) return "—";
|
||||
return `${n.toFixed(2)}U`;
|
||||
}
|
||||
const parts = [];
|
||||
if (usdt !== null && usdt !== undefined && usdt !== "") {
|
||||
const n = Number(usdt);
|
||||
if (!Number.isNaN(n)) parts.push(`${n.toFixed(2)} USDT`);
|
||||
}
|
||||
const pushCoin = (v, ccy) => {
|
||||
if (v === null || v === undefined || v === "") return;
|
||||
const n = Number(v);
|
||||
if (Number.isNaN(n) || Math.abs(n) < 1e-12) return;
|
||||
const txt = String(n.toFixed(6)).replace(/\.?0+$/, "");
|
||||
parts.push(`${txt || "0"} ${ccy}`);
|
||||
};
|
||||
pushCoin(eth, "ETH");
|
||||
pushCoin(btc, "BTC");
|
||||
return parts.length ? parts.join(" / ") : "—";
|
||||
}
|
||||
|
||||
function setFundsFieldText(field, text){
|
||||
if(text == null || text === "") return;
|
||||
@@ -1171,6 +1179,11 @@ function applyPerpFundsVisibility(show){
|
||||
el.style.display = on ? "" : "none";
|
||||
});
|
||||
}
|
||||
function applyOptionsFundsVisibility(show){
|
||||
document.querySelectorAll("[data-options-funds='1']").forEach((el) => {
|
||||
el.style.display = show ? "" : "none";
|
||||
});
|
||||
}
|
||||
function accountSnapshotFundingMissing(data){
|
||||
if(!data || typeof data !== "object") return true;
|
||||
if(data.show_perp_funds === false){
|
||||
@@ -1190,9 +1203,13 @@ function accountSnapshotFundingMissing(data){
|
||||
let accountSnapshotRetryCount = 0;
|
||||
function applyAccountSnapshot(data){
|
||||
if(!data || typeof data !== "object") return;
|
||||
const coinMode = String(data.options_margin_mode || "usdc").toLowerCase() === "coin";
|
||||
if(typeof data.show_perp_funds !== "undefined"){
|
||||
applyPerpFundsVisibility(data.show_perp_funds);
|
||||
applyPerpFundsVisibility(data.show_perp_funds !== false || coinMode);
|
||||
} else if (coinMode) {
|
||||
applyPerpFundsVisibility(true);
|
||||
}
|
||||
applyOptionsFundsVisibility(!coinMode);
|
||||
if(data.funding_usdt != null && data.funding_usdt !== ""){
|
||||
setFundsFieldText("total-capital", `${Number(data.funding_usdt).toFixed(2)}U`);
|
||||
}
|
||||
@@ -1200,9 +1217,17 @@ function applyAccountSnapshot(data){
|
||||
setFundsFieldText("total-funds", `${Number(data.total_funds).toFixed(2)}U`);
|
||||
}
|
||||
if(data.current_capital != null && data.current_capital !== "" && !Number.isNaN(Number(data.current_capital))){
|
||||
setFundsFieldText("current-capital", `${Number(data.current_capital).toFixed(2)}U`);
|
||||
setFundsFieldText(
|
||||
"current-capital",
|
||||
formatTradingAccountLabel(
|
||||
data.current_capital,
|
||||
data.options_trading_eth,
|
||||
data.options_trading_btc,
|
||||
data.options_margin_mode
|
||||
)
|
||||
);
|
||||
}
|
||||
if(data.options_funding_usdc != null || data.options_funding_usdt != null || data.options_funding_eth != null){
|
||||
if(!coinMode && (data.options_funding_usdc != null || data.options_funding_usdt != null || data.options_funding_eth != null)){
|
||||
const optFunding = formatOptionsFundingLabel(
|
||||
data.options_funding_usdc,
|
||||
data.options_funding_usdt,
|
||||
@@ -1212,7 +1237,7 @@ function applyAccountSnapshot(data){
|
||||
);
|
||||
setFundsFieldText("options-funding-usdc", optFunding);
|
||||
}
|
||||
if(data.options_trading_usdc != null || data.options_trading_usdt != null || data.options_trading_eth != null){
|
||||
if(!coinMode && (data.options_trading_usdc != null || data.options_trading_usdt != null || data.options_trading_eth != null)){
|
||||
const optTrading = formatOptionsFundingLabel(
|
||||
data.options_trading_usdc,
|
||||
data.options_trading_usdt,
|
||||
|
||||
@@ -1618,27 +1618,35 @@ function paintRealtimePnlFromSnapshot(data){
|
||||
}
|
||||
|
||||
function formatOptionsFundingLabel(usdc, usdt, eth, marginMode, underly) {
|
||||
const mode = String(marginMode || "usdc").toLowerCase();
|
||||
if (mode === "coin") {
|
||||
const parts = [];
|
||||
if (usdt != null && usdt !== "") {
|
||||
const n = Number(usdt);
|
||||
if (!Number.isNaN(n)) parts.push(`${n.toFixed(2)} USDT`);
|
||||
}
|
||||
if (eth != null && eth !== "") {
|
||||
const n = Number(eth);
|
||||
if (!Number.isNaN(n)) {
|
||||
const txt = String(n.toFixed(6)).replace(/\.?0+$/, "");
|
||||
parts.push(`${txt || "0"} ${String(underly || "ETH").toUpperCase()}`);
|
||||
}
|
||||
}
|
||||
return parts.length ? parts.join(" / ") : "—";
|
||||
}
|
||||
if(usdc == null || usdc === "") return "—";
|
||||
const n = Number(usdc);
|
||||
if(Number.isNaN(n)) return "—";
|
||||
return `${n.toFixed(2)} USDC`;
|
||||
}
|
||||
function formatTradingAccountLabel(usdt, eth, btc, marginMode) {
|
||||
const mode = String(marginMode || "usdc").toLowerCase();
|
||||
if (mode !== "coin") {
|
||||
if (usdt == null || usdt === "") return "—";
|
||||
const n = Number(usdt);
|
||||
if (Number.isNaN(n)) return "—";
|
||||
return `${n.toFixed(2)}U`;
|
||||
}
|
||||
const parts = [];
|
||||
if (usdt != null && usdt !== "") {
|
||||
const n = Number(usdt);
|
||||
if (!Number.isNaN(n)) parts.push(`${n.toFixed(2)} USDT`);
|
||||
}
|
||||
const pushCoin = (v, ccy) => {
|
||||
if (v == null || v === "") return;
|
||||
const n = Number(v);
|
||||
if (Number.isNaN(n) || Math.abs(n) < 1e-12) return;
|
||||
const txt = String(n.toFixed(6)).replace(/\.?0+$/, "");
|
||||
parts.push(`${txt || "0"} ${ccy}`);
|
||||
};
|
||||
pushCoin(eth, "ETH");
|
||||
pushCoin(btc, "BTC");
|
||||
return parts.length ? parts.join(" / ") : "—";
|
||||
}
|
||||
|
||||
function setFundsFieldText(field, text){
|
||||
if(text == null || text === "") return;
|
||||
@@ -1652,6 +1660,11 @@ function applyPerpFundsVisibility(show){
|
||||
el.style.display = on ? "" : "none";
|
||||
});
|
||||
}
|
||||
function applyOptionsFundsVisibility(show){
|
||||
document.querySelectorAll("[data-options-funds='1']").forEach((el) => {
|
||||
el.style.display = show ? "" : "none";
|
||||
});
|
||||
}
|
||||
function accountSnapshotFundingMissing(data){
|
||||
if(!data || typeof data !== "object") return true;
|
||||
if(data.show_perp_funds === false){
|
||||
@@ -1671,9 +1684,13 @@ function accountSnapshotFundingMissing(data){
|
||||
let accountSnapshotRetryCount = 0;
|
||||
function applyAccountSnapshot(data){
|
||||
if(!data || typeof data !== "object") return;
|
||||
const coinMode = String(data.options_margin_mode || "usdc").toLowerCase() === "coin";
|
||||
if(typeof data.show_perp_funds !== "undefined"){
|
||||
applyPerpFundsVisibility(data.show_perp_funds);
|
||||
applyPerpFundsVisibility(data.show_perp_funds !== false || coinMode);
|
||||
} else if (coinMode) {
|
||||
applyPerpFundsVisibility(true);
|
||||
}
|
||||
applyOptionsFundsVisibility(!coinMode);
|
||||
if(data.funding_usdt != null && data.funding_usdt !== ""){
|
||||
setFundsFieldText("total-capital", `${Number(data.funding_usdt).toFixed(2)}U`);
|
||||
}
|
||||
@@ -1681,9 +1698,17 @@ function applyAccountSnapshot(data){
|
||||
setFundsFieldText("total-funds", `${Number(data.total_funds).toFixed(2)}U`);
|
||||
}
|
||||
if(data.current_capital != null && data.current_capital !== "" && !Number.isNaN(Number(data.current_capital))){
|
||||
setFundsFieldText("current-capital", `${Number(data.current_capital).toFixed(2)}U`);
|
||||
setFundsFieldText(
|
||||
"current-capital",
|
||||
formatTradingAccountLabel(
|
||||
data.current_capital,
|
||||
data.options_trading_eth,
|
||||
data.options_trading_btc,
|
||||
data.options_margin_mode
|
||||
)
|
||||
);
|
||||
}
|
||||
if(data.options_funding_usdc != null || data.options_funding_usdt != null || data.options_funding_eth != null){
|
||||
if(!coinMode && (data.options_funding_usdc != null || data.options_funding_usdt != null || data.options_funding_eth != null)){
|
||||
const optFunding = formatOptionsFundingLabel(
|
||||
data.options_funding_usdc,
|
||||
data.options_funding_usdt,
|
||||
@@ -1693,7 +1718,7 @@ function applyAccountSnapshot(data){
|
||||
);
|
||||
setFundsFieldText("options-funding-usdc", optFunding);
|
||||
}
|
||||
if(data.options_trading_usdc != null || data.options_trading_usdt != null || data.options_trading_eth != null){
|
||||
if(!coinMode && (data.options_trading_usdc != null || data.options_trading_usdt != null || data.options_trading_eth != null)){
|
||||
const optTrading = formatOptionsFundingLabel(
|
||||
data.options_trading_usdc,
|
||||
data.options_trading_usdt,
|
||||
|
||||
@@ -38,11 +38,13 @@
|
||||
{% include 'instance_header_stats.html' %}
|
||||
</div>
|
||||
<div class="instance-header-phone-strip instance-phone-only" aria-label="手机资金摘要">
|
||||
<span class="inst-phone-chip"{% if not (show_perp_funds|default(true)) %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
{% set _coin_margin = (options_margin_mode|default('usdc')) == 'coin' %}
|
||||
{% set _show_perp = (show_perp_funds|default(true)) or _coin_margin %}
|
||||
<span class="inst-phone-chip"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<em>交易</em>
|
||||
<b data-funds-field="current-capital">{{ funds_fmt(current_capital) }}U</b>
|
||||
<b data-funds-field="current-capital">{{ trading_account_label(current_capital, options_trading_eth, options_trading_btc, margin_mode=options_margin_mode|default('usdc')) }}</b>
|
||||
</span>
|
||||
<span class="inst-phone-chip"{% if not (show_perp_funds|default(true)) %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<span class="inst-phone-chip"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<em>资金</em>
|
||||
<b data-funds-field="total-capital">{% if funding_usdt is not none %}{{ funds_fmt(funding_usdt) }}U{% else %}—{% endif %}</b>
|
||||
</span>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
{# 资金与统计条(顶栏 / 系统设置共用,单行展示) #}
|
||||
{% set _coin_margin = (options_margin_mode|default('usdc')) == 'coin' %}
|
||||
{% set _show_perp = (show_perp_funds|default(true)) or _coin_margin %}
|
||||
<div class="instance-header-stats{% if options_enabled %} instance-header-stats--options{% endif %}">
|
||||
<div class="stat-strip-item stat-strip-item--primary">
|
||||
<div class="label">交易所</div>
|
||||
@@ -24,20 +26,20 @@
|
||||
<div class="label">总资金</div>
|
||||
<div class="value" id="total-funds" data-funds-field="total-funds">{% if total_funds is not none %}{{ funds_fmt(total_funds) }}U{% else %}—{% endif %}</div>
|
||||
</div>
|
||||
<div class="stat-strip-item"{% if not (show_perp_funds|default(true)) %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<div class="stat-strip-item"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<div class="label">资金账户</div>
|
||||
<div class="value" id="total-capital" data-funds-field="total-capital">{% if funding_usdt is not none %}{{ funds_fmt(funding_usdt) }}U{% else %}—{% endif %}</div>
|
||||
</div>
|
||||
<div class="stat-strip-item"{% if not (show_perp_funds|default(true)) %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<div class="stat-strip-item"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<div class="label">交易账户</div>
|
||||
<div class="value" id="current-capital" data-funds-field="current-capital">{{ funds_fmt(current_capital) }}U</div>
|
||||
<div class="value" id="current-capital" data-funds-field="current-capital">{{ trading_account_label(current_capital, options_trading_eth, options_trading_btc, margin_mode=options_margin_mode|default('usdc')) }}</div>
|
||||
</div>
|
||||
{% if options_enabled %}
|
||||
<div class="stat-strip-item">
|
||||
{% if options_enabled and not _coin_margin %}
|
||||
<div class="stat-strip-item" data-options-funds="1">
|
||||
<div class="label">期权资金账户</div>
|
||||
<div class="value" id="options-funding-usdc" data-funds-field="options-funding-usdc">{{ options_funding_label(options_funding_usdc, options_funding_usdt, options_funding_eth, options_margin_mode, options_underly|default('ETH')) }}</div>
|
||||
</div>
|
||||
<div class="stat-strip-item">
|
||||
<div class="stat-strip-item" data-options-funds="1">
|
||||
<div class="label">期权交易账户</div>
|
||||
<div class="value" id="options-trading-usdc" data-funds-field="options-trading-usdc">{{ options_funding_label(options_trading_usdc, options_trading_usdt, options_trading_eth, options_margin_mode, options_underly|default('ETH')) }}</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user