|
|
@ -33,6 +33,7 @@ |
|
|
<script setup lang="ts"> |
|
|
<script setup lang="ts"> |
|
|
defineProps<{ qrCode: string }>(); |
|
|
defineProps<{ qrCode: string }>(); |
|
|
|
|
|
|
|
|
|
|
|
const toast = useToast(); |
|
|
const img = useTemplateRef('img'); |
|
|
const img = useTemplateRef('img'); |
|
|
|
|
|
|
|
|
async function svgToPng() { |
|
|
async function svgToPng() { |
|
|
@ -63,35 +64,52 @@ async function svgToPng() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function downloadPng() { |
|
|
async function downloadPng() { |
|
|
const blob = await svgToPng(); |
|
|
try { |
|
|
|
|
|
const blob = await svgToPng(); |
|
|
|
|
|
|
|
|
const url = URL.createObjectURL(blob); |
|
|
const url = URL.createObjectURL(blob); |
|
|
const a = document.createElement('a'); |
|
|
const a = document.createElement('a'); |
|
|
a.href = url; |
|
|
a.href = url; |
|
|
a.download = 'client-config.png'; |
|
|
a.download = 'client-config.png'; |
|
|
document.body.appendChild(a); |
|
|
document.body.appendChild(a); |
|
|
a.click(); |
|
|
a.click(); |
|
|
document.body.removeChild(a); |
|
|
document.body.removeChild(a); |
|
|
URL.revokeObjectURL(url); |
|
|
URL.revokeObjectURL(url); |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
console.error('failed to download png', e); |
|
|
|
|
|
toast.showToast({ |
|
|
|
|
|
type: 'error', |
|
|
|
|
|
message: $t('toast.unknown'), |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function copyPng() { |
|
|
async function copyPng() { |
|
|
try { |
|
|
const blob = await svgToPng().catch((e) => { |
|
|
const blob = await svgToPng(); |
|
|
console.error('failed to convert svg to png', e); |
|
|
|
|
|
toast.showToast({ |
|
|
|
|
|
type: 'error', |
|
|
|
|
|
message: $t('toast.unknown'), |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
if (!blob) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
await navigator.clipboard.write([ |
|
|
await navigator.clipboard.write([ |
|
|
new ClipboardItem({ |
|
|
new ClipboardItem({ |
|
|
[blob.type]: blob, |
|
|
[blob.type]: blob, |
|
|
}), |
|
|
}), |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
useToast().showToast({ |
|
|
toast.showToast({ |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: $t('copy.copied'), |
|
|
message: $t('copy.copied'), |
|
|
}); |
|
|
}); |
|
|
} catch (e) { |
|
|
} catch (e) { |
|
|
console.error('failed to copy png', e); |
|
|
console.error('failed to copy png', e); |
|
|
useToast().showToast({ |
|
|
toast.showToast({ |
|
|
type: 'error', |
|
|
type: 'error', |
|
|
message: $t('copy.failed'), |
|
|
message: $t('copy.failed'), |
|
|
}); |
|
|
}); |
|
|
|