币本位 env 隐藏门控 USDC 倍数项,USDC 模式隐藏币本位倍数
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -351,6 +351,7 @@
|
|||||||
body.dataset.envModeSectionIdx = String(modeSectionIdx);
|
body.dataset.envModeSectionIdx = String(modeSectionIdx);
|
||||||
bindTradeModeAutoRefresh(body);
|
bindTradeModeAutoRefresh(body);
|
||||||
bindCompoundBudgetVisibility(body);
|
bindCompoundBudgetVisibility(body);
|
||||||
|
bindMarginModeGateVisibility(body);
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,6 +363,12 @@
|
|||||||
return input ? input.closest(".env-field-row") : null;
|
return input ? input.closest(".env-field-row") : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setEnvRowHidden(row, hidden) {
|
||||||
|
if (!row) return;
|
||||||
|
row.hidden = !!hidden;
|
||||||
|
row.style.display = hidden ? "none" : "";
|
||||||
|
}
|
||||||
|
|
||||||
function syncCompoundBudgetVisibility(body) {
|
function syncCompoundBudgetVisibility(body) {
|
||||||
if (!body) return;
|
if (!body) return;
|
||||||
const compoundSel = body.querySelector(
|
const compoundSel = body.querySelector(
|
||||||
@@ -370,8 +377,18 @@
|
|||||||
const budgetRow = envFieldRowByKey(body, "OKX_OPTIONS_TRADE_BUDGET_USDC");
|
const budgetRow = envFieldRowByKey(body, "OKX_OPTIONS_TRADE_BUDGET_USDC");
|
||||||
if (!budgetRow) return;
|
if (!budgetRow) return;
|
||||||
const compoundOn = !compoundSel || String(compoundSel.value || "").toLowerCase() === "true";
|
const compoundOn = !compoundSel || String(compoundSel.value || "").toLowerCase() === "true";
|
||||||
budgetRow.hidden = compoundOn;
|
setEnvRowHidden(budgetRow, compoundOn);
|
||||||
budgetRow.style.display = compoundOn ? "none" : "";
|
}
|
||||||
|
|
||||||
|
function syncMarginModeGateVisibility(body) {
|
||||||
|
if (!body) return;
|
||||||
|
const modeSel = body.querySelector(
|
||||||
|
'.env-field-input[data-env-key="OKX_OPTIONS_MARGIN_MODE"]'
|
||||||
|
);
|
||||||
|
const mode = String((modeSel && modeSel.value) || "coin").toLowerCase();
|
||||||
|
const coinMode = mode !== "usdc";
|
||||||
|
setEnvRowHidden(envFieldRowByKey(body, "OKX_OPTIONS_CLOSE_RECYCLE_MULT_USDC"), coinMode);
|
||||||
|
setEnvRowHidden(envFieldRowByKey(body, "OKX_OPTIONS_CLOSE_RECYCLE_MULT_COIN"), !coinMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindCompoundBudgetVisibility(body) {
|
function bindCompoundBudgetVisibility(body) {
|
||||||
@@ -385,6 +402,17 @@
|
|||||||
compoundSel.addEventListener("change", () => syncCompoundBudgetVisibility(body));
|
compoundSel.addEventListener("change", () => syncCompoundBudgetVisibility(body));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bindMarginModeGateVisibility(body) {
|
||||||
|
if (!body) return;
|
||||||
|
syncMarginModeGateVisibility(body);
|
||||||
|
const modeSel = body.querySelector(
|
||||||
|
'.env-field-input[data-env-key="OKX_OPTIONS_MARGIN_MODE"]'
|
||||||
|
);
|
||||||
|
if (!modeSel || modeSel.dataset.marginGateBound === "1") return;
|
||||||
|
modeSel.dataset.marginGateBound = "1";
|
||||||
|
modeSel.addEventListener("change", () => syncMarginModeGateVisibility(body));
|
||||||
|
}
|
||||||
|
|
||||||
function bindTradeModeAutoRefresh(body) {
|
function bindTradeModeAutoRefresh(body) {
|
||||||
const modeSel = body.querySelector('.env-field-input[data-env-key="OKX_TRADE_MODE"]');
|
const modeSel = body.querySelector('.env-field-input[data-env-key="OKX_TRADE_MODE"]');
|
||||||
if (!modeSel || modeSel.dataset.modeRefreshBound === "1") return;
|
if (!modeSel || modeSel.dataset.modeRefreshBound === "1") return;
|
||||||
|
|||||||
Vendored
+27
-13
@@ -537,7 +537,7 @@ def build_env_ui_payload(
|
|||||||
_build_field(key, label, note, schema, values)
|
_build_field(key, label, note, schema, values)
|
||||||
for key, label, note in sec["fields"]
|
for key, label, note in sec["fields"]
|
||||||
]
|
]
|
||||||
fields = _mark_compound_budget_hidden(fields)
|
fields = _mark_options_env_field_visibility(fields)
|
||||||
groups.append({
|
groups.append({
|
||||||
"title": sec["title"],
|
"title": sec["title"],
|
||||||
"fields": fields,
|
"fields": fields,
|
||||||
@@ -546,26 +546,40 @@ def build_env_ui_payload(
|
|||||||
return groups
|
return groups
|
||||||
|
|
||||||
|
|
||||||
def _mark_compound_budget_hidden(fields: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
def _mark_options_env_field_visibility(fields: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||||
"""全仓复利开启时标记单笔预算为 hidden(供 SSR/前端隐藏;切换开关仍可再显示)."""
|
"""按本位/全仓复利隐藏无关项(供 SSR/前端;切换开关仍可再显示)."""
|
||||||
compound_on = True
|
compound_on = True
|
||||||
|
margin_mode = "coin"
|
||||||
for f in fields:
|
for f in fields:
|
||||||
if f.get("key") == "OKX_OPTIONS_COMPOUND_FULL_ENABLED":
|
key = f.get("key")
|
||||||
compound_on = _env_truthy(str(f.get("current") or f.get("default") or "true"))
|
cur = str(f.get("current") or f.get("default") or "").strip()
|
||||||
break
|
if key == "OKX_OPTIONS_COMPOUND_FULL_ENABLED":
|
||||||
if not compound_on:
|
compound_on = _env_truthy(cur or "true")
|
||||||
return fields
|
elif key == "OKX_OPTIONS_MARGIN_MODE":
|
||||||
|
margin_mode = (cur or "coin").lower()
|
||||||
|
if margin_mode not in ("coin", "usdc"):
|
||||||
|
margin_mode = "coin"
|
||||||
out: list[dict[str, Any]] = []
|
out: list[dict[str, Any]] = []
|
||||||
for f in fields:
|
for f in fields:
|
||||||
if f.get("key") == "OKX_OPTIONS_TRADE_BUDGET_USDC":
|
item = dict(f)
|
||||||
item = dict(f)
|
key = item.get("key")
|
||||||
|
hide = False
|
||||||
|
if key == "OKX_OPTIONS_TRADE_BUDGET_USDC" and compound_on:
|
||||||
|
hide = True
|
||||||
|
if key == "OKX_OPTIONS_CLOSE_RECYCLE_MULT_USDC" and margin_mode == "coin":
|
||||||
|
hide = True
|
||||||
|
if key == "OKX_OPTIONS_CLOSE_RECYCLE_MULT_COIN" and margin_mode == "usdc":
|
||||||
|
hide = True
|
||||||
|
if hide:
|
||||||
item["hidden"] = True
|
item["hidden"] = True
|
||||||
out.append(item)
|
out.append(item)
|
||||||
else:
|
|
||||||
out.append(f)
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def _mark_compound_budget_hidden(fields: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||||
|
"""兼容旧调用名;实际走 _mark_options_env_field_visibility."""
|
||||||
|
return _mark_options_env_field_visibility(fields)
|
||||||
|
|
||||||
def filter_updates_for_ui(exchange_key: str, updates: dict[str, str]) -> dict[str, str]:
|
def filter_updates_for_ui(exchange_key: str, updates: dict[str, str]) -> dict[str, str]:
|
||||||
allowed = ui_allowed_keys(exchange_key)
|
allowed = ui_allowed_keys(exchange_key)
|
||||||
return {k: v for k, v in (updates or {}).items() if k in allowed}
|
return {k: v for k, v in (updates or {}).items() if k in allowed}
|
||||||
|
|||||||
Reference in New Issue
Block a user