import { ref } from 'vue'; interface QROptions { width?: number; margin?: number; color?: { dark: string; light: string; }; } export const qrOptions = ref({ width: 100, margin: 1, color: { dark: '#000000', light: 'f0f0f0' } }); export const downloadData = (data: string) => { const b = base64ToBytes(data) downloadFile(b, 'teams_qr_code.pdf', 'application/pdf;teams_qr_code.pdf') } const base64ToBytes = (base64: string): Uint8Array => { const binaryString = atob(base64); const bytes = new Uint8Array(binaryString.length); for (let i = 0; i < binaryString.length; i++) { bytes[i] = binaryString.charCodeAt(i); } return bytes; } const downloadFile = (bytes: Uint8Array, fileName: string, mimeType: string) => { const blob = new Blob([bytes], { type: mimeType }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = fileName; link.click(); URL.revokeObjectURL(url); };