币本位隐藏 USDT↔USDC 兑换,持仓区与设置仅保留划转。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-20 15:45:11 +08:00
parent a257d7e369
commit 7ca31b74fb
5 changed files with 51 additions and 20 deletions
+20 -14
View File
@@ -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);
+9 -1
View File
@@ -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
+14 -4
View File
@@ -1,8 +1,11 @@
{# 期权页·持仓卡内:兑换 + 划转(默认折叠;独立 ID 避免与系统设置冲突) #}
<details class="opt-close-rule options-funds-fold" id="options-funds-card">
<summary>兑换 / 划转</summary>
{# 期权页·持仓卡内:划转(+ USDC 模式下的兑换);默认折叠 #}
{% set _mm = (options_margin_mode|default('coin'))|string|lower %}
{% set _coin = (_mm == 'coin') %}
<details class="opt-close-rule options-funds-fold" id="options-funds-card"{% if _coin %} data-margin-mode="coin"{% else %} data-margin-mode="usdc"{% endif %}>
<summary>{% if _coin %}划转{% else %}兑换 / 划转{% endif %}</summary>
<div class="opt-close-rule-body options-funds-fold-body">
<div class="options-settings-section">
{% if not _coin %}
<div class="options-settings-section" id="options-funds-swap-section">
<p class="options-settings-hint">账户资金账户:USDT ↔ USDC 现货市价单.</p>
<div class="form-row settings-transfer-form options-settings-row">
<input type="text" name="username" autocomplete="username" tabindex="-1" aria-hidden="true"
@@ -18,14 +21,21 @@
</div>
<div id="opt-page-swap-msg" class="options-settings-msg muted"></div>
</div>
{% endif %}
<div class="options-settings-section">
<div class="options-settings-subtitle">账户内划转</div>
<div class="form-row settings-transfer-form options-settings-row options-funds-row--single">
<input type="text" name="username" autocomplete="username" tabindex="-1" aria-hidden="true"
style="position:absolute;left:-9999px;width:1px;height:1px;opacity:0" value="">
<select id="opt-page-int-ccy" aria-label="币种" autocomplete="off">
{% if _coin %}
<option value="USDT" selected>USDT</option>
<option value="ETH">ETH</option>
<option value="BTC">BTC</option>
{% else %}
<option value="USDC" selected>USDC</option>
<option value="USDT">USDT</option>
{% endif %}
</select>
<select id="opt-page-int-from" aria-label="划出账户">
<option value="funding" selected>from: 资金</option>
@@ -1,3 +1,3 @@
{# 期权设置脚本挂载点(卡片在 settings_panel 中拆分) #}
<div id="options-settings-root" hidden></div>
<script src="/static/options_settings.js?v=11"></script>
<script src="/static/options_settings.js?v=12"></script>
@@ -4,8 +4,15 @@
<input type="text" name="username" autocomplete="username" tabindex="-1" aria-hidden="true"
style="position:absolute;left:-9999px;width:1px;height:1px;opacity:0" value="">
<select id="opt-set-int-ccy" aria-label="币种" autocomplete="off">
{% set _mm = (options_margin_mode|default('coin'))|string|lower %}
{% if _mm == 'coin' %}
<option value="USDT" selected>USDT</option>
<option value="ETH">ETH</option>
<option value="BTC">BTC</option>
{% else %}
<option value="USDC" selected>USDC</option>
<option value="USDT">USDT</option>
{% endif %}
</select>
<select id="opt-set-int-from" aria-label="划出账户">
<option value="funding" selected>from: 资金</option>