fix: reset photo 5 min
This commit is contained in:
parent
3c09380a26
commit
5d01f4d400
2 changed files with 42 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch } from 'vue'
|
||||
import { is, useQuasar } from 'quasar'
|
||||
import { useQuasar } from 'quasar'
|
||||
import moment from 'moment'
|
||||
import Camera from 'simple-vue-camera'
|
||||
|
||||
|
|
@ -304,6 +304,9 @@ async function capturePhoto() {
|
|||
await camera.value?.stop()
|
||||
const url = URL.createObjectURL(imageBlob)
|
||||
img.value = url
|
||||
|
||||
// เริ่มนับเวลา 3 นาที เพื่อลบรูป
|
||||
startPhotoTimeout()
|
||||
}
|
||||
|
||||
/** function เปลี่ยนรูปภาพ*/
|
||||
|
|
@ -501,6 +504,30 @@ const getClassXS = (val: boolean) => {
|
|||
}
|
||||
const inQueue = ref<boolean>(false)
|
||||
|
||||
const photoTimeout = ref<any | null>(null)
|
||||
const PHOTO_TIMEOUT_DURATION = 5 * 60 * 1000 // 5 นาที
|
||||
|
||||
// ฟังก์ชันใหม่สำหรับจัดการ timeout ของรูป
|
||||
function startPhotoTimeout() {
|
||||
clearPhotoTimeout() // ล้าง timeout เดิมก่อน (ถ้ามี)
|
||||
|
||||
photoTimeout.value = setTimeout(() => {
|
||||
// ลบรูปหลังจาก 5 นาที
|
||||
if (img.value) {
|
||||
img.value = undefined
|
||||
cameraIsOn.value = false
|
||||
camera.value?.stop()
|
||||
}
|
||||
}, PHOTO_TIMEOUT_DURATION)
|
||||
}
|
||||
|
||||
function clearPhotoTimeout() {
|
||||
if (photoTimeout.value) {
|
||||
clearTimeout(photoTimeout.value)
|
||||
photoTimeout.value = null
|
||||
}
|
||||
}
|
||||
|
||||
/** Hook*/
|
||||
onMounted(async () => {
|
||||
isLoadingCheckTime.value = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue