fix: reset photo 5 min
This commit is contained in:
parent
3c09380a26
commit
5d01f4d400
2 changed files with 42 additions and 8 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from 'vue'
|
import { onUnmounted, ref } from 'vue'
|
||||||
import { loadModules } from 'esri-loader'
|
import { loadModules } from 'esri-loader'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { useCounterMixin } from '@/stores/mixin'
|
import { useCounterMixin } from '@/stores/mixin'
|
||||||
|
|
@ -22,6 +22,8 @@ function updateLocation(latitude: number, longitude: number, namePOI: string) {
|
||||||
|
|
||||||
const poiPlaceName = ref<string>('') // ชื่อพื้นที่ใกล้เคียง
|
const poiPlaceName = ref<string>('') // ชื่อพื้นที่ใกล้เคียง
|
||||||
|
|
||||||
|
const intervalId = ref<any | null>(null)
|
||||||
|
|
||||||
// Replace ArcGIS api key
|
// Replace ArcGIS api key
|
||||||
const apiKey = ref<string>(
|
const apiKey = ref<string>(
|
||||||
'YLATgWuywoeRLHn6KImj5rg7UaP8bJoR9jiTldoCVBHlqFIebwMSA5wIXEmcYhwXwMHkmNISEYtUz3x0oiGIIx0bIXXnUwi0OzupoOEtDrQIsRPVtor7gaPpXEmH8TrNaMT3snf6zO_yujHLGzborg-L9aeAjTJn4ndL6f8qFmRzYcX93E2vyA-7XCufLYTRsdTE5Aq-9hnx1q9PmYVMqhAZpL7dWqn3JgO33fRXetk.'
|
'YLATgWuywoeRLHn6KImj5rg7UaP8bJoR9jiTldoCVBHlqFIebwMSA5wIXEmcYhwXwMHkmNISEYtUz3x0oiGIIx0bIXXnUwi0OzupoOEtDrQIsRPVtor7gaPpXEmH8TrNaMT3snf6zO_yujHLGzborg-L9aeAjTJn4ndL6f8qFmRzYcX93E2vyA-7XCufLYTRsdTE5Aq-9hnx1q9PmYVMqhAZpL7dWqn3JgO33fRXetk.'
|
||||||
|
|
@ -222,7 +224,7 @@ const requestLocationPermission = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.geolocation.getCurrentPosition(
|
navigator.geolocation.getCurrentPosition(
|
||||||
(position) => {
|
async (position) => {
|
||||||
// Permission granted
|
// Permission granted
|
||||||
locationGranted.value = true
|
locationGranted.value = true
|
||||||
|
|
||||||
|
|
@ -235,7 +237,12 @@ const requestLocationPermission = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Center map on user's location if map is initialized
|
// Center map on user's location if map is initialized
|
||||||
initializeMap()
|
if (privacyStore.isAccepted) {
|
||||||
|
await initializeMap()
|
||||||
|
intervalId.value = setInterval(async () => {
|
||||||
|
await initializeMap()
|
||||||
|
}, 300000)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
// Permission denied
|
// Permission denied
|
||||||
|
|
@ -272,10 +279,10 @@ defineExpose({
|
||||||
requestLocationPermission,
|
requestLocationPermission,
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onUnmounted(() => {
|
||||||
// เรียกแผนที่เฉพาะเมื่อยอมรับ privacy แล้ว
|
if (intervalId.value) {
|
||||||
if (privacyStore.isAccepted) {
|
clearInterval(intervalId.value)
|
||||||
await initializeMap()
|
intervalId.value = null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, watch } from 'vue'
|
import { ref, reactive, onMounted, watch } from 'vue'
|
||||||
import { is, useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import Camera from 'simple-vue-camera'
|
import Camera from 'simple-vue-camera'
|
||||||
|
|
||||||
|
|
@ -304,6 +304,9 @@ async function capturePhoto() {
|
||||||
await camera.value?.stop()
|
await camera.value?.stop()
|
||||||
const url = URL.createObjectURL(imageBlob)
|
const url = URL.createObjectURL(imageBlob)
|
||||||
img.value = url
|
img.value = url
|
||||||
|
|
||||||
|
// เริ่มนับเวลา 3 นาที เพื่อลบรูป
|
||||||
|
startPhotoTimeout()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function เปลี่ยนรูปภาพ*/
|
/** function เปลี่ยนรูปภาพ*/
|
||||||
|
|
@ -501,6 +504,30 @@ const getClassXS = (val: boolean) => {
|
||||||
}
|
}
|
||||||
const inQueue = ref<boolean>(false)
|
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*/
|
/** Hook*/
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
isLoadingCheckTime.value = true
|
isLoadingCheckTime.value = true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue