1616 <CameraItem
1717 :camera =" camera"
1818 :embedded =" true"
19+ crossorigin =" anonymous"
1920 @frame =" handlePrinterCameraFrame"
2021 />
2122 </v-card-text >
@@ -34,12 +35,14 @@ import BrowserMixin from '@/mixins/browser'
3435 components: { CameraItem }
3536})
3637export default class QRReader extends Mixins (StateMixin , BrowserMixin ) {
37- dataPatterns = [/ \/ spool\/ show\/ (\d + )\/ ? / ]
38+ dataPatterns = [
39+ / web\+ spoolman:s-(\d + )/ ,
40+ / \/ spool\/ show\/ (\d + )\/ ? /
41+ ]
42+
3843 statusMessage = ' info.howto'
3944 lastScanTimestamp = Date .now ()
4045 processing = false
41-
42- video! : HTMLVideoElement | HTMLImageElement
4346 context! : CanvasRenderingContext2D
4447
4548 @VModel ({ type: String , default: null })
@@ -49,6 +52,9 @@ export default class QRReader extends Mixins(StateMixin, BrowserMixin) {
4952 canvas! : HTMLCanvasElement
5053
5154 get camera () {
55+ if (this .source === ' device' ) {
56+ return { name: this .$t (' app.spoolman.label.device_camera' ), service: ' device' }
57+ }
5258 return this .$store .getters [' cameras/getCameraById' ](this .source )
5359 }
5460
@@ -90,13 +96,23 @@ export default class QRReader extends Mixins(StateMixin, BrowserMixin) {
9096 this .canvas .height = image .naturalHeight
9197 }
9298
99+ if (! this .canvas .width || ! this .canvas .height ) {
100+ // no image drawn yet
101+ this .processing = false
102+ return
103+ }
104+
93105 try {
94106 this .context .drawImage (image , 0 , 0 , this .canvas .width , this .canvas .height )
95107 const result = await QrScanner .scanImage (this .canvas , { returnDetailedScanResult: true })
96108 if (result .data ) { this .handleCodeFound (result .data ) }
97109 } catch (err ) {
98110 if (err instanceof DOMException ) {
99- this .statusMessage = ' error.no_image_data'
111+ if (err .name === ' SecurityError' ) {
112+ this .statusMessage = ' error.cors'
113+ } else {
114+ this .statusMessage = ' error.no_image_data'
115+ }
100116 }
101117
102118 // no QR code found
0 commit comments