fix(hub): stop instance iframe nav flash after account status badge
Load account_risk_badge.css before body paint, skip redundant hub theme re-apply, remove iframe hide overlay, and disable badge transitions in hub embed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -371,11 +371,6 @@
|
||||
return j.url;
|
||||
}
|
||||
|
||||
function setInstanceFrameNavLoading(loading) {
|
||||
const shell = document.getElementById("instance-frame-shell");
|
||||
if (shell) shell.classList.toggle("is-instance-nav-loading", !!loading);
|
||||
}
|
||||
|
||||
async function openInstance(exchangeId, nextPath, opts) {
|
||||
const options = opts || {};
|
||||
const newTab = !!options.newTab;
|
||||
@@ -428,10 +423,7 @@
|
||||
);
|
||||
instanceFrameUrl = url;
|
||||
const frame = document.getElementById("instance-frame");
|
||||
if (frame) {
|
||||
setInstanceFrameNavLoading(true);
|
||||
frame.src = url;
|
||||
}
|
||||
if (frame) frame.src = url;
|
||||
} catch (e) {
|
||||
showToast(String(e), true);
|
||||
}
|
||||
@@ -448,7 +440,6 @@
|
||||
closeExchangeFullscreen();
|
||||
instanceFrameUrl = url;
|
||||
if (titleEl) titleEl.textContent = title || "实例";
|
||||
setInstanceFrameNavLoading(true);
|
||||
frame.src = url;
|
||||
shell.classList.remove("hidden");
|
||||
shell.setAttribute("aria-hidden", "false");
|
||||
@@ -456,14 +447,16 @@
|
||||
if (frame.dataset.themeSyncBound !== "1") {
|
||||
frame.dataset.themeSyncBound = "1";
|
||||
frame.addEventListener("load", function syncInstanceFrameTheme() {
|
||||
try {
|
||||
if (globalThis.HubTheme && typeof HubTheme.get === "function" && frame.contentWindow) {
|
||||
frame.contentWindow.postMessage(
|
||||
{ type: "hub-theme-sync", theme: HubTheme.get() },
|
||||
"*"
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
requestAnimationFrame(() => {
|
||||
try {
|
||||
if (globalThis.HubTheme && typeof HubTheme.get === "function" && frame.contentWindow) {
|
||||
frame.contentWindow.postMessage(
|
||||
{ type: "hub-theme-sync", theme: HubTheme.get() },
|
||||
"*"
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -477,7 +470,6 @@
|
||||
if (shell) {
|
||||
shell.classList.add("hidden");
|
||||
shell.setAttribute("aria-hidden", "true");
|
||||
shell.classList.remove("is-instance-nav-loading");
|
||||
}
|
||||
document.body.classList.remove("hub-instance-frame-open");
|
||||
}
|
||||
@@ -3140,23 +3132,6 @@
|
||||
const back = document.getElementById("instance-frame-back");
|
||||
const refresh = document.getElementById("instance-frame-refresh");
|
||||
const newTab = document.getElementById("instance-frame-newtab");
|
||||
const frame = document.getElementById("instance-frame");
|
||||
if (frame && frame.dataset.hubNavBound !== "1") {
|
||||
frame.dataset.hubNavBound = "1";
|
||||
frame.addEventListener("load", () => setInstanceFrameNavLoading(false));
|
||||
}
|
||||
if (!window.__hubInstanceFrameMsgBound) {
|
||||
window.__hubInstanceFrameMsgBound = true;
|
||||
window.addEventListener("message", (ev) => {
|
||||
const d = ev.data;
|
||||
if (!d || typeof d !== "object") return;
|
||||
if (d.type === "instance-frame-navigating") {
|
||||
setInstanceFrameNavLoading(true);
|
||||
} else if (d.type === "instance-frame-ready" || d.type === "instance-theme-ready") {
|
||||
setInstanceFrameNavLoading(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (back) back.onclick = () => closeInstanceFrame();
|
||||
if (refresh) refresh.onclick = () => refreshInstanceFrame();
|
||||
if (newTab) {
|
||||
|
||||
Reference in New Issue
Block a user