全仓复利开启时隐藏并禁用单笔预算;关闭后才显示可用打满预算。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-12 10:00:50 +08:00
parent 51e454b0f6
commit a8d6795837
9 changed files with 103 additions and 22 deletions
+36 -1
View File
@@ -202,6 +202,7 @@
function renderEnvFieldRow(field) {
const row = document.createElement("div");
row.className = "env-field-row" + (field.restart_required ? " env-field-row--restart" : "");
row.dataset.envKey = field.key;
const label = document.createElement("label");
label.className = "env-field-label";
label.htmlFor = "env-f-" + field.key;
@@ -345,9 +346,40 @@
body.appendChild(panelsWrap);
body.dataset.envModeSectionIdx = String(modeSectionIdx);
bindTradeModeAutoRefresh(body);
bindCompoundBudgetVisibility(body);
return body;
}
function envFieldRowByKey(body, key) {
if (!body || !key) return null;
const byRow = body.querySelector('.env-field-row[data-env-key="' + key + '"]');
if (byRow) return byRow;
const input = body.querySelector('.env-field-input[data-env-key="' + key + '"]');
return input ? input.closest(".env-field-row") : null;
}
function syncCompoundBudgetVisibility(body) {
if (!body) return;
const compoundSel = body.querySelector(
'.env-field-input[data-env-key="OKX_OPTIONS_COMPOUND_FULL_ENABLED"]'
);
const budgetRow = envFieldRowByKey(body, "OKX_OPTIONS_TRADE_BUDGET_USDC");
if (!budgetRow) return;
const compoundOn = !compoundSel || String(compoundSel.value || "").toLowerCase() === "true";
budgetRow.hidden = compoundOn;
}
function bindCompoundBudgetVisibility(body) {
if (!body) return;
syncCompoundBudgetVisibility(body);
const compoundSel = body.querySelector(
'.env-field-input[data-env-key="OKX_OPTIONS_COMPOUND_FULL_ENABLED"]'
);
if (!compoundSel || compoundSel.dataset.compoundBudgetBound === "1") return;
compoundSel.dataset.compoundBudgetBound = "1";
compoundSel.addEventListener("change", () => syncCompoundBudgetVisibility(body));
}
function bindTradeModeAutoRefresh(body) {
const modeSel = body.querySelector('.env-field-input[data-env-key="OKX_TRADE_MODE"]');
if (!modeSel || modeSel.dataset.modeRefreshBound === "1") return;
@@ -542,7 +574,10 @@
loadEnvConfig(false);
const root = envConfigRoot();
const body = root && root.querySelector("#env-config-body");
if (body) bindTradeModeAutoRefresh(body);
if (body) {
bindTradeModeAutoRefresh(body);
bindCompoundBudgetVisibility(body);
}
if (global.__INSTANCE_DISPLAY__) applyDisplayToNav(global.__INSTANCE_DISPLAY__);
}
+14 -7
View File
@@ -286,25 +286,32 @@
const ethEl = document.getElementById("opt-eth-amount");
const hint = document.getElementById("opt-budget-full-hint");
const compoundHint = document.getElementById("opt-compound-full-hint");
const budgetWrap = document.getElementById("opt-size-mode-budget-wrap");
const compoundWrap = document.getElementById("opt-size-mode-compound-wrap");
const capEl = document.getElementById("opt-budget-full-cap");
const compoundCapLine = document.getElementById("opt-compound-cap-line");
const compoundOn = compoundFullEnabled();
if (budgetWrap) {
budgetWrap.hidden = compoundOn;
const radio = budgetWrap.querySelector('input[name="opt-size-mode"]');
if (radio) radio.disabled = compoundOn;
}
if (compoundWrap) {
compoundWrap.hidden = !compoundOn;
const radio = compoundWrap.querySelector('input[name="opt-size-mode"]');
if (radio) radio.disabled = !compoundOn;
if (!compoundOn && mode === "compound_full") {
const sheetsRadio = document.querySelector('input[name="opt-size-mode"][value="sheets"]');
if (sheetsRadio) {
sheetsRadio.checked = true;
}
}
}
if (compoundOn && mode === "budget_full") {
const compoundRadio = document.querySelector('input[name="opt-size-mode"][value="compound_full"]');
if (compoundRadio) compoundRadio.checked = true;
} else if (!compoundOn && mode === "compound_full") {
const sheetsRadio = document.querySelector('input[name="opt-size-mode"][value="sheets"]');
if (sheetsRadio) sheetsRadio.checked = true;
}
const modeNow = currentSizeMode();
if (sheetsEl) sheetsEl.style.display = modeNow === "sheets" ? "" : "none";
if (ethEl) ethEl.style.display = modeNow === "eth_amount" ? "" : "none";
if (hint) hint.style.display = modeNow === "budget_full" ? "" : "none";
if (hint) hint.style.display = modeNow === "budget_full" && !compoundOn ? "" : "none";
if (compoundHint) compoundHint.style.display = modeNow === "compound_full" && compoundOn ? "" : "none";
if (capEl && root && root.dataset.tradeBudget) {
const n = Number(root.dataset.tradeBudget);