Skip to content

Commit

Permalink
fix: barcode reader issues bayang#126 bayang#118
Browse files Browse the repository at this point in the history
  • Loading branch information
bayang committed Aug 19, 2024
1 parent f623512 commit ff6090b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/jelu-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/jelu-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@saekitominaga/isbn-verify": "2.0.1",
"@splidejs/splide": "4.1.4",
"@splidejs/vue-splide": "0.6.12",
"@teckel/vue-barcode-reader": "^1.1.6",
"@teckel/vue-barcode-reader": "^1.1.7",
"@vueuse/core": "10.9.0",
"@vueuse/router": "10.9.0",
"axios": "1.6.8",
Expand Down
11 changes: 11 additions & 0 deletions src/jelu-ui/src/components/AutoImportFormModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ const isValid = computed(() => StringUtils.isNotBlank(form.title)
|| StringUtils.isNotBlank(form.isbn)
|| StringUtils.isNotBlank(form.authors))
let barcodeReader: any = null
function toggleScanModal() {
oruga.modal.open({
component: ScanModal,
Expand All @@ -90,6 +92,9 @@ function toggleScanModal() {
if (barcode != null) {
form.isbn = barcode
}
},
barcodeLoaded: (reader) => {
barcodeReader = reader
}
},
onClose: scanModalClosed
Expand Down Expand Up @@ -118,7 +123,13 @@ function togglePluginsModal() {
function scanModalClosed() {
console.log("scan modal closed")
barcodeReader.codeReader.stream
.getTracks()
.forEach(function (track) {
track.stop();
});
}
function pluginsModalClosed() {
console.log("plugins modal closed")
}
Expand Down
6 changes: 5 additions & 1 deletion src/jelu-ui/src/components/ScanModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ const { t } = useI18n({
const emit = defineEmits<{
(e: 'close'): void,
(e: 'decoded', barcode: string|null): void
(e: 'decoded', barcode: string|null): void,
(e: 'barcodeLoaded', reader: any): void
}>()
const decodedText = ref("");
const barcodeReader = ref()
const acceptBarcode = () => {
emit('decoded', decodedText.value)
Expand All @@ -22,6 +24,7 @@ const acceptBarcode = () => {
const onLoaded = () => {
console.log("barcode modal loaded");
emit('barcodeLoaded', barcodeReader.value)
};
const onDecode = (text: string) => {
console.log("barcode " + text);
Expand All @@ -42,6 +45,7 @@ const onDecode = (text: string) => {
<div>
<div class="field mb-2">
<StreamBarcodeReader
ref="barcodeReader"
torch
no-front-cameras
@decode="onDecode"
Expand Down

0 comments on commit ff6090b

Please sign in to comment.