diff --git a/lib/common/static/options_settings.js b/lib/common/static/options_settings.js index 41a3957..25aabf9 100644 --- a/lib/common/static/options_settings.js +++ b/lib/common/static/options_settings.js @@ -42,9 +42,13 @@ return window.confirm(message); } - function roundAvail(v) { + function roundAvail(v, ccy) { const n = Number(v); if (!Number.isFinite(n) || n <= 0) return null; + const u = String(ccy || "").toUpperCase(); + if (u === "ETH" || u === "BTC") { + return Math.round(n * 1e8) / 1e8; + } return Math.round(n * 100) / 100; } @@ -63,7 +67,7 @@ const c = String(ccy || "").toLowerCase(); const availKey = acct + "_" + c + "_avail"; const totalKey = acct + "_" + c; - return roundAvail(bal[availKey] != null ? bal[availKey] : bal[totalKey]); + return roundAvail(bal[availKey] != null ? bal[availKey] : bal[totalKey], ccy); } async function resolveSwapMaxAmount(dir) { @@ -130,10 +134,11 @@ function bindFundsUi(ids) { const swapBtn = document.getElementById(ids.swapBtn); - if (!swapBtn) return; + const intBtn = document.getElementById(ids.intBtn); + if (!swapBtn && !intBtn) return; - const swapBtns = [ids.swapBtn, ids.swapAllBtn]; - const intBtns = [ids.intBtn, ids.intAllBtn]; + const swapBtns = [ids.swapBtn, ids.swapAllBtn].filter(Boolean); + const intBtns = [ids.intBtn, ids.intAllBtn].filter(Boolean); async function submitSwap(amount) { setButtonsBusy(swapBtns, ids.swapAmount, true, "兑换中…"); @@ -191,14 +196,16 @@ } } - swapBtn.addEventListener("click", async function () { - const amount = parseFloat(document.getElementById(ids.swapAmount).value); - if (!amount || amount <= 0) { - setMsg(ids.swapMsg, "请输入有效数量", true); - return; - } - await submitSwap(amount); - }); + if (swapBtn) { + swapBtn.addEventListener("click", async function () { + const amount = parseFloat(document.getElementById(ids.swapAmount).value); + if (!amount || amount <= 0) { + setMsg(ids.swapMsg, "请输入有效数量", true); + return; + } + await submitSwap(amount); + }); + } const swapAllBtn = document.getElementById(ids.swapAllBtn); if (swapAllBtn) { @@ -247,7 +254,6 @@ }); } - const intBtn = document.getElementById(ids.intBtn); if (intBtn) { intBtn.addEventListener("click", async function () { const amount = parseFloat(document.getElementById(ids.intAmount).value); diff --git a/lib/instance/instance_settings_lib.py b/lib/instance/instance_settings_lib.py index 7fed9cb..694906a 100644 --- a/lib/instance/instance_settings_lib.py +++ b/lib/instance/instance_settings_lib.py @@ -132,7 +132,15 @@ def build_settings_tabs(display: dict[str, Any] | None, instance_settings: dict[ if disp.get("show_settings_export", True): tabs.append({"key": "export", "title": "数据导出"}) if inst.get("options_settings_enabled") and disp.get("show_settings_options_swap", True): - tabs.append({"key": "options_swap", "title": "币种兑换"}) + _coin = False + try: + from lib.options.options_margin_mode_lib import is_coin_margin_mode + + _coin = bool(is_coin_margin_mode()) + except Exception: + _coin = False + if not _coin: + tabs.append({"key": "options_swap", "title": "币种兑换"}) if inst.get("options_settings_enabled") and disp.get("show_settings_options_transfer", True): tabs.append({"key": "options_transfer", "title": "期权划转"}) return tabs diff --git a/lib/options/templates/options_page_funds.html b/lib/options/templates/options_page_funds.html index 03376a5..2f703ae 100644 --- a/lib/options/templates/options_page_funds.html +++ b/lib/options/templates/options_page_funds.html @@ -1,8 +1,11 @@ -{# 期权页·持仓卡内:兑换 + 划转(默认折叠;独立 ID 避免与系统设置冲突) #} -
- 兑换 / 划转 +{# 期权页·持仓卡内:划转(+ USDC 模式下的兑换);默认折叠 #} +{% set _mm = (options_margin_mode|default('coin'))|string|lower %} +{% set _coin = (_mm == 'coin') %} +
+ {% if _coin %}划转{% else %}兑换 / 划转{% endif %}
-
+ {% if not _coin %} +

账户资金账户:USDT ↔ USDC 现货市价单.

+ {% endif %}
账户内划转