refactor(base64): mutualized base64 functions into global utilities

This commit is contained in:
Corentin Thomasset 2022-08-04 12:09:32 +02:00
parent ca7cb44389
commit 447bdf2148
No known key found for this signature in database
GPG key ID: 3103EB5E79496F9C
8 changed files with 138 additions and 12 deletions

View file

@ -53,6 +53,7 @@
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useCopy } from '@/composable/copy';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
import { textToBase64 } from '@/utils/base64';
import { computed, ref } from 'vue';
const width = ref(600);
@ -75,7 +76,7 @@ const svgString = computed(() => {
</svg>
`.trim();
});
const base64 = computed(() => 'data:image/svg+xml;base64,' + window.btoa(svgString.value));
const base64 = computed(() => 'data:image/svg+xml;base64,' + textToBase64(svgString.value));
const { copy: copySVG } = useCopy({ source: svgString });
const { copy: copyBase64 } = useCopy({ source: base64 });