From 82a4958a62f44f584adaea6fe8c38b9b4fdab9a4 Mon Sep 17 00:00:00 2001 From: Kamil Essekkat Date: Mon, 30 Dec 2024 17:38:07 +0100 Subject: [PATCH 1/3] feat(wifi-qr-code): Allow to copy wifi connection string. Fixes #1438 --- src/tools/wifi-qr-code-generator/useQRCode.ts | 9 +++++---- .../wifi-qr-code-generator.vue | 12 +++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/tools/wifi-qr-code-generator/useQRCode.ts b/src/tools/wifi-qr-code-generator/useQRCode.ts index c8a7215c4..118176d2f 100644 --- a/src/tools/wifi-qr-code-generator/useQRCode.ts +++ b/src/tools/wifi-qr-code-generator/useQRCode.ts @@ -110,6 +110,7 @@ export function useWifiQRCode({ color: { background, foreground }, options, }: IWifiQRCodeOptions) { + const text = ref(''); const qrcode = ref(''); const encryption = ref('WPA'); @@ -118,7 +119,7 @@ export function useWifiQRCode({ async () => { // @see https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-network-config-android-ios-11 // This is the full spec, there's quite a bit of logic to generate the string embeddedin the QR code. - const text = getQrCodeText({ + text.value = getQrCodeText({ ssid: get(ssid), password: get(password), encryption: get(encryption), @@ -128,8 +129,8 @@ export function useWifiQRCode({ eapIdentity: get(eapIdentity), eapPhase2Method: get(eapPhase2Method), }); - if (text) { - qrcode.value = await QRCode.toDataURL(get(text).trim(), { + if (text.value) { + qrcode.value = await QRCode.toDataURL(get(text.value).trim(), { color: { dark: get(foreground), light: get(background), @@ -142,5 +143,5 @@ export function useWifiQRCode({ }, { immediate: true }, ); - return { qrcode, encryption }; + return { qrcode, text, encryption }; } diff --git a/src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue b/src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue index e6320d3e7..460d6e489 100644 --- a/src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue +++ b/src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue @@ -5,6 +5,7 @@ import { useWifiQRCode, } from './useQRCode'; import { useDownloadFileFromBase64 } from '@/composable/downloadBase64'; +import { useCopy } from '@/composable/copy'; const foreground = ref('#000000ff'); const background = ref('#ffffffff'); @@ -17,7 +18,7 @@ const eapAnonymous = ref(false); const eapIdentity = ref(); const eapPhase2Method = ref(); -const { qrcode, encryption } = useWifiQRCode({ +const { qrcode, text, encryption } = useWifiQRCode({ ssid, password, eapMethod, @@ -33,6 +34,8 @@ const { qrcode, encryption } = useWifiQRCode({ }); const { download } = useDownloadFileFromBase64({ source: qrcode, filename: 'qr-code.png' }); +const { copy } = useCopy({ source: text, text: 'Copied to the clipboard' }); + From 0fc30feaed3fbd550b2e89ae5062db3d7ac01b1d Mon Sep 17 00:00:00 2001 From: Kamil Essekkat Date: Mon, 30 Dec 2024 17:39:06 +0100 Subject: [PATCH 2/3] Fix lint errors --- .../wifi-qr-code-generator.vue | 67 ++++--------------- 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue b/src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue index 460d6e489..06738acad 100644 --- a/src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue +++ b/src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue @@ -35,7 +35,6 @@ const { qrcode, text, encryption } = useWifiQRCode({ const { download } = useDownloadFileFromBase64({ source: qrcode, filename: 'qr-code.png' }); const { copy } = useCopy({ source: text, text: 'Copied to the clipboard' }); -