Fix instance nav display prefs save in embed shell.
Re-bind save button when settings tab loads lazily; scope form lookup to settings pane. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj
|
||||
<script>
|
||||
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
|
||||
</script>
|
||||
<script src="/static/instance_settings_prefs.js?v=10"></script>
|
||||
<script src="/static/instance_settings_prefs.js?v=11"></script>
|
||||
<script src="/static/instance_live.js?v=4"></script>
|
||||
<script src="/static/instance_embed.js?v=20"></script>
|
||||
<script src="/static/instance_embed.js?v=21"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -2038,6 +2038,6 @@ setInterval(refreshPriceSnapshotConditional, {{ price_refresh_seconds * 1000 }})
|
||||
<script>
|
||||
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
|
||||
</script>
|
||||
<script src="/static/instance_settings_prefs.js?v=10"></script>
|
||||
<script src="/static/instance_settings_prefs.js?v=11"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user