diff options
Diffstat (limited to 'src/tools/qr-code-generator/useQRCode.ts')
-rw-r--r-- | src/tools/qr-code-generator/useQRCode.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/tools/qr-code-generator/useQRCode.ts b/src/tools/qr-code-generator/useQRCode.ts index 64ee90a..5aa5450 100644 --- a/src/tools/qr-code-generator/useQRCode.ts +++ b/src/tools/qr-code-generator/useQRCode.ts @@ -1,6 +1,6 @@ -import { get, type MaybeRef } from '@vueuse/core'; +import { type MaybeRef, get } from '@vueuse/core'; import QRCode, { type QRCodeErrorCorrectionLevel, type QRCodeToDataURLOptions } from 'qrcode'; -import { ref, watch, isRef } from 'vue'; +import { isRef, ref, watch } from 'vue'; export function useQRCode({ text, @@ -8,17 +8,17 @@ export function useQRCode({ errorCorrectionLevel, options, }: { - text: MaybeRef<string>; - color: { foreground: MaybeRef<string>; background: MaybeRef<string> }; - errorCorrectionLevel?: MaybeRef<QRCodeErrorCorrectionLevel>; - options?: QRCodeToDataURLOptions; + text: MaybeRef<string> + color: { foreground: MaybeRef<string>; background: MaybeRef<string> } + errorCorrectionLevel?: MaybeRef<QRCodeErrorCorrectionLevel> + options?: QRCodeToDataURLOptions }) { const qrcode = ref(''); watch( [text, background, foreground, errorCorrectionLevel].filter(isRef), async () => { - if (get(text)) + if (get(text)) { qrcode.value = await QRCode.toDataURL(get(text).trim(), { color: { dark: get(foreground), @@ -28,6 +28,7 @@ export function useQRCode({ errorCorrectionLevel: get(errorCorrectionLevel) ?? 'M', ...options, }); + } }, { immediate: true }, ); |