SDK开发完成
This commit is contained in:
@@ -258,7 +258,7 @@ export function onScanListener(listener, key, match, level) {
|
||||
key,
|
||||
match: match || "",
|
||||
level: level || 0,
|
||||
listener: listener ,
|
||||
listener: listener,
|
||||
cancel: () => {
|
||||
const index = _scan_listener_list.indexOf(item);
|
||||
if (index !== -1) {
|
||||
@@ -332,12 +332,12 @@ export function startScan() {
|
||||
scanPromise = __startWxScan();
|
||||
} else if (isSupportWebScan()) {
|
||||
console.log("startScanForWeb");
|
||||
scanPromise = startScanForWeb(getConfig("webCanvasStyle"), __result);
|
||||
scanPromise = startScanForWeb(getConfig("webScanCanvasStyle"), __result);
|
||||
} else if (isSupportImageScan()) {
|
||||
console.log("startScanForImage");
|
||||
scanPromise = __startImageScan();
|
||||
} else {
|
||||
console.log("not support scanner");
|
||||
console.log("Not support scanner");
|
||||
}
|
||||
return Promise.race([scanPromise, scannerPromise]);
|
||||
}).finally(() => {
|
||||
@@ -346,16 +346,38 @@ export function startScan() {
|
||||
});
|
||||
}
|
||||
|
||||
export function scanImage() {
|
||||
if (!isSupportImageScan()) {
|
||||
console.log("not support image scanner");
|
||||
export function scanVideo() {
|
||||
if (!isSupportWebScan()) {
|
||||
console.log("Not support video scanner");
|
||||
return;
|
||||
}
|
||||
startScanForImage().then(resp => {
|
||||
if (resp && resp.result) {
|
||||
__result(resp.result);
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log("scan image error", err);
|
||||
Promise.resolve().then(() => {
|
||||
__scanning();
|
||||
return startScanForWeb(getConfig("webScanCanvasStyle"), __result).then(resp => {
|
||||
if (resp && resp.result) {
|
||||
__result(resp.result);
|
||||
}
|
||||
throw resp.error;
|
||||
}).catch(err => { });
|
||||
}).finally(() => {
|
||||
__closed();
|
||||
});
|
||||
}
|
||||
|
||||
export function scanImage() {
|
||||
if (!isSupportImageScan()) {
|
||||
console.log("Not support image scanner");
|
||||
return;
|
||||
}
|
||||
Promise.resolve().then(() => {
|
||||
__scanning();
|
||||
return startScanForImage().then(resp => {
|
||||
if (resp && resp.result) {
|
||||
__result(resp.result);
|
||||
}
|
||||
throw resp.error;
|
||||
}).catch(err => { });
|
||||
}).finally(() => {
|
||||
__closed();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user