修复中控
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user