mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-22 05:51:44 +03:00
feat(new tool): Contact Info QR Code generator
Author: Taltos-ch <info@taltos.ch> Date: Sun Feb 16 18:21:54 2025 +0100 This component generates a QR code that stores contact information in vCard format, compatible with both Android and iOS contact cards.
This commit is contained in:
1 parent
0852d1822f
commit
d80207b746
8 files changed
+141
-58
No files matched your search
Vendored
+1
-43
@@ -150,28 +150,17 @@ declare module '@vue/runtime-core' {
|
|||||||
IcalParser: typeof import('./src/tools/ical-parser/ical-parser.vue')['default']
|
IcalParser: typeof import('./src/tools/ical-parser/ical-parser.vue')['default']
|
||||||
IcoConverter: typeof import('./src/tools/ico-converter/ico-converter.vue')['default']
|
IcoConverter: typeof import('./src/tools/ico-converter/ico-converter.vue')['default']
|
||||||
'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default']
|
'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default']
|
||||||
'IconMdi:contentCopy': typeof import('~icons/mdi/content-copy')['default']
|
|
||||||
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
|
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
|
||||||
IconMdiArrowDown: typeof import('~icons/mdi/arrow-down')['default']
|
|
||||||
IconMdiArrowRightBottom: typeof import('~icons/mdi/arrow-right-bottom')['default']
|
|
||||||
IconMdiCamera: typeof import('~icons/mdi/camera')['default']
|
|
||||||
IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
|
IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
|
||||||
IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default']
|
IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default']
|
||||||
IconMdiClose: typeof import('~icons/mdi/close')['default']
|
IconMdiClose: typeof import('~icons/mdi/close')['default']
|
||||||
IconMdiContentCopy: typeof import('~icons/mdi/content-copy')['default']
|
IconMdiContentCopy: typeof import('~icons/mdi/content-copy')['default']
|
||||||
IconMdiDeleteOutline: typeof import('~icons/mdi/delete-outline')['default']
|
|
||||||
IconMdiDownload: typeof import('~icons/mdi/download')['default']
|
|
||||||
IconMdiEye: typeof import('~icons/mdi/eye')['default']
|
IconMdiEye: typeof import('~icons/mdi/eye')['default']
|
||||||
IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default']
|
IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default']
|
||||||
IconMdiHeart: typeof import('~icons/mdi/heart')['default']
|
IconMdiHeart: typeof import('~icons/mdi/heart')['default']
|
||||||
IconMdiPause: typeof import('~icons/mdi/pause')['default']
|
|
||||||
IconMdiPlay: typeof import('~icons/mdi/play')['default']
|
|
||||||
IconMdiRecord: typeof import('~icons/mdi/record')['default']
|
|
||||||
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
|
|
||||||
IconMdiSearch: typeof import('~icons/mdi/search')['default']
|
IconMdiSearch: typeof import('~icons/mdi/search')['default']
|
||||||
IconMdiTranslate: typeof import('~icons/mdi/translate')['default']
|
IconMdiTranslate: typeof import('~icons/mdi/translate')['default']
|
||||||
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
|
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
|
||||||
IconMdiVideo: typeof import('~icons/mdi/video')['default']
|
|
||||||
ImageConverter: typeof import('./src/tools/image-converter/image-converter.vue')['default']
|
ImageConverter: typeof import('./src/tools/image-converter/image-converter.vue')['default']
|
||||||
ImageExifReader: typeof import('./src/tools/image-exif-reader/image-exif-reader.vue')['default']
|
ImageExifReader: typeof import('./src/tools/image-exif-reader/image-exif-reader.vue')['default']
|
||||||
ImageResizer: typeof import('./src/tools/image-resizer/image-resizer.vue')['default']
|
ImageResizer: typeof import('./src/tools/image-resizer/image-resizer.vue')['default']
|
||||||
@@ -253,59 +242,27 @@ declare module '@vue/runtime-core' {
|
|||||||
MorseConverter: typeof import('./src/tools/morse-converter/morse-converter.vue')['default']
|
MorseConverter: typeof import('./src/tools/morse-converter/morse-converter.vue')['default']
|
||||||
MultiLinkDownloader: typeof import('./src/tools/multi-link-downloader/multi-link-downloader.vue')['default']
|
MultiLinkDownloader: typeof import('./src/tools/multi-link-downloader/multi-link-downloader.vue')['default']
|
||||||
MyIp: typeof import('./src/tools/my-ip/my-ip.vue')['default']
|
MyIp: typeof import('./src/tools/my-ip/my-ip.vue')['default']
|
||||||
NA: typeof import('naive-ui')['NA']
|
|
||||||
NAlert: typeof import('naive-ui')['NAlert']
|
|
||||||
NanoidGenerator: typeof import('./src/tools/nanoid-generator/nanoid-generator.vue')['default']
|
NanoidGenerator: typeof import('./src/tools/nanoid-generator/nanoid-generator.vue')['default']
|
||||||
NanoMemo: typeof import('./src/tools/nano-memo/nano-memo.vue')['default']
|
NanoMemo: typeof import('./src/tools/nano-memo/nano-memo.vue')['default']
|
||||||
'NanoMemo.content': typeof import('./src/tools/nano-memo/nano-memo.content.md')['default']
|
'NanoMemo.content': typeof import('./src/tools/nano-memo/nano-memo.content.md')['default']
|
||||||
NAutoComplete: typeof import('naive-ui')['NAutoComplete']
|
|
||||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||||
NButton: typeof import('naive-ui')['NButton']
|
|
||||||
NCard: typeof import('naive-ui')['NCard']
|
|
||||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||||
NCheckboxGroup: typeof import('naive-ui')['NCheckboxGroup']
|
|
||||||
NCode: typeof import('naive-ui')['NCode']
|
NCode: typeof import('naive-ui')['NCode']
|
||||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||||
NColorPicker: typeof import('naive-ui')['NColorPicker']
|
NColorPicker: typeof import('naive-ui')['NColorPicker']
|
||||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||||
NDatePicker: typeof import('naive-ui')['NDatePicker']
|
|
||||||
NDivider: typeof import('naive-ui')['NDivider']
|
|
||||||
NDynamicInput: typeof import('naive-ui')['NDynamicInput']
|
|
||||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||||
NForm: typeof import('naive-ui')['NForm']
|
NForm: typeof import('naive-ui')['NForm']
|
||||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||||
NGi: typeof import('naive-ui')['NGi']
|
|
||||||
NginxFormatter: typeof import('./src/tools/nginx-formatter/nginx-formatter.vue')['default']
|
NginxFormatter: typeof import('./src/tools/nginx-formatter/nginx-formatter.vue')['default']
|
||||||
NGrid: typeof import('naive-ui')['NGrid']
|
|
||||||
NH1: typeof import('naive-ui')['NH1']
|
NH1: typeof import('naive-ui')['NH1']
|
||||||
NH2: typeof import('naive-ui')['NH2']
|
|
||||||
NH3: typeof import('naive-ui')['NH3']
|
NH3: typeof import('naive-ui')['NH3']
|
||||||
NIcon: typeof import('naive-ui')['NIcon']
|
NIcon: typeof import('naive-ui')['NIcon']
|
||||||
NImage: typeof import('naive-ui')['NImage']
|
|
||||||
NInput: typeof import('naive-ui')['NInput']
|
|
||||||
NInputGroup: typeof import('naive-ui')['NInputGroup']
|
|
||||||
NInputGroupLabel: typeof import('naive-ui')['NInputGroupLabel']
|
|
||||||
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
|
||||||
NLayout: typeof import('naive-ui')['NLayout']
|
NLayout: typeof import('naive-ui')['NLayout']
|
||||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||||
NLi: typeof import('naive-ui')['NLi']
|
|
||||||
NMenu: typeof import('naive-ui')['NMenu']
|
NMenu: typeof import('naive-ui')['NMenu']
|
||||||
NP: typeof import('naive-ui')['NP']
|
|
||||||
NProgress: typeof import('naive-ui')['NProgress']
|
|
||||||
NRadio: typeof import('naive-ui')['NRadio']
|
|
||||||
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
|
|
||||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||||
NSelect: typeof import('naive-ui')['NSelect']
|
|
||||||
NSlider: typeof import('naive-ui')['NSlider']
|
|
||||||
NSpace: typeof import('naive-ui')['NSpace']
|
NSpace: typeof import('naive-ui')['NSpace']
|
||||||
NSpin: typeof import('naive-ui')['NSpin']
|
|
||||||
NStatistic: typeof import('naive-ui')['NStatistic']
|
|
||||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
|
||||||
NTable: typeof import('naive-ui')['NTable']
|
|
||||||
NTag: typeof import('naive-ui')['NTag']
|
|
||||||
NText: typeof import('naive-ui')['NText']
|
|
||||||
NTree: typeof import('naive-ui')['NTree']
|
|
||||||
NUl: typeof import('naive-ui')['NUl']
|
|
||||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||||
OcrImage: typeof import('./src/tools/ocr-image/ocr-image.vue')['default']
|
OcrImage: typeof import('./src/tools/ocr-image/ocr-image.vue')['default']
|
||||||
Option43Generator: typeof import('./src/tools/option43-generator/option43-generator.vue')['default']
|
Option43Generator: typeof import('./src/tools/option43-generator/option43-generator.vue')['default']
|
||||||
@@ -333,6 +290,7 @@ declare module '@vue/runtime-core' {
|
|||||||
PunycodeConverter: typeof import('./src/tools/punycode-converter/punycode-converter.vue')['default']
|
PunycodeConverter: typeof import('./src/tools/punycode-converter/punycode-converter.vue')['default']
|
||||||
QrCodeDecoder: typeof import('./src/tools/qr-code-decoder/qr-code-decoder.vue')['default']
|
QrCodeDecoder: typeof import('./src/tools/qr-code-decoder/qr-code-decoder.vue')['default']
|
||||||
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
|
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
|
||||||
|
QrContactInfoGenerator: typeof import('./src/tools/qr-contact-info-generator/qr-contact-info-generator.vue')['default']
|
||||||
RaidCalculator: typeof import('./src/tools/raid-calculator/raid-calculator.vue')['default']
|
RaidCalculator: typeof import('./src/tools/raid-calculator/raid-calculator.vue')['default']
|
||||||
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
|
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
|
||||||
RegexMemo: typeof import('./src/tools/regex-memo/regex-memo.vue')['default']
|
RegexMemo: typeof import('./src/tools/regex-memo/regex-memo.vue')['default']
|
||||||
|
|||||||
@@ -275,6 +275,10 @@ tools:
|
|||||||
title: WiFi QR Code generator
|
title: WiFi QR Code generator
|
||||||
description: Generate and download QR codes for quick connections to WiFi networks.
|
description: Generate and download QR codes for quick connections to WiFi networks.
|
||||||
|
|
||||||
|
qr-contact-info-generator:
|
||||||
|
title: QR Contact Info generator
|
||||||
|
description: Generate and download QR codes for Contact information (vCard), and customize the background and foreground colors.
|
||||||
|
|
||||||
xml-formatter:
|
xml-formatter:
|
||||||
title: XML formatter
|
title: XML formatter
|
||||||
description: Prettify your XML string into a friendly, human-readable format.
|
description: Prettify your XML string into a friendly, human-readable format.
|
||||||
|
|||||||
Generated
+3
-10
@@ -362,9 +362,6 @@ dependencies:
|
|||||||
json-to-ts:
|
json-to-ts:
|
||||||
specifier: ^1.7.0
|
specifier: ^1.7.0
|
||||||
version: 1.7.0
|
version: 1.7.0
|
||||||
json2csharp:
|
|
||||||
specifier: ^1.0.3
|
|
||||||
version: 1.0.3
|
|
||||||
json5:
|
json5:
|
||||||
specifier: ^2.2.3
|
specifier: ^2.2.3
|
||||||
version: 2.2.3
|
version: 2.2.3
|
||||||
@@ -6285,7 +6282,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@unhead/dom': 0.5.1
|
'@unhead/dom': 0.5.1
|
||||||
'@unhead/schema': 0.5.1
|
'@unhead/schema': 0.5.1
|
||||||
'@vueuse/shared': 12.7.0(typescript@5.2.2)
|
'@vueuse/shared': 12.8.2(typescript@5.2.2)
|
||||||
unhead: 0.5.1
|
unhead: 0.5.1
|
||||||
vue: 3.3.4
|
vue: 3.3.4
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -6988,8 +6985,8 @@ packages:
|
|||||||
- vue
|
- vue
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@vueuse/shared@12.7.0(typescript@5.2.2):
|
/@vueuse/shared@12.8.2(typescript@5.2.2):
|
||||||
resolution: {integrity: sha512-coLlUw2HHKsm7rPN6WqHJQr18WymN4wkA/3ThFaJ4v4gWGWAQQGK+MJxLuJTBs4mojQiazlVWAKNJNpUWGRkNw==}
|
resolution: {integrity: sha512-dznP38YzxZoNloI0qpEfpkms8knDtaoQ6Y/sfS0L7Yki4zh40LFHEhur0odJC6xTHG5dxWVPiUWBXn+wCG2s5w==}
|
||||||
dependencies:
|
dependencies:
|
||||||
vue: 3.5.13(typescript@5.2.2)
|
vue: 3.5.13(typescript@5.2.2)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -11976,10 +11973,6 @@ packages:
|
|||||||
pluralize: 3.1.0
|
pluralize: 3.1.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/json2csharp@1.0.3:
|
|
||||||
resolution: {integrity: sha512-hbe5csNMtvYf4neEDvYRWkJf8fgxeheuMAfhG80f2HIpeUMunPvv+4F2fS1PLpXbdzBp6EMQjZiocRvKhtahgg==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/json5@2.2.3:
|
/json5@2.2.3:
|
||||||
resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==}
|
resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { tool as areaConverter } from './area-converter';
|
|||||||
import { tool as angleConverter } from './angle-converter';
|
import { tool as angleConverter } from './angle-converter';
|
||||||
import { tool as floatingPointNumberConverter } from './floating-point-number-converter';
|
import { tool as floatingPointNumberConverter } from './floating-point-number-converter';
|
||||||
import { tool as snowflakeIdExtractor } from './snowflake-id-extractor';
|
import { tool as snowflakeIdExtractor } from './snowflake-id-extractor';
|
||||||
|
import { tool as qrContactInfoGenerator } from './qr-contact-info-generator';
|
||||||
import { tool as emailNormalizer } from './email-normalizer';
|
import { tool as emailNormalizer } from './email-normalizer';
|
||||||
import { tool as jwtGenerator } from './jwt-generator';
|
import { tool as jwtGenerator } from './jwt-generator';
|
||||||
import { tool as gptTokenEstimator } from './gpt-token-estimator';
|
import { tool as gptTokenEstimator } from './gpt-token-estimator';
|
||||||
@@ -392,6 +393,7 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
components: [
|
components: [
|
||||||
qrCodeGenerator,
|
qrCodeGenerator,
|
||||||
wifiQrCodeGenerator,
|
wifiQrCodeGenerator,
|
||||||
|
qrContactInfoGenerator,
|
||||||
barcodeReader,
|
barcodeReader,
|
||||||
barcodeGenerator,
|
barcodeGenerator,
|
||||||
heicConverter,
|
heicConverter,
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { Qrcode } from '@vicons/tabler';
|
||||||
|
import { defineTool } from '../tool';
|
||||||
|
import { translate } from '@/plugins/i18n.plugin';
|
||||||
|
|
||||||
|
export const tool = defineTool({
|
||||||
|
name: translate('tools.qr-contact-info-generator.title'),
|
||||||
|
path: '/qr-contact-info-generator',
|
||||||
|
description: translate('tools.qr-contact-info-generator.description'),
|
||||||
|
keywords: ['qr', 'contact', 'vcard', 'generator', 'business', 'networking'],
|
||||||
|
component: () => import('./qr-contact-info-generator.vue'),
|
||||||
|
icon: Qrcode,
|
||||||
|
createdAt: new Date(),
|
||||||
|
});
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useContactQRCode } from './useContactQRCode';
|
||||||
|
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
||||||
|
|
||||||
|
const fullName = ref('');
|
||||||
|
const jobRole = ref('');
|
||||||
|
const phoneNumber = ref('');
|
||||||
|
const email = ref('');
|
||||||
|
const website = ref('');
|
||||||
|
const address = ref('');
|
||||||
|
|
||||||
|
const foreground = ref('#000000ff');
|
||||||
|
const background = ref('#ffffffff');
|
||||||
|
|
||||||
|
const { qrcode } = useContactQRCode({
|
||||||
|
fullName,
|
||||||
|
jobRole,
|
||||||
|
phoneNumber,
|
||||||
|
email,
|
||||||
|
website,
|
||||||
|
address,
|
||||||
|
color: { foreground, background },
|
||||||
|
options: { width: 1024 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const { download } = useDownloadFileFromBase64({
|
||||||
|
source: qrcode,
|
||||||
|
filename: 'contact-info-qr.png',
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<c-card>
|
||||||
|
<div grid grid-cols-1 gap-12>
|
||||||
|
<div>
|
||||||
|
<c-input-text v-model:value="fullName" label="Full Name" placeholder="John Doe" mb-4 />
|
||||||
|
<c-input-text v-model:value="jobRole" label="Job Role" placeholder="Software Engineer" mb-4 />
|
||||||
|
<c-input-text v-model:value="phoneNumber" label="Phone Number" placeholder="+1 234 567 8901" mb-4 />
|
||||||
|
<c-input-text v-model:value="email" label="Email Address" placeholder="john.doe@example.com" mb-4 />
|
||||||
|
<c-input-text v-model:value="website" label="Website" placeholder="https://acme.com" mb-4 />
|
||||||
|
<c-input-text v-model:value="address" label="Company Address" placeholder="123 Main St, City" mb-4 />
|
||||||
|
|
||||||
|
<n-form label-width="130" label-placement="left">
|
||||||
|
<n-form-item label="Foreground color:">
|
||||||
|
<n-color-picker v-model:value="foreground" :modes="['hex']" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="Background color:">
|
||||||
|
<n-color-picker v-model:value="background" :modes="['hex']" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="qrcode">
|
||||||
|
<div flex flex-col items-center gap-3>
|
||||||
|
<img alt="contact-info-qrcode" :src="qrcode" width="200">
|
||||||
|
<c-button @click="download">
|
||||||
|
Download QR Code
|
||||||
|
</c-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</c-card>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { computed, ref, watchEffect } from 'vue';
|
||||||
|
import QRCode, { type QRCodeToDataURLOptions } from 'qrcode';
|
||||||
|
import type { MaybeRef } from '@vueuse/core';
|
||||||
|
import { get } from '@vueuse/core';
|
||||||
|
|
||||||
|
interface IContactQRCodeOptions {
|
||||||
|
fullName: MaybeRef<string>
|
||||||
|
jobRole: MaybeRef<string>
|
||||||
|
phoneNumber: MaybeRef<string>
|
||||||
|
email: MaybeRef<string>
|
||||||
|
website: MaybeRef<string>
|
||||||
|
address: MaybeRef<string>
|
||||||
|
color: { foreground: MaybeRef<string>; background: MaybeRef<string> }
|
||||||
|
options?: QRCodeToDataURLOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// Computed vCard to ensure reactivity works correctly
|
||||||
|
function useVCard(options: IContactQRCodeOptions) {
|
||||||
|
return computed(() => {
|
||||||
|
return `BEGIN:VCARD
|
||||||
|
VERSION:3.0
|
||||||
|
${get(options.fullName) ? `FN:${get(options.fullName)}` : ''}
|
||||||
|
${get(options.jobRole) ? `TITLE:${get(options.jobRole)}` : ''}
|
||||||
|
${get(options.phoneNumber) ? `TEL:${get(options.phoneNumber)}` : ''}
|
||||||
|
${get(options.email) ? `EMAIL:${get(options.email)}` : ''}
|
||||||
|
${get(options.website) ? `URL:${get(options.website)}` : ''}
|
||||||
|
${get(options.address) ? `ADR:${get(options.address)}` : ''}
|
||||||
|
END:VCARD`.trim();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useContactQRCode(options: IContactQRCodeOptions) {
|
||||||
|
const qrcode = ref('');
|
||||||
|
const vCardText = useVCard(options); // Computed property for reactivity
|
||||||
|
|
||||||
|
watchEffect(async () => {
|
||||||
|
if (vCardText.value) {
|
||||||
|
qrcode.value = await QRCode.toDataURL(vCardText.value, {
|
||||||
|
color: {
|
||||||
|
dark: get(options.color.foreground),
|
||||||
|
light: get(options.color.background),
|
||||||
|
},
|
||||||
|
errorCorrectionLevel: 'M',
|
||||||
|
...options.options,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return { qrcode };
|
||||||
|
}
|
||||||
@@ -70,13 +70,13 @@ function getQrCodeText(options: GetQrCodeTextOptions): string | null {
|
|||||||
if (encryption === 'nopass') {
|
if (encryption === 'nopass') {
|
||||||
return `WIFI:S:${escapeString(ssid)};;`; // type can be omitted in that case, and password is not needed, makes the QR Code smaller
|
return `WIFI:S:${escapeString(ssid)};;`; // type can be omitted in that case, and password is not needed, makes the QR Code smaller
|
||||||
}
|
}
|
||||||
if (encryption === 'WPA3' && password) {
|
if (encryption === 'WPA3' && password) {
|
||||||
return `WIFI:S:${escapeString(ssid)};T:WPA3;P:${escapeString(password)};${isHiddenSSID ? 'H:true;' : ''}R:1;;`;
|
return `WIFI:S:${escapeString(ssid)};T:WPA3;P:${escapeString(password)};${isHiddenSSID ? 'H:true;' : ''}R:1;;`;
|
||||||
}
|
}
|
||||||
if (encryption === 'WPA2/WPA3' && password) {
|
if (encryption === 'WPA2/WPA3' && password) {
|
||||||
return `WIFI:S:${escapeString(ssid)};T:WPA3;P:${escapeString(password)};${isHiddenSSID ? 'H:true;' : ''};`;
|
return `WIFI:S:${escapeString(ssid)};T:WPA3;P:${escapeString(password)};${isHiddenSSID ? 'H:true;' : ''};`;
|
||||||
}
|
}
|
||||||
if (encryption !== 'WPA2-EAP' && password) {
|
if (encryption !== 'WPA2-EAP' && password) {
|
||||||
// EAP has a lot of options, so we'll handle it separately
|
// EAP has a lot of options, so we'll handle it separately
|
||||||
// WPA and WEP are pretty simple though.
|
// WPA and WEP are pretty simple though.
|
||||||
return `WIFI:S:${escapeString(ssid)};T:${encryption};P:${escapeString(password)};${isHiddenSSID ? 'H:true' : ''};`;
|
return `WIFI:S:${escapeString(ssid)};T:${encryption};P:${escapeString(password)};${isHiddenSSID ? 'H:true' : ''};`;
|
||||||
|
|||||||
Reference in new issue
Block a user