fix
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
setEmbedScanResultForwarder,
|
||||
setEmbedScanErrorForwarder,
|
||||
} from "./services/embedScanBridge";
|
||||
import { unlockScanBeep, installScanBeepGestureUnlock } from "./services/web";
|
||||
|
||||
const EMBED_SOURCE = "IScanEmbed";
|
||||
const EMBED_V = 1;
|
||||
@@ -34,6 +35,13 @@ const EMBED_LISTENER_METHODS = new Set([
|
||||
"clear",
|
||||
]);
|
||||
|
||||
/** 嵌入 iframe 转发到父页时,须在子页用用户手势解锁提示音 */
|
||||
const EMBED_SCAN_GESTURE_METHODS = new Set([
|
||||
"startScan",
|
||||
"scanImage",
|
||||
"scanImageFromFile",
|
||||
]);
|
||||
|
||||
function isEmbedMessage(data) {
|
||||
return data && data.source === EMBED_SOURCE && data.v === EMBED_V;
|
||||
}
|
||||
@@ -256,6 +264,7 @@ function ensureEmbedChildListener() {
|
||||
return;
|
||||
}
|
||||
embedChildInstalled = true;
|
||||
installScanBeepGestureUnlock();
|
||||
window.addEventListener("message", embedChildOnMessage);
|
||||
}
|
||||
|
||||
@@ -449,6 +458,9 @@ function createInvokeTransport(lib, method, methodName, initNames) {
|
||||
}
|
||||
return _exec(lib, methodName, ...params);
|
||||
}
|
||||
if (EMBED_SCAN_GESTURE_METHODS.has(method)) {
|
||||
unlockScanBeep();
|
||||
}
|
||||
return embedInvoke(methodName, params);
|
||||
}
|
||||
if (!isReadyCalled() && initNames && initNames.indexOf(method) < 0) {
|
||||
|
||||
Reference in New Issue
Block a user