perf: embed shell soft nav, tab cache, and lighter options page boot

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-07 10:42:01 +08:00
parent 8913138dc3
commit 30e40dc34c
6 changed files with 150 additions and 31 deletions
+29 -4
View File
@@ -4,10 +4,12 @@
const root = document.getElementById("options-root");
if (!root) return;
const panelCache = (window.__optionsPanelCache = window.__optionsPanelCache || {});
const state = {
underlying: root.dataset.defaultUnderly || "ETH",
optType: "C",
chain: null,
chain: panelCache.chain || null,
selectedInst: null,
};
@@ -254,6 +256,9 @@
return;
}
state.chain = d;
panelCache.chain = d;
panelCache.underlying = state.underlying;
panelCache.optType = state.optType;
state.selectedInst = null;
parkOrderPanel();
renderExpiries();
@@ -457,6 +462,28 @@
refreshHistory();
}
function bootOptionsPanel() {
updateSizeInputs();
const hasCache =
panelCache.chain &&
panelCache.underlying === state.underlying &&
panelCache.optType === state.optType;
if (hasCache) {
state.chain = panelCache.chain;
renderExpiries();
renderStrikes();
refreshAllPositions();
requestAnimationFrame(function () {
loadChain();
});
return;
}
requestAnimationFrame(function () {
loadChain();
refreshAllPositions();
});
}
document.querySelectorAll(".opt-uly-btn").forEach(function (btn) {
btn.addEventListener("click", function () {
document.querySelectorAll(".opt-uly-btn").forEach(function (b) { b.classList.remove("active"); });
@@ -495,7 +522,5 @@
});
});
updateSizeInputs();
loadChain();
refreshAllPositions();
bootOptionsPanel();
})();