This commit is contained in:
iqudoo
2026-04-30 16:56:30 +08:00
parent 0acd16e0a5
commit 11113ab818
7 changed files with 386 additions and 15 deletions

View File

@@ -6,6 +6,10 @@ let _events = {};
let _callbacks = {};
let _bridge = "__bridge_client__";
function getBridgeName() {
return getConfig("bridgeName") ? getConfig("bridgeName") : _bridge;
}
function _callRuntime(func, ...options) {
let funcs = func.split('.');
let instant = window;
@@ -26,7 +30,7 @@ function onCallback(name, callback) {
}
function _checkInit() {
let methodName = `${_bridge}_handle_callback`;
let methodName = `${getBridgeName()}_handle_callback`;
if (!window[methodName]) {
window[methodName] = (res) => {
let { method, payload, code, request_id } = toAny(res, {});
@@ -43,7 +47,8 @@ function _checkInit() {
}
export function inRuntime() {
return !!window[_bridge]
return !!window[getBridgeName()]
&& getConfig("bridgeEnabled") !== false;
}
export function onEvent(method, callback) {
@@ -70,7 +75,7 @@ export function offEvent(method, callback) {
export function bridgeSync(method, data) {
_checkInit();
let result = toAny(_callRuntime(`${_bridge}.call`, method, toAny(data, "")));
let result = toAny(_callRuntime(`${getBridgeName()}.call`, method, toAny(data, "")));
let options = [method];
if (data) {
options.push("params:")

View File

@@ -224,7 +224,8 @@ export function isSupportWebScan() {
return typeof navigator !== 'undefined'
&& navigator.mediaDevices
&& navigator.mediaDevices.getUserMedia
&& !!getBarcodeDetectorClass();
&& !!getBarcodeDetectorClass()
&& getConfig("webCanvasEnabled") !== false;
}
export function isSupportImageScan() {