Add roll leg avg/TP profit display and reduce instance nav flicker
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -329,19 +329,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 中控 iframe 内:拦截顶栏导航,fetch 后 document.write 原地换页,避免 iframe 卸载白屏 */
|
||||
function initHubEmbedInFrameNav() {
|
||||
if (!isHubLinked()) return;
|
||||
/** 顶栏软导航:fetch + document.write 换页,避免整页卸载白屏(实例 standalone / 中控 iframe 均启用) */
|
||||
function injectNavTransitionGuard(html, theme) {
|
||||
const t = normalize(theme || get());
|
||||
const bg = META[t];
|
||||
const guard = `<style id="inst-nav-guard">html,body{background:${bg}!important;color-scheme:${t};}</style>`;
|
||||
if (html.includes("</head>")) {
|
||||
return html.replace("</head>", `${guard}</head>`);
|
||||
}
|
||||
return guard + html;
|
||||
}
|
||||
|
||||
function initInstanceTopNavSoft() {
|
||||
let navToken = 0;
|
||||
|
||||
function isSoftNavLink(a) {
|
||||
if (!a || !a.getAttribute) return false;
|
||||
if (a.hasAttribute("download") || a.target === "_blank") return false;
|
||||
return !!a.closest(".top-nav, .strategy-subnav");
|
||||
}
|
||||
|
||||
async function navigateInFrame(href, opts) {
|
||||
const token = ++navToken;
|
||||
const themeNow = get();
|
||||
try {
|
||||
const r = await fetch(href, { credentials: "same-origin" });
|
||||
if (token !== navToken) return;
|
||||
@@ -349,7 +359,7 @@
|
||||
location.href = href;
|
||||
return;
|
||||
}
|
||||
const html = await r.text();
|
||||
const html = injectNavTransitionGuard(await r.text(), themeNow);
|
||||
if (token !== navToken) return;
|
||||
let path = href;
|
||||
try {
|
||||
@@ -398,13 +408,13 @@
|
||||
if (isHubLinked()) {
|
||||
apply(get(), { skipStore: true });
|
||||
window.addEventListener("message", (ev) => initFromHubMessage(ev.data));
|
||||
initHubEmbedInFrameNav();
|
||||
try {
|
||||
window.parent.postMessage({ type: "instance-theme-ready" }, "*");
|
||||
} catch (_) {}
|
||||
} else {
|
||||
apply(getStandalone());
|
||||
}
|
||||
initInstanceTopNavSoft();
|
||||
|
||||
function observeDynamicLists() {
|
||||
["journal-list", "review-list"].forEach((id) => {
|
||||
|
||||
Reference in New Issue
Block a user