This commit is contained in:
iqudoo
2026-05-26 14:00:41 +08:00
parent 229c8cb9e4
commit b438364656
4 changed files with 44 additions and 20 deletions

View File

@@ -14,6 +14,7 @@ import {
dispatchEmbedScanResult,
acknowledgeEmbedScanConsumed,
dispatchEmbedScanError,
setEmbedScanHostEnabled,
} from "./services/provider/scan";
import {
setEmbedScanResultForwarder,
@@ -139,7 +140,7 @@ function broadcastScanErrorToEmbedChildren(error) {
});
}
function broadcastScanResultToEmbedChildren(result) {
function broadcastScanResultToEmbedChildren(result, meta) {
if (embedChildSources.size === 0 || result == null || result === "") {
return;
}
@@ -151,6 +152,7 @@ function broadcastScanResultToEmbedChildren(result) {
v: EMBED_V,
kind: "forwardScanResult",
result,
scanSource: meta && meta.source,
},
"*"
);
@@ -217,7 +219,9 @@ function embedChildOnMessage(ev) {
}
if (data.kind === "forwardScanResult") {
if (typeof data.result === "string") {
const consumed = dispatchEmbedScanResult(data.result);
const consumed = dispatchEmbedScanResult(data.result, {
source: data.scanSource,
});
if (consumed && resolveUseParentProxy()) {
window.parent.postMessage(
{
@@ -349,6 +353,7 @@ export function installEmbedHost(lib) {
embedHostInstalled = true;
setEmbedScanResultForwarder(broadcastScanResultToEmbedChildren);
setEmbedScanErrorForwarder(broadcastScanErrorToEmbedChildren);
setEmbedScanHostEnabled(true);
window.addEventListener("message", (ev) => {
const data = ev.data;
if (!isEmbedMessage(data)) {