From 4abe8a6ca9134cccc915626741d821b11054b45e Mon Sep 17 00:00:00 2001 From: dekun Date: Thu, 9 Jul 2026 00:07:30 +0800 Subject: [PATCH] Fix instance settings prefs JS 404 on static route. Register instance_settings_prefs.js (and options_panel.js) in install_instance_theme_static; add delegated click handlers for embed lazy tabs. Co-authored-by: Cursor --- lib/common/static/instance_settings_prefs.js | 34 ++++++++++++++++++++ lib/hub/hub_bridge.py | 2 ++ lib/instance/templates/embed_shell.html | 2 +- lib/instance/templates/index.html | 2 +- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/common/static/instance_settings_prefs.js b/lib/common/static/instance_settings_prefs.js index 0c728fa..9e61431 100644 --- a/lib/common/static/instance_settings_prefs.js +++ b/lib/common/static/instance_settings_prefs.js @@ -373,6 +373,39 @@ } } + function installDelegatedHandlers() { + if (document.documentElement.dataset.prefsDelegateBound === "1") return; + document.documentElement.dataset.prefsDelegateBound = "1"; + document.addEventListener("click", (ev) => { + const target = ev.target; + if (!(target instanceof Element)) return; + if (target.closest("#display-prefs-save")) { + ev.preventDefault(); + void saveDisplayPrefs(); + return; + } + if (target.closest("#env-config-save")) { + ev.preventDefault(); + void saveEnvConfig(false); + return; + } + if (target.closest("#env-config-save-restart")) { + ev.preventDefault(); + void saveEnvConfig(true); + return; + } + if (target.closest("#env-config-reload")) { + ev.preventDefault(); + void loadEnvConfig(true); + return; + } + if (target.closest("#pwd-save-btn")) { + ev.preventDefault(); + void savePassword(); + } + }); + } + function bindClickOnce(id, handler) { const el = document.getElementById(id); if (!el || el.dataset.bound === "1") return; @@ -389,6 +422,7 @@ } function initPage() { + installDelegatedHandlers(); bindEvents(); loadDisplayPrefsForm(false); loadEnvConfig(false); diff --git a/lib/hub/hub_bridge.py b/lib/hub/hub_bridge.py index 00e1bc5..9d22ede 100644 --- a/lib/hub/hub_bridge.py +++ b/lib/hub/hub_bridge.py @@ -69,6 +69,8 @@ def install_instance_theme_static(app) -> None: "instance_page.css": "text/css; charset=utf-8", "instance_embed.js": "application/javascript; charset=utf-8", "instance_live.js": "application/javascript; charset=utf-8", + "instance_settings_prefs.js": "application/javascript; charset=utf-8", + "options_panel.js": "application/javascript; charset=utf-8", "order_entry_model.js": "application/javascript; charset=utf-8", "focus_chart_page.js": "application/javascript; charset=utf-8", "focus_chart_page.css": "text/css; charset=utf-8", diff --git a/lib/instance/templates/embed_shell.html b/lib/instance/templates/embed_shell.html index 6d0d199..13d306c 100644 --- a/lib/instance/templates/embed_shell.html +++ b/lib/instance/templates/embed_shell.html @@ -103,7 +103,7 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj - + diff --git a/lib/instance/templates/index.html b/lib/instance/templates/index.html index 3476158..76aad3b 100644 --- a/lib/instance/templates/index.html +++ b/lib/instance/templates/index.html @@ -2038,6 +2038,6 @@ setInterval(refreshPriceSnapshotConditional, {{ price_refresh_seconds * 1000 }}) - + \ No newline at end of file