fix:mediaDevices
This commit is contained in:
parent
6010c6ff59
commit
662cca4e22
1 changed files with 19 additions and 1 deletions
|
|
@ -536,6 +536,17 @@ function handleVisibilityChange() {
|
|||
}
|
||||
}
|
||||
|
||||
const isPermissionCameraDenied = ref<boolean>(false) // ตัวแปรสำหรับตรวจสอบการปฏิเสธสิทธิ์กล้อง
|
||||
|
||||
async function requestCamera() {
|
||||
try {
|
||||
await navigator.mediaDevices.getUserMedia({ video: true })
|
||||
} catch (err) {
|
||||
console.error('ผู้ใช้ปฏิเสธการเข้าถึง หรือเกิดข้อผิดพลาด: ', err)
|
||||
isPermissionCameraDenied.value = true
|
||||
}
|
||||
}
|
||||
|
||||
/** Hook*/
|
||||
onMounted(async () => {
|
||||
isLoadingCheckTime.value = true
|
||||
|
|
@ -545,6 +556,7 @@ onMounted(async () => {
|
|||
// เรียกแผนที่เฉพาะเมื่อยอมรับ privacy แล้ว
|
||||
if (privacyStore.isAccepted) {
|
||||
mapRef.value?.requestLocationPermission()
|
||||
requestCamera()
|
||||
}
|
||||
|
||||
// เพิ่ม event listeners สำหรับมือถือ
|
||||
|
|
@ -571,6 +583,7 @@ watch(
|
|||
(newVal) => {
|
||||
if (newVal) {
|
||||
mapRef.value?.requestLocationPermission()
|
||||
requestCamera()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
@ -658,7 +671,12 @@ watch(
|
|||
<div
|
||||
v-if="!cameraIsOn && img == null"
|
||||
class="preview-placeholder"
|
||||
@click="() => !isDisabledCheckTime && openCamera()"
|
||||
@click="
|
||||
() =>
|
||||
!isDisabledCheckTime &&
|
||||
!isPermissionCameraDenied &&
|
||||
openCamera()
|
||||
"
|
||||
>
|
||||
<div class="text-center">
|
||||
<q-icon
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue