This commit is contained in:
Viet An
2026-06-25 17:25:42 +07:00
parent 31ac60a282
commit f759ca49d5
13 changed files with 669 additions and 1458 deletions

View File

@@ -0,0 +1,30 @@
<script setup>
import { Html5Qrcode } from "html5-qrcode";
const emit = defineEmits(["scanned"]);
let scanner;
onMounted(async () => {
scanner = new Html5Qrcode("scanner-region");
await scanner.start(
{ facingMode: "environment" }, // or 'user' for front cam
{ fps: 10, qrbox: 450 },
(decodedText) => {
console.log("scanned", decodedText);
emit("scanned", decodedText);
scanner.stop(); // stop after first scan
},
(errorMsg) => {
console.log("errorMsg", errorMsg);
}, // ignore per-frame scan failures
);
});
onBeforeUnmount(() => {
scanner?.stop().catch(() => {});
});
</script>
<template>
<div id="scanner-region"></div>
</template>

View File

@@ -1,8 +1,16 @@
<script setup>
import BarcodeScanner from "~/components/imports/BarcodeScanner.vue";
import Products from "~/components/imports/Products.vue";
function onScanned(code) {
console.log("code", code);
}
</script>
<template>
<div class="fixed-grid has-12-cols">
<!-- <ClientOnly>
<BarcodeScanner @scanned="onScanned" />
</ClientOnly> -->
<div class="grid">
<div class="cell is-col-span-12">
<Products />