修复中控

This commit is contained in:
dekun
2026-05-30 12:19:05 +08:00
parent c882a5e565
commit 26004fb0e7
3 changed files with 32 additions and 2 deletions
+29
View File
@@ -21,6 +21,32 @@
/** @type {{ exchangeId: string, nextPath: string, title: string } | null} */
let instanceFrameCtx = null;
function isHubEmbedded() {
try {
return window.self !== window.top;
} catch (_) {
return true;
}
}
function delegateInstanceToParent(url, title, exchangeId, nextPath) {
try {
window.parent.postMessage(
{
type: "hub:open-instance",
url,
title: title || "实例",
exchangeId: String(exchangeId),
nextPath: nextPath || "/",
},
"*"
);
return true;
} catch (_) {
return false;
}
}
async function fetchInstanceOpenUrl(exchangeId, nextPath) {
const next = nextPath || "/";
const q = new URLSearchParams({ exchange_id: String(exchangeId), next });
@@ -45,6 +71,9 @@
const row = lastMonitorRows.find((x) => String(x.id) === String(exchangeId));
const title = row ? row.name : exchangeId;
instanceFrameCtx = { exchangeId: String(exchangeId), nextPath: next, title };
if (isHubEmbedded() && delegateInstanceToParent(url, title, exchangeId, next)) {
return;
}
openInstanceFrame(url, title);
} catch (e) {
showToast(String(e), true);