diff --git a/lib/common/static/instance_embed.js b/lib/common/static/instance_embed.js
index 70c4843..8b49187 100644
--- a/lib/common/static/instance_embed.js
+++ b/lib/common/static/instance_embed.js
@@ -108,23 +108,11 @@
if (!revisit && tab === "stats") {
if (typeof global.initStatsSegmentFromUrl === "function") global.initStatsSegmentFromUrl();
}
- if (!revisit && (tab === "settings" || tab === "env_config")) {
+ if (tab === "settings" || tab === "env_config") {
if (global.InstanceSettingsPrefs) {
- if (tab === "settings" && typeof global.InstanceSettingsPrefs.loadDisplayPrefsForm === "function") {
- global.InstanceSettingsPrefs.loadDisplayPrefsForm();
+ if (typeof global.InstanceSettingsPrefs.bindEvents === "function") {
+ global.InstanceSettingsPrefs.bindEvents();
}
- if (tab === "env_config") {
- if (typeof global.InstanceSettingsPrefs.loadEnvConfig === "function") {
- global.InstanceSettingsPrefs.loadEnvConfig();
- }
- if (typeof global.InstanceSettingsPrefs.bindEnvTabs === "function") {
- global.InstanceSettingsPrefs.bindEnvTabs();
- }
- }
- }
- }
- if (revisit && (tab === "settings" || tab === "env_config")) {
- if (global.InstanceSettingsPrefs) {
if (tab === "settings" && typeof global.InstanceSettingsPrefs.loadDisplayPrefsForm === "function") {
global.InstanceSettingsPrefs.loadDisplayPrefsForm();
}
diff --git a/lib/common/static/instance_settings_prefs.js b/lib/common/static/instance_settings_prefs.js
index b3290a0..0c728fa 100644
--- a/lib/common/static/instance_settings_prefs.js
+++ b/lib/common/static/instance_settings_prefs.js
@@ -57,6 +57,11 @@
}
function displayPrefsRoot() {
+ const settingsPane = document.querySelector('.embed-tab-pane[data-embed-pane="settings"]');
+ if (settingsPane) {
+ const inSettings = settingsPane.querySelector("#display-prefs-form");
+ if (inSettings) return inSettings;
+ }
const pane = document.querySelector(".embed-tab-pane.is-active-pane");
if (pane) {
const inPane = pane.querySelector("#display-prefs-form");
@@ -65,6 +70,15 @@
return document.getElementById("display-prefs-form");
}
+ function displayPrefsStatusEl() {
+ const card = document.getElementById("display-prefs-card");
+ if (card) {
+ const el = card.querySelector("#display-prefs-status");
+ if (el) return el;
+ }
+ return document.getElementById("display-prefs-status");
+ }
+
function envConfigRoot() {
const activePane = document.querySelector(".embed-tab-pane.is-active-pane");
if (activePane) {
@@ -122,10 +136,14 @@
}
async function saveDisplayPrefs() {
- const status = document.getElementById("display-prefs-status");
+ const status = displayPrefsStatusEl();
const root = displayPrefsRoot();
+ if (!root) {
+ setStatus(status, "未找到导航设置表单", true);
+ return;
+ }
const display = {};
- (root ? root.querySelectorAll("input[data-pref-key]") : []).forEach((cb) => {
+ root.querySelectorAll("input[data-pref-key]").forEach((cb) => {
display[cb.dataset.prefKey] = !!cb.checked;
});
try {
@@ -355,17 +373,19 @@
}
}
+ function bindClickOnce(id, handler) {
+ const el = document.getElementById(id);
+ if (!el || el.dataset.bound === "1") return;
+ el.dataset.bound = "1";
+ el.addEventListener("click", handler);
+ }
+
function bindEvents() {
- const dSave = document.getElementById("display-prefs-save");
- if (dSave) dSave.addEventListener("click", saveDisplayPrefs);
- const eSave = document.getElementById("env-config-save");
- if (eSave) eSave.addEventListener("click", () => saveEnvConfig(false));
- const eRestart = document.getElementById("env-config-save-restart");
- if (eRestart) eRestart.addEventListener("click", () => saveEnvConfig(true));
- const eReload = document.getElementById("env-config-reload");
- if (eReload) eReload.addEventListener("click", () => loadEnvConfig(true));
- const pSave = document.getElementById("pwd-save-btn");
- if (pSave) pSave.addEventListener("click", savePassword);
+ bindClickOnce("display-prefs-save", saveDisplayPrefs);
+ bindClickOnce("env-config-save", () => saveEnvConfig(false));
+ bindClickOnce("env-config-save-restart", () => saveEnvConfig(true));
+ bindClickOnce("env-config-reload", () => loadEnvConfig(true));
+ bindClickOnce("pwd-save-btn", savePassword);
}
function initPage() {
@@ -381,6 +401,7 @@
loadDisplayPrefsForm,
loadEnvConfig,
bindEnvTabs,
+ bindEvents,
restartInstance,
};
diff --git a/lib/instance/templates/embed_shell.html b/lib/instance/templates/embed_shell.html
index 4882e0a..6d0d199 100644
--- a/lib/instance/templates/embed_shell.html
+++ b/lib/instance/templates/embed_shell.html
@@ -103,8 +103,8 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj
-
+
-
+