Skip to content

Commit e31fa73

Browse files
committed
review
1 parent db4fa5e commit e31fa73

File tree

30 files changed

+146
-315
lines changed

30 files changed

+146
-315
lines changed

hello-world/angular/src/app/image-capture/image-capture.component.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component } from '@angular/core';
22
import { BarcodeResultItem } from '@dynamsoft/dynamsoft-barcode-reader';
33
import { CaptureVisionRouter } from 'dynamsoft-capture-vision-router';
4+
import '../../cvr'; // import side effects. The license, engineResourcePath, so on.
45

56
@Component({
67
selector: 'app-image-capture',
@@ -26,13 +27,7 @@ export class ImageCaptureComponent {
2627
if (texts != '') alert(texts);
2728
if (!result.items.length) alert('No barcode found');
2829
} catch (ex: any) {
29-
let errMsg;
30-
if (ex.message?.includes('network connection error')) {
31-
errMsg =
32-
'Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.';
33-
} else {
34-
errMsg = ex.message || ex;
35-
}
30+
let errMsg = ex.message || ex;
3631
console.error(errMsg);
3732
alert(errMsg);
3833
}

hello-world/angular/src/app/video-capture/video-capture.component.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
CaptureVisionRouter,
1111
} from 'dynamsoft-capture-vision-router';
1212
import { MultiFrameResultCrossFilter } from 'dynamsoft-utility';
13+
import '../../cvr'; // import side effects. The license, engineResourcePath, so on.
1314

1415
@Component({
1516
selector: 'app-video-capture',
@@ -48,10 +49,14 @@ export class VideoCaptureComponent {
4849
resultReceiver.onDecodedBarcodesReceived = (result: DecodedBarcodesResult) => {
4950
if (!result.barcodesResultItems.length) return;
5051

51-
this.resultsContainer!.nativeElement.innerHTML = "";
52+
this.resultsContainer!.nativeElement.textContent = '';
5253
console.log(result);
5354
for (let item of result.barcodesResultItems) {
54-
this.resultsContainer!.nativeElement.innerHTML += `${item.formatString}: ${item.text}<br><hr>`;
55+
this.resultsContainer!.nativeElement.append(
56+
`${item.formatString}: ${item.text}`,
57+
document.createElement('br'),
58+
document.createElement('hr'),
59+
);
5560
}
5661
};
5762
router.addResultReceiver(resultReceiver);
@@ -82,13 +87,7 @@ export class VideoCaptureComponent {
8287
router,
8388
};
8489
} catch (ex: any) {
85-
let errMsg;
86-
if (ex.message?.includes('network connection error')) {
87-
errMsg =
88-
'Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.';
89-
} else {
90-
errMsg = ex.message || ex;
91-
}
90+
let errMsg = ex.message || ex;
9291
console.error(errMsg);
9392
alert(errMsg);
9493
throw ex;

hello-world/angular/src/cvr.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,4 @@ CoreModule.engineResourcePaths = {
2828
};
2929

3030
// Preload "BarcodeReader" module for reading barcodes. It will save time on the initial decoding by skipping the module loading.
31-
CoreModule.loadWasm(['DBR']).catch((ex) => {
32-
let errMsg;
33-
if (ex.message?.includes('network connection error')) {
34-
errMsg =
35-
'Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.';
36-
} else {
37-
errMsg = ex.message || ex;
38-
}
39-
console.error(errMsg);
40-
alert(errMsg);
41-
});
31+
CoreModule.loadWasm(['DBR']);

hello-world/electron/action.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ Dynamsoft.Core.CoreModule.engineResourcePaths = {
4343
if (!result.barcodesResultItems.length) return;
4444

4545
const resultsContainer = document.querySelector("#div-results-container");
46-
resultsContainer.innerHTML = "";
46+
resultsContainer.textContent = '';
4747
console.log(result);
4848
for (let item of result.barcodesResultItems) {
49-
resultsContainer.innerHTML += `${item.formatString}: ${item.text}<br><hr>`;
49+
resultsContainer.append(
50+
`${item.formatString}: ${item.text}`,
51+
document.createElement('br'),
52+
document.createElement('hr'),
53+
);
5054
}
5155
};
5256
router.addResultReceiver(resultReceiver);
@@ -72,13 +76,7 @@ Dynamsoft.Core.CoreModule.engineResourcePaths = {
7276
await cameraEnhancer.open();
7377
await router.startCapturing("ReadSingleBarcode");
7478
} catch (ex) {
75-
let errMsg;
76-
if (ex.message?.includes("network connection error")) {
77-
errMsg =
78-
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.";
79-
} else {
80-
errMsg = ex.message || ex;
81-
}
79+
let errMsg = ex.message || ex;
8280
console.error(errMsg);
8381
alert(errMsg);
8482
}

hello-world/es6.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,14 @@ <h1>Hello World for ES6 (Decode via Camera)</h1>
101101
if (!result.barcodesResultItems.length) return;
102102

103103
const resultsContainer = document.querySelector("#div-results-container");
104-
resultsContainer.innerHTML = "";
104+
resultsContainer.textContent = '';
105105
console.log(result);
106106
for (let item of result.barcodesResultItems) {
107-
resultsContainer.innerHTML += `${item.formatString}: ${item.text}<br><hr>`;
107+
resultsContainer.append(
108+
`${item.formatString}: ${item.text}`,
109+
document.createElement('br'),
110+
document.createElement('hr'),
111+
);
108112
}
109113
};
110114
router.addResultReceiver(resultReceiver);
@@ -130,13 +134,7 @@ <h1>Hello World for ES6 (Decode via Camera)</h1>
130134
await cameraEnhancer.open();
131135
await router.startCapturing("ReadSingleBarcode");
132136
} catch (ex) {
133-
let errMsg;
134-
if (ex.message?.includes("network connection error")) {
135-
errMsg =
136-
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.";
137-
} else {
138-
errMsg = ex.message || ex;
139-
}
137+
let errMsg = ex.message || ex;
140138
console.error(errMsg);
141139
alert(errMsg);
142140
}

hello-world/hello-world.html

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ <h1>Hello World (Decode via Camera)</h1>
5252
* LICENSE ALERT - THE END
5353
*/
5454

55-
(async function () {
55+
(async () => {
5656
try {
5757
// Create a `CameraEnhancer` instance for camera control and a `CameraView` instance for UI control.
5858
const cameraView = await Dynamsoft.DCE.CameraView.createInstance();
@@ -73,10 +73,14 @@ <h1>Hello World (Decode via Camera)</h1>
7373
if (!result.barcodesResultItems.length) return;
7474

7575
const resultsContainer = document.querySelector("#div-results-container");
76-
resultsContainer.innerHTML = "";
76+
resultsContainer.textContent = '';
7777
console.log(result);
7878
for (let item of result.barcodesResultItems) {
79-
resultsContainer.innerHTML += `${item.formatString}: ${item.text}<br><hr>`;
79+
resultsContainer.append(
80+
`${item.formatString}: ${item.text}`,
81+
document.createElement('br'),
82+
document.createElement('hr'),
83+
);
8084
}
8185
};
8286
router.addResultReceiver(resultReceiver);
@@ -102,13 +106,7 @@ <h1>Hello World (Decode via Camera)</h1>
102106
await cameraEnhancer.open();
103107
await router.startCapturing("ReadSingleBarcode");
104108
} catch (ex) {
105-
let errMsg;
106-
if (ex.message?.includes("network connection error")) {
107-
errMsg =
108-
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.";
109-
} else {
110-
errMsg = ex.message || ex;
111-
}
109+
let errMsg = ex.message || ex;
112110
console.error(errMsg);
113111
alert(errMsg);
114112
}

hello-world/next/components/ImageCapture/ImageCapture.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import React, { useRef, useEffect } from "react";
44
import { BarcodeResultItem } from "@dynamsoft/dynamsoft-barcode-reader";
55
import { CaptureVisionRouter } from "dynamsoft-capture-vision-router";
6+
import "../../cvr"; // import side effects. The license, engineResourcePath, so on.
67
import "./ImageCapture.css";
78

89
function ImageCapture() {
@@ -37,12 +38,9 @@ function ImageCapture() {
3738
if (texts !== "") alert(texts);
3839
if (!result.items.length) alert("No barcode found");
3940
} catch (ex: any) {
40-
if (ex.message.indexOf("network connection error")) {
41-
let customMsg =
42-
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.";
43-
console.log(customMsg);
44-
alert(customMsg);
45-
}
41+
let errMsg = ex.message || ex;
42+
console.error(errMsg);
43+
alert(errMsg);
4644
throw ex;
4745
}
4846
e.target.value = "";

hello-world/next/components/VideoCapture/VideoCapture.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
CaptureVisionRouter,
1313
} from "dynamsoft-capture-vision-router";
1414
import { MultiFrameResultCrossFilter } from "dynamsoft-utility";
15+
import "../../cvr"; // import side effects. The license, engineResourcePath, so on.
1516
import "./VideoCapture.css";
1617

1718
function VideoCapture() {
@@ -50,10 +51,14 @@ function VideoCapture() {
5051
) => {
5152
if (!result.barcodesResultItems.length) return;
5253

53-
resultsContainer.current!.innerHTML = "";
54+
resultsContainer.current!.textContent = '';
5455
console.log(result);
5556
for (let item of result.barcodesResultItems) {
56-
resultsContainer.current!.innerHTML += `${item.formatString}: ${item.text}<br><hr>`;
57+
resultsContainer.current!.append(
58+
`${item.formatString}: ${item.text}`,
59+
document.createElement('br'),
60+
document.createElement('hr'),
61+
);
5762
}
5863
};
5964
router.addResultReceiver(resultReceiver);
@@ -84,13 +89,7 @@ function VideoCapture() {
8489
router,
8590
};
8691
} catch (ex: any) {
87-
let errMsg;
88-
if (ex.message?.includes("network connection error")) {
89-
errMsg =
90-
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.";
91-
} else {
92-
errMsg = ex.message || ex;
93-
}
92+
let errMsg = ex.message || ex;
9493
console.error(errMsg);
9594
alert(errMsg);
9695
throw ex;

hello-world/next/cvr.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,4 @@ CoreModule.engineResourcePaths = {
2828
};
2929

3030
// Preload "BarcodeReader" module for reading barcodes. It will save time on the initial decoding by skipping the module loading.
31-
CoreModule.loadWasm(['DBR']).catch((ex) => {
32-
let errMsg;
33-
if (ex.message?.includes('network connection error')) {
34-
errMsg =
35-
'Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.';
36-
} else {
37-
errMsg = ex.message || ex;
38-
}
39-
console.error(errMsg);
40-
alert(errMsg);
41-
});
31+
CoreModule.loadWasm(['DBR']);

hello-world/nuxt/components/ImageCapture.client.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { onMounted, onBeforeUnmount, ref, type Ref } from "vue";
33
import { type BarcodeResultItem } from "@dynamsoft/dynamsoft-barcode-reader";
44
import { CaptureVisionRouter } from "dynamsoft-capture-vision-router";
5+
import "../cvr"; // import side effects. The license, engineResourcePath, so on.
56
67
const pInit: Ref<Promise<CaptureVisionRouter> | null> = ref(null);
78
@@ -22,10 +23,6 @@ const decodeImg = async (e: Event) => {
2223
if (!result.items.length) alert("No barcode found");
2324
} catch (ex: any) {
2425
let errMsg = ex.message || ex;
25-
if (errMsg.includes("network connection error")) {
26-
errMsg =
27-
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support ([email protected]) to acquire an offline license.";
28-
}
2926
console.error(errMsg);
3027
alert(errMsg);
3128
}

0 commit comments

Comments
 (0)