import html from "html"; import { onMounted, ref } from "vue"; import { useAppStore } from "../../store/index.js"; export default { template: html` `, props: { name: { default: "file", }, }, setup(props) { const svg = ref(null); const appStore = useAppStore(); onMounted(async () => { if (!props.name.startsWith("ep-")) { try { const url = `./assets/icons/${props.name}.svg`; if (!appStore.cache.has(url)) { const response = await fetch(url); const result = await response.text(); appStore.cache.set(url, result); } svg.value = appStore.cache.get(url); } catch (error) { console.log(error); } finally { svg.value ??= ``; } } }); return { svg, }; }, };