完成
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import './polyfill';
|
||||
import {
|
||||
onScanListener, offScanListener, setStatusListener, getStatus,
|
||||
startScan, stopScan, scanVideo, scanImage, clear
|
||||
} from './services/provider/scan';
|
||||
import { setConfig, getVersion } from './services/config';
|
||||
import { onScanListener, offScanListener, setStatusListener, getStatus,
|
||||
startScan, stopScan, scanVideo, scanImage, clear } from './services/provider/scan';
|
||||
import { initWxJssdk } from './services/wx';
|
||||
import { printDebug } from './utils/logger';
|
||||
|
||||
|
||||
@@ -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:")
|
||||
|
||||
@@ -224,7 +224,8 @@ export function isSupportWebScan() {
|
||||
return typeof navigator !== 'undefined'
|
||||
&& navigator.mediaDevices
|
||||
&& navigator.mediaDevices.getUserMedia
|
||||
&& !!getBarcodeDetectorClass();
|
||||
&& !!getBarcodeDetectorClass()
|
||||
&& getConfig("webCanvasEnabled") !== false;
|
||||
}
|
||||
|
||||
export function isSupportImageScan() {
|
||||
|
||||
Reference in New Issue
Block a user