-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<script setup lang="ts"> | ||
import { Html5QrcodeScanner } from 'html5-qrcode' | ||
const state = ref({ | ||
error: '', | ||
}) | ||
function onScanSuccess(decodedText, decodedResult) { | ||
// Handle on success condition with the decoded text or result. | ||
console.log(`Scan result: ${decodedText}`, decodedResult) | ||
} | ||
onMounted(() => { | ||
const html5QrcodeScanner = new Html5QrcodeScanner( | ||
'reader', | ||
{ fps: 10, qrbox: 300 }, | ||
false, | ||
) | ||
html5QrcodeScanner.render(onScanSuccess, (err) => { | ||
if (err) | ||
state.value.error = err | ||
}) | ||
document.querySelectorAll('#html5-qrcode-button-camera-permission').forEach((elm) => { | ||
console.log(elm) | ||
elm.className += ' button' | ||
}) | ||
return async () => { | ||
await html5QrcodeScanner.clear() | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col items-center justify-center"> | ||
<div id="reader" class="w-[90%]" style="border: none;" /> | ||
<div v-if="state.error"> | ||
{{ state.error }} | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
:deep(#html5-qrcode-button-camera-stop) { | ||
display: none !important; | ||
} | ||
:deep(#reader div:first-child img:nth-child(2)) { | ||
display: none !important; /* Hide info button */ | ||
} | ||
#reader { | ||
border: none !important; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.