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>📷</span>
<span>Scan to Clock {{ isClockedIn ? 'Out' : 'In' }}</span> <span>Scan to Clock {{ isClockedIn ? 'Out' : 'In' }}</span>
</button> </button>
<button <!-- <button
@click="triggerFileUpload" @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" 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>📁</span>
<span>Upload QR Image</span> <span>Upload QR Image</span>
</button> </button> -->
<input ref="fileInput" type="file" accept="image/*" @change="handleFileUpload" hidden /> <input ref="fileInput" type="file" accept="image/*" @change="handleFileUpload" hidden />
</div> </div>
</div> </div>
@@ -166,8 +166,8 @@ const startScanner = () => {
html5QrCode = new Html5Qrcode('qr-reader') html5QrCode = new Html5Qrcode('qr-reader')
const config = { fps: 10, qrbox: { width: 250, height: 250 } } const config = { fps: 10, qrbox: { width: 250, height: 250 } }
html5QrCode.start({ facingMode: 'environment' }, config, onScanSuccess, onScanFailure) html5QrCode.start({ facingMode: 'environment' }, config, onScanSuccess, onScanFailure)
} catch (err) { } catch {
errorMessage.value = `Unable to start camera. Try uploading an image instead. Error: ${err.message}` errorMessage.value = `Unable to start camera. `
isScannerActive.value = false isScannerActive.value = false
} }
}, 300) }, 300)
@@ -179,7 +179,7 @@ const stopScanner = () => {
} }
isScannerActive.value = false isScannerActive.value = false
} }
const triggerFileUpload = () => fileInput.value.click() // const triggerFileUpload = () => fileInput.value.click()
const handleFileUpload = (event) => { const handleFileUpload = (event) => {
const file = event.target.files[0] const file = event.target.files[0]
if (!file) return if (!file) return
@@ -190,8 +190,8 @@ const handleFileUpload = (event) => {
html5QrCode html5QrCode
.scanFile(file, true) .scanFile(file, true)
.then(onScanSuccess) .then(onScanSuccess)
.catch((err) => { .catch(() => {
onScanFailure(`Error scanning file: ${err}`) onScanFailure(`Try Again`)
}) })
} }
const onScanSuccess = (decodedText) => { const onScanSuccess = (decodedText) => {
@@ -207,8 +207,8 @@ const onScanSuccess = (decodedText) => {
(errorMessage.value = `Unable to retrieve your location: ${geoError.message}. Please enable location services.`), (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.') => { const onScanFailure = () => {
errorMessage.value = message errorMessage.value = 'Could not detect a QR code. Please try again.'
} }
</script> </script>