From fc8511c9dd53901cb8343669e76f1042b863cd80 Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Sun, 13 Oct 2024 03:58:43 +0800 Subject: [PATCH] fix: remember last selected camera --- app/components/Scan.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/components/Scan.vue b/app/components/Scan.vue index 2f3d919..81b3c9b 100644 --- a/app/components/Scan.vue +++ b/app/components/Scan.vue @@ -59,15 +59,15 @@ watchEffect(() => { selectedCamera.value = cameras.value[0]?.deviceId }) -watch(cameras, () => { - if (selectedCamera.value && cameras.value.filter(i => i.deviceId === selectedCamera.value).length === 0) - selectedCamera.value = '' -}) - // const results = defineModel>('results', { default: new Set() }) let qrScanner: QrScanner | undefined +watch(cameras, () => { + if (selectedCamera.value && cameras.value.find(i => i.deviceId === selectedCamera.value)) + qrScanner?.setCamera(selectedCamera.value) +}) + const error = ref() const video = shallowRef() const videoWidth = ref(0)