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); onMounted(async () => { if (!props.name.startsWith("ep-")) { try { const url = `./assets/icons/${props.name}.svg`; navigator.locks.request(url, async () => { const appStore = useAppStore(); if (appStore.cache.has(url)) { svg.value = appStore.cache.get(url); } else { const response = await fetch(url); if (response.ok && response.status === 200) { svg.value = await response.text(); appStore.cache.set(url, svg.value); } } }); } catch (error) { console.log(error); if (!svg.value) { svg.value = ``; } } } }); return { svg, }; }, };