refactor(WorkerDashboardView): 移除QR图片上传功能

- 删除QR图片上传按钮
This commit is contained in:
sudomarcma
2025-06-30 17:03:38 +08:00
parent d322404007
commit 62896d9fc6
+9 -9
View File
@@ -32,13 +32,13 @@
<span>📷</span>
<span>Scan to Clock {{ isClockedIn ? 'Out' : 'In' }}</span>
</button>
<button
<!-- <button
@click="triggerFileUpload"
class="w-full py-4 text-xl flex items-center justify-center gap-3 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-800 dark:text-white font-semibold rounded-md transition-colors duration-200"
>
<span>📁</span>
<span>Upload QR Image</span>
</button>
</button> -->
<input ref="fileInput" type="file" accept="image/*" @change="handleFileUpload" hidden />
</div>
</div>
@@ -166,8 +166,8 @@ const startScanner = () => {
html5QrCode = new Html5Qrcode('qr-reader')
const config = { fps: 10, qrbox: { width: 250, height: 250 } }
html5QrCode.start({ facingMode: 'environment' }, config, onScanSuccess, onScanFailure)
} catch (err) {
errorMessage.value = `Unable to start camera. Try uploading an image instead. Error: ${err.message}`
} catch {
errorMessage.value = `Unable to start camera. `
isScannerActive.value = false
}
}, 300)
@@ -179,7 +179,7 @@ const stopScanner = () => {
}
isScannerActive.value = false
}
const triggerFileUpload = () => fileInput.value.click()
// const triggerFileUpload = () => fileInput.value.click()
const handleFileUpload = (event) => {
const file = event.target.files[0]
if (!file) return
@@ -190,8 +190,8 @@ const handleFileUpload = (event) => {
html5QrCode
.scanFile(file, true)
.then(onScanSuccess)
.catch((err) => {
onScanFailure(`Error scanning file: ${err}`)
.catch(() => {
onScanFailure(`Try Again`)
})
}
const onScanSuccess = (decodedText) => {
@@ -207,8 +207,8 @@ const onScanSuccess = (decodedText) => {
(errorMessage.value = `Unable to retrieve your location: ${geoError.message}. Please enable location services.`),
)
}
const onScanFailure = (message = 'Could not detect a QR code. Please try again.') => {
errorMessage.value = message
const onScanFailure = () => {
errorMessage.value = 'Could not detect a QR code. Please try again.'
}
</script>