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*/
|
/** Hook*/
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
isLoadingCheckTime.value = true
|
isLoadingCheckTime.value = true
|
||||||
|
|
@ -545,6 +556,7 @@ onMounted(async () => {
|
||||||
// เรียกแผนที่เฉพาะเมื่อยอมรับ privacy แล้ว
|
// เรียกแผนที่เฉพาะเมื่อยอมรับ privacy แล้ว
|
||||||
if (privacyStore.isAccepted) {
|
if (privacyStore.isAccepted) {
|
||||||
mapRef.value?.requestLocationPermission()
|
mapRef.value?.requestLocationPermission()
|
||||||
|
requestCamera()
|
||||||
}
|
}
|
||||||
|
|
||||||
// เพิ่ม event listeners สำหรับมือถือ
|
// เพิ่ม event listeners สำหรับมือถือ
|
||||||
|
|
@ -571,6 +583,7 @@ watch(
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
mapRef.value?.requestLocationPermission()
|
mapRef.value?.requestLocationPermission()
|
||||||
|
requestCamera()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -658,7 +671,12 @@ watch(
|
||||||
<div
|
<div
|
||||||
v-if="!cameraIsOn && img == null"
|
v-if="!cameraIsOn && img == null"
|
||||||
class="preview-placeholder"
|
class="preview-placeholder"
|
||||||
@click="() => !isDisabledCheckTime && openCamera()"
|
@click="
|
||||||
|
() =>
|
||||||
|
!isDisabledCheckTime &&
|
||||||
|
!isPermissionCameraDenied &&
|
||||||
|
openCamera()
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<q-icon
|
<q-icon
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue