Preserve settings transfer sub-tab after manual transfer in embed shell.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-26 08:37:26 +08:00
parent d870178b83
commit a7b75895e6
5 changed files with 43 additions and 11 deletions
+2 -2
View File
@@ -9870,7 +9870,7 @@ def manual_transfer():
amount = float(request.form.get("amount", "0"))
except Exception:
flash("划转金额格式错误")
return redirect("/settings?tab=transfer")
return redirect("/settings?settings_tab=transfer")
from_account = (request.form.get("from_account") or AUTO_TRANSFER_FROM).strip()
to_account = (request.form.get("to_account") or AUTO_TRANSFER_TO).strip()
ok, msg, _ = execute_transfer_usdt(amount, from_account, to_account)
@@ -9885,7 +9885,7 @@ def manual_transfer():
flash(f"手动划转成功:{amount}U {from_account}->{to_account}")
else:
flash(f"手动划转失败:{msg}")
return redirect("/settings?tab=transfer")
return redirect("/settings?settings_tab=transfer")
def _journal_ai_chart_builder(row):
+2 -2
View File
@@ -9727,7 +9727,7 @@ def manual_transfer():
amount = float(request.form.get("amount", "0"))
except Exception:
flash("划转金额格式错误")
return redirect("/settings?tab=transfer")
return redirect("/settings?settings_tab=transfer")
from_account = (request.form.get("from_account") or AUTO_TRANSFER_FROM).strip()
to_account = (request.form.get("to_account") or AUTO_TRANSFER_TO).strip()
ok, msg, _ = execute_transfer_usdt(amount, from_account, to_account)
@@ -9742,7 +9742,7 @@ def manual_transfer():
flash(f"手动划转成功:{amount}U {from_account}->{to_account}")
else:
flash(f"手动划转失败:{msg}")
return redirect("/settings?tab=transfer")
return redirect("/settings?settings_tab=transfer")
def _journal_ai_chart_builder(row):
+2 -2
View File
@@ -9455,7 +9455,7 @@ def manual_transfer():
amount = float(request.form.get("amount", "0"))
except Exception:
flash("划转金额格式错误")
return redirect("/settings?tab=transfer")
return redirect("/settings?settings_tab=transfer")
from_account = (request.form.get("from_account") or AUTO_TRANSFER_FROM).strip()
to_account = (request.form.get("to_account") or AUTO_TRANSFER_TO).strip()
ok, msg, _ = execute_transfer_usdt(amount, from_account, to_account)
@@ -9477,7 +9477,7 @@ def manual_transfer():
flash(f"手动划转成功:{amount}U {from_account}->{to_account}")
else:
flash(f"手动划转失败:{msg}")
return redirect("/settings?tab=transfer")
return redirect("/settings?settings_tab=transfer")
def _journal_ai_chart_builder(row):
+16
View File
@@ -84,6 +84,11 @@ def embed_shell_enabled() -> bool:
return (os.getenv("HUB_EMBED_SHELL") or "1").strip().lower() in ("1", "true", "yes", "on")
_SETTINGS_SUB_TABS = frozenset(
{"nav", "password", "transfer", "export", "options_swap", "options_transfer"}
)
def redirect_to_embed_shell_if_enabled(page: str):
"""直连 /trade 等整页路由时,重定向到 embed 壳(顶栏常驻,tab 软切换)."""
if not embed_shell_enabled():
@@ -93,6 +98,12 @@ def redirect_to_embed_shell_if_enabled(page: str):
if (request.path or "").rstrip("/") == "/embed":
return None
q = {k: v for k, v in request.args.items()}
# embed 的 tab=页面名;系统设置内页签用 settings_tab,避免 /settings?tab=transfer 被覆盖成 tab=settings
if (page or "").strip() == "settings":
sub = (q.get("settings_tab") or "").strip()
legacy = (q.get("tab") or "").strip()
if not sub and legacy in _SETTINGS_SUB_TABS:
q["settings_tab"] = legacy
q["tab"] = page
q["embed"] = "1"
return redirect("/embed?" + urlencode(q))
@@ -115,6 +126,11 @@ def rewrite_embed_dest(path: str, hub_theme: str | None = None) -> str:
tab = path_to_embed_tab(split.path)
q = dict(parse_qsl(split.query, keep_blank_values=True))
if tab:
if tab == "settings":
sub = (q.get("settings_tab") or "").strip()
legacy = (q.get("tab") or "").strip()
if not sub and legacy in _SETTINGS_SUB_TABS:
q["settings_tab"] = legacy
q["tab"] = tab
q["embed"] = "1"
ht = (hub_theme or q.get("hub_theme") or "").strip().lower()
+21 -5
View File
@@ -6,16 +6,21 @@
</div>
{% if settings_tabs %}
{% set active_settings_tab = (request.args.get('tab') or '').strip() %}
{% set ns = namespace(active_idx=0) %}
{% set _sub = (request.args.get('settings_tab') or '').strip() %}
{% set _legacy_tab = (request.args.get('tab') or '').strip() %}
{% set ns = namespace(active_idx=0, active_key='') %}
{% for tab in settings_tabs %}
{% if active_settings_tab and tab.key == active_settings_tab %}
{% if _sub and tab.key == _sub %}
{% set ns.active_idx = loop.index0 %}
{% set ns.active_key = tab.key %}
{% elif (not _sub) and _legacy_tab and tab.key == _legacy_tab %}
{% set ns.active_idx = loop.index0 %}
{% set ns.active_key = tab.key %}
{% endif %}
{% endfor %}
<div class="env-config-body card settings-config-body">
<div class="env-config-body card settings-config-body" data-settings-active-tab="{{ ns.active_key }}">
{% for tab in settings_tabs %}
<input type="radio" name="settings-section" id="settings-sec-{{ loop.index0 }}" class="env-tab-radio"{% if loop.index0 == ns.active_idx %} checked{% endif %}>
<input type="radio" name="settings-section" id="settings-sec-{{ loop.index0 }}" class="env-tab-radio" data-settings-tab="{{ tab.key }}"{% if loop.index0 == ns.active_idx %} checked{% endif %}>
{% endfor %}
<div class="env-config-tabs" role="tablist" aria-label="系统设置分类">
{% for tab in settings_tabs %}
@@ -59,3 +64,14 @@
{% include 'options_settings_panel.html' %}
{% endif %}
</div>
<script>
(function () {
try {
var q = new URLSearchParams(window.location.search || "");
var key = (q.get("settings_tab") || "").trim();
if (!key) return;
var radio = document.querySelector('input.env-tab-radio[data-settings-tab="' + key + '"]');
if (radio) radio.checked = true;
} catch (e) {}
})();
</script>