qrcode-reader-vue3 3.1.3 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +3 -3
- package/.editorconfig +18 -18
- package/.github/ISSUE_TEMPLATE/bug_report.md +28 -28
- package/.github/copilot-instructions.md +209 -0
- package/.github/workflows/npm-publish.yml +15 -15
- package/.releaserc.yml +4 -4
- package/.travis.yml +26 -26
- package/CONTRIBUTING.md +23 -23
- package/LICENSE +21 -21
- package/README.md +194 -194
- package/babel.config.js +3 -3
- package/dist/QrcodeReaderVue3.common.js +15988 -13327
- package/dist/QrcodeReaderVue3.common.js.map +1 -1
- package/dist/QrcodeReaderVue3.umd.js +16152 -13482
- package/dist/QrcodeReaderVue3.umd.js.map +1 -1
- package/dist/QrcodeReaderVue3.umd.min.js +3 -1
- package/dist/QrcodeReaderVue3.umd.min.js.map +1 -1
- package/dist/demo.html +1 -8
- package/docs/.vuepress/components/DemoWrapper.vue +54 -54
- package/docs/.vuepress/components/demos/CustomTracking.vue +3 -2
- package/docs/.vuepress/components/demos/DecodeAll.vue +58 -58
- package/docs/.vuepress/components/demos/DragDrop.vue +80 -80
- package/docs/.vuepress/components/demos/Fullscreen.vue +115 -115
- package/docs/.vuepress/components/demos/LoadingIndicator.vue +61 -61
- package/docs/.vuepress/components/demos/ScanSameQrcodeMoreThanOnce.vue +78 -78
- package/docs/.vuepress/components/demos/SwitchCamera.vue +82 -82
- package/docs/.vuepress/components/demos/Torch.vue +64 -64
- package/docs/.vuepress/components/demos/Upload.vue +28 -28
- package/docs/.vuepress/components/demos/Validate.vue +118 -118
- package/docs/.vuepress/config.js +41 -41
- package/docs/.vuepress/public/checkmark.svg +1 -1
- package/docs/.vuepress/public/debug-memory-leak.html +102 -102
- package/docs/README.md +7 -7
- package/docs/api/QrcodeCapture.md +95 -95
- package/docs/api/QrcodeDropZone.md +117 -117
- package/docs/api/QrcodeStream.md +298 -298
- package/docs/demos/CustomTracking.md +13 -13
- package/docs/demos/DecodeAll.md +12 -12
- package/docs/demos/DragDrop.md +13 -13
- package/docs/demos/Fullscreen.md +13 -13
- package/docs/demos/LoadingIndicator.md +14 -14
- package/docs/demos/ScanSameQrcodeMoreThanOnce.md +17 -17
- package/docs/demos/Simple.md +14 -14
- package/docs/demos/SwitchCamera.md +12 -12
- package/docs/demos/Torch.md +15 -15
- package/docs/demos/Upload.md +16 -16
- package/docs/demos/Validate.md +13 -13
- package/eslint.config.js +49 -0
- package/package.json +33 -23
- package/src/components/QrcodeCapture.vue +31 -30
- package/src/components/QrcodeDropZone.vue +42 -42
- package/src/components/QrcodeStream.vue +28 -31
- package/src/index.ts +44 -0
- package/src/misc/{camera.js → camera.ts} +79 -21
- package/src/misc/{errors.js → errors.ts} +25 -25
- package/src/misc/scanner.ts +149 -0
- package/src/misc/{shimGetUserMedia.js → shimGetUserMedia.ts} +28 -28
- package/src/misc/util.ts +35 -0
- package/src/mixins/CommonAPI.vue +9 -4
- package/src/shims-vue.d.ts +9 -0
- package/src/types/index.d.ts +43 -0
- package/src/types/vue-qrcode-reader.d.ts +32 -4
- package/src/types/webrtc-adapter.d.ts +25 -0
- package/tests/misc/util.test.ts +72 -0
- package/tsconfig.json +35 -0
- package/vitest.config.ts +10 -0
- package/vue.config.js +30 -7
- package/.eslintrc.js +0 -25
- package/src/index.js +0 -32
- package/src/misc/scanner.js +0 -112
- package/src/misc/util.js +0 -15
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<button @click="reload">Destroy And Re-Create Component</button>
|
|
4
|
-
|
|
5
|
-
<qrcode-stream @init="onInit" v-if="!destroyed">
|
|
6
|
-
<div class="loading-indicator" v-if="loading">
|
|
7
|
-
Loading...
|
|
8
|
-
</div>
|
|
9
|
-
</qrcode-stream>
|
|
10
|
-
</div>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script>
|
|
14
|
-
import { QrcodeStream } from '../../../../src'
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
|
|
18
|
-
components: { QrcodeStream },
|
|
19
|
-
|
|
20
|
-
data () {
|
|
21
|
-
return {
|
|
22
|
-
loading: false,
|
|
23
|
-
destroyed: false
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
methods: {
|
|
28
|
-
async onInit (promise) {
|
|
29
|
-
this.loading = true
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
await promise
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error(error)
|
|
35
|
-
} finally {
|
|
36
|
-
this.loading = false
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
async reload () {
|
|
41
|
-
this.destroyed = true
|
|
42
|
-
|
|
43
|
-
await this.$nextTick()
|
|
44
|
-
|
|
45
|
-
this.destroyed = false
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
<style scoped>
|
|
52
|
-
button {
|
|
53
|
-
margin-bottom: 20px;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.loading-indicator {
|
|
57
|
-
font-weight: bold;
|
|
58
|
-
font-size: 2rem;
|
|
59
|
-
text-align: center;
|
|
60
|
-
}
|
|
61
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<button @click="reload">Destroy And Re-Create Component</button>
|
|
4
|
+
|
|
5
|
+
<qrcode-stream @init="onInit" v-if="!destroyed">
|
|
6
|
+
<div class="loading-indicator" v-if="loading">
|
|
7
|
+
Loading...
|
|
8
|
+
</div>
|
|
9
|
+
</qrcode-stream>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import { QrcodeStream } from '../../../../src'
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
|
|
18
|
+
components: { QrcodeStream },
|
|
19
|
+
|
|
20
|
+
data () {
|
|
21
|
+
return {
|
|
22
|
+
loading: false,
|
|
23
|
+
destroyed: false
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
methods: {
|
|
28
|
+
async onInit (promise) {
|
|
29
|
+
this.loading = true
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
await promise
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error(error)
|
|
35
|
+
} finally {
|
|
36
|
+
this.loading = false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
async reload () {
|
|
41
|
+
this.destroyed = true
|
|
42
|
+
|
|
43
|
+
await this.$nextTick()
|
|
44
|
+
|
|
45
|
+
this.destroyed = false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<style scoped>
|
|
52
|
+
button {
|
|
53
|
+
margin-bottom: 20px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.loading-indicator {
|
|
57
|
+
font-weight: bold;
|
|
58
|
+
font-size: 2rem;
|
|
59
|
+
text-align: center;
|
|
60
|
+
}
|
|
61
|
+
</style>
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<p class="decode-result">Last result: <b>{{ result }}</b></p>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<qrcode-stream :camera="camera" @decode="onDecode" @init="onInit">
|
|
7
|
-
<div v-show="showScanConfirmation" class="scan-confirmation">
|
|
8
|
-
<img :src="$withBase('/checkmark.svg')" alt="Checkmark" width="128px" />
|
|
9
|
-
</div>
|
|
10
|
-
</qrcode-stream>
|
|
11
|
-
</div>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script>
|
|
15
|
-
import { QrcodeStream } from '../../../../src'
|
|
16
|
-
|
|
17
|
-
export default {
|
|
18
|
-
|
|
19
|
-
components: { QrcodeStream },
|
|
20
|
-
|
|
21
|
-
data () {
|
|
22
|
-
return {
|
|
23
|
-
camera: 'auto',
|
|
24
|
-
result: null,
|
|
25
|
-
showScanConfirmation: false
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
methods: {
|
|
30
|
-
|
|
31
|
-
async onInit (promise) {
|
|
32
|
-
try {
|
|
33
|
-
await promise
|
|
34
|
-
} catch (e) {
|
|
35
|
-
console.error(e)
|
|
36
|
-
} finally {
|
|
37
|
-
this.showScanConfirmation = this.camera === "off"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
async onDecode (content) {
|
|
42
|
-
this.result = content
|
|
43
|
-
|
|
44
|
-
this.pause()
|
|
45
|
-
await this.timeout(500)
|
|
46
|
-
this.unpause()
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
unpause () {
|
|
50
|
-
this.camera = 'auto'
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
pause () {
|
|
54
|
-
this.camera = 'off'
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
timeout (ms) {
|
|
58
|
-
return new Promise(resolve => {
|
|
59
|
-
window.setTimeout(resolve, ms)
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
</script>
|
|
65
|
-
|
|
66
|
-
<style scoped>
|
|
67
|
-
.scan-confirmation {
|
|
68
|
-
position: absolute;
|
|
69
|
-
width: 100%;
|
|
70
|
-
height: 100%;
|
|
71
|
-
|
|
72
|
-
background-color: rgba(255, 255, 255, .8);
|
|
73
|
-
|
|
74
|
-
display: flex;
|
|
75
|
-
flex-flow: row nowrap;
|
|
76
|
-
justify-content: center;
|
|
77
|
-
}
|
|
78
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<p class="decode-result">Last result: <b>{{ result }}</b></p>
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<qrcode-stream :camera="camera" @decode="onDecode" @init="onInit">
|
|
7
|
+
<div v-show="showScanConfirmation" class="scan-confirmation">
|
|
8
|
+
<img :src="$withBase('/checkmark.svg')" alt="Checkmark" width="128px" />
|
|
9
|
+
</div>
|
|
10
|
+
</qrcode-stream>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import { QrcodeStream } from '../../../../src'
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
|
|
19
|
+
components: { QrcodeStream },
|
|
20
|
+
|
|
21
|
+
data () {
|
|
22
|
+
return {
|
|
23
|
+
camera: 'auto',
|
|
24
|
+
result: null,
|
|
25
|
+
showScanConfirmation: false
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
methods: {
|
|
30
|
+
|
|
31
|
+
async onInit (promise) {
|
|
32
|
+
try {
|
|
33
|
+
await promise
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error(e)
|
|
36
|
+
} finally {
|
|
37
|
+
this.showScanConfirmation = this.camera === "off"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
async onDecode (content) {
|
|
42
|
+
this.result = content
|
|
43
|
+
|
|
44
|
+
this.pause()
|
|
45
|
+
await this.timeout(500)
|
|
46
|
+
this.unpause()
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
unpause () {
|
|
50
|
+
this.camera = 'auto'
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
pause () {
|
|
54
|
+
this.camera = 'off'
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
timeout (ms) {
|
|
58
|
+
return new Promise(resolve => {
|
|
59
|
+
window.setTimeout(resolve, ms)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<style scoped>
|
|
67
|
+
.scan-confirmation {
|
|
68
|
+
position: absolute;
|
|
69
|
+
width: 100%;
|
|
70
|
+
height: 100%;
|
|
71
|
+
|
|
72
|
+
background-color: rgba(255, 255, 255, .8);
|
|
73
|
+
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-flow: row nowrap;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<p class="error" v-if="noFrontCamera">
|
|
4
|
-
You don't seem to have a front camera on your device
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
<p class="error" v-if="noRearCamera">
|
|
8
|
-
You don't seem to have a rear camera on your device
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
<qrcode-stream :camera="camera" @init="onInit">
|
|
12
|
-
<button @click="switchCamera">
|
|
13
|
-
<img :src="$withBase('/camera-switch.svg')" alt="switch camera">
|
|
14
|
-
</button>
|
|
15
|
-
</qrcode-stream>
|
|
16
|
-
</div>
|
|
17
|
-
</template>
|
|
18
|
-
|
|
19
|
-
<script>
|
|
20
|
-
import { QrcodeStream } from '../../../../src'
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
|
|
24
|
-
components: { QrcodeStream },
|
|
25
|
-
|
|
26
|
-
data () {
|
|
27
|
-
return {
|
|
28
|
-
camera: 'rear',
|
|
29
|
-
|
|
30
|
-
noRearCamera: false,
|
|
31
|
-
noFrontCamera: false
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
methods: {
|
|
36
|
-
switchCamera () {
|
|
37
|
-
switch (this.camera) {
|
|
38
|
-
case 'front':
|
|
39
|
-
this.camera = 'rear'
|
|
40
|
-
break
|
|
41
|
-
case 'rear':
|
|
42
|
-
this.camera = 'front'
|
|
43
|
-
break
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
async onInit (promise) {
|
|
48
|
-
try {
|
|
49
|
-
await promise
|
|
50
|
-
} catch (error) {
|
|
51
|
-
const triedFrontCamera = this.camera === 'front'
|
|
52
|
-
const triedRearCamera = this.camera === 'rear'
|
|
53
|
-
|
|
54
|
-
const cameraMissingError = error.name === 'OverconstrainedError'
|
|
55
|
-
|
|
56
|
-
if (triedRearCamera && cameraMissingError) {
|
|
57
|
-
this.noRearCamera = true
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (triedFrontCamera && cameraMissingError) {
|
|
61
|
-
this.noFrontCamera = true
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.error(error)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
<style scoped>
|
|
72
|
-
button {
|
|
73
|
-
position: absolute;
|
|
74
|
-
left: 10px;
|
|
75
|
-
top: 10px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.error {
|
|
79
|
-
color: red;
|
|
80
|
-
font-weight: bold;
|
|
81
|
-
}
|
|
82
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<p class="error" v-if="noFrontCamera">
|
|
4
|
+
You don't seem to have a front camera on your device
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p class="error" v-if="noRearCamera">
|
|
8
|
+
You don't seem to have a rear camera on your device
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<qrcode-stream :camera="camera" @init="onInit">
|
|
12
|
+
<button @click="switchCamera">
|
|
13
|
+
<img :src="$withBase('/camera-switch.svg')" alt="switch camera">
|
|
14
|
+
</button>
|
|
15
|
+
</qrcode-stream>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
import { QrcodeStream } from '../../../../src'
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
|
|
24
|
+
components: { QrcodeStream },
|
|
25
|
+
|
|
26
|
+
data () {
|
|
27
|
+
return {
|
|
28
|
+
camera: 'rear',
|
|
29
|
+
|
|
30
|
+
noRearCamera: false,
|
|
31
|
+
noFrontCamera: false
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
methods: {
|
|
36
|
+
switchCamera () {
|
|
37
|
+
switch (this.camera) {
|
|
38
|
+
case 'front':
|
|
39
|
+
this.camera = 'rear'
|
|
40
|
+
break
|
|
41
|
+
case 'rear':
|
|
42
|
+
this.camera = 'front'
|
|
43
|
+
break
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
async onInit (promise) {
|
|
48
|
+
try {
|
|
49
|
+
await promise
|
|
50
|
+
} catch (error) {
|
|
51
|
+
const triedFrontCamera = this.camera === 'front'
|
|
52
|
+
const triedRearCamera = this.camera === 'rear'
|
|
53
|
+
|
|
54
|
+
const cameraMissingError = error.name === 'OverconstrainedError'
|
|
55
|
+
|
|
56
|
+
if (triedRearCamera && cameraMissingError) {
|
|
57
|
+
this.noRearCamera = true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (triedFrontCamera && cameraMissingError) {
|
|
61
|
+
this.noFrontCamera = true
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.error(error)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<style scoped>
|
|
72
|
+
button {
|
|
73
|
+
position: absolute;
|
|
74
|
+
left: 10px;
|
|
75
|
+
top: 10px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.error {
|
|
79
|
+
color: red;
|
|
80
|
+
font-weight: bold;
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<p v-if="torchNotSupported" class="error">
|
|
4
|
-
Torch not supported for active camera
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
<qrcode-stream :torch="torchActive" @init="onInit">
|
|
8
|
-
<button @click="torchActive = !torchActive" :disabled="torchNotSupported">
|
|
9
|
-
<img :src="$withBase(icon)" alt="toggle torch">
|
|
10
|
-
</button>
|
|
11
|
-
</qrcode-stream>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
import { QrcodeStream } from '../../../../src'
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
|
|
20
|
-
components: { QrcodeStream },
|
|
21
|
-
|
|
22
|
-
data () {
|
|
23
|
-
return {
|
|
24
|
-
torchActive: false,
|
|
25
|
-
torchNotSupported: false
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
computed: {
|
|
30
|
-
icon() {
|
|
31
|
-
if (this.torchActive)
|
|
32
|
-
return '/flash-off.svg'
|
|
33
|
-
else
|
|
34
|
-
return '/flash-on.svg'
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
methods: {
|
|
39
|
-
async onInit (promise) {
|
|
40
|
-
try {
|
|
41
|
-
const { capabilities } = await promise
|
|
42
|
-
|
|
43
|
-
console.log(capabilities);
|
|
44
|
-
|
|
45
|
-
this.torchNotSupported = !capabilities.torch
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.error(error)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
</script>
|
|
53
|
-
|
|
54
|
-
<style scoped>
|
|
55
|
-
button {
|
|
56
|
-
position: absolute;
|
|
57
|
-
left: 10px;
|
|
58
|
-
top: 10px;
|
|
59
|
-
}
|
|
60
|
-
.error {
|
|
61
|
-
color: red;
|
|
62
|
-
font-weight: bold;
|
|
63
|
-
}
|
|
64
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<p v-if="torchNotSupported" class="error">
|
|
4
|
+
Torch not supported for active camera
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<qrcode-stream :torch="torchActive" @init="onInit">
|
|
8
|
+
<button @click="torchActive = !torchActive" :disabled="torchNotSupported">
|
|
9
|
+
<img :src="$withBase(icon)" alt="toggle torch">
|
|
10
|
+
</button>
|
|
11
|
+
</qrcode-stream>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { QrcodeStream } from '../../../../src'
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
|
|
20
|
+
components: { QrcodeStream },
|
|
21
|
+
|
|
22
|
+
data () {
|
|
23
|
+
return {
|
|
24
|
+
torchActive: false,
|
|
25
|
+
torchNotSupported: false
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
computed: {
|
|
30
|
+
icon() {
|
|
31
|
+
if (this.torchActive)
|
|
32
|
+
return '/flash-off.svg'
|
|
33
|
+
else
|
|
34
|
+
return '/flash-on.svg'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
methods: {
|
|
39
|
+
async onInit (promise) {
|
|
40
|
+
try {
|
|
41
|
+
const { capabilities } = await promise
|
|
42
|
+
|
|
43
|
+
console.log(capabilities);
|
|
44
|
+
|
|
45
|
+
this.torchNotSupported = !capabilities.torch
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error(error)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<style scoped>
|
|
55
|
+
button {
|
|
56
|
+
position: absolute;
|
|
57
|
+
left: 10px;
|
|
58
|
+
top: 10px;
|
|
59
|
+
}
|
|
60
|
+
.error {
|
|
61
|
+
color: red;
|
|
62
|
+
font-weight: bold;
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<p class="decode-result">Last result: <b>{{ result }}</b></p>
|
|
4
|
-
|
|
5
|
-
<qrcode-capture @decode="onDecode" />
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script>
|
|
10
|
-
import { QrcodeCapture } from '../../../../src'
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
|
|
14
|
-
components: { QrcodeCapture },
|
|
15
|
-
|
|
16
|
-
data () {
|
|
17
|
-
return {
|
|
18
|
-
result: ''
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
methods: {
|
|
23
|
-
onDecode (result) {
|
|
24
|
-
this.result = result
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<p class="decode-result">Last result: <b>{{ result }}</b></p>
|
|
4
|
+
|
|
5
|
+
<qrcode-capture @decode="onDecode" />
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
import { QrcodeCapture } from '../../../../src'
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
|
|
14
|
+
components: { QrcodeCapture },
|
|
15
|
+
|
|
16
|
+
data () {
|
|
17
|
+
return {
|
|
18
|
+
result: ''
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
methods: {
|
|
23
|
+
onDecode (result) {
|
|
24
|
+
this.result = result
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
</script>
|