You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
821 B

1 year ago
import { onMounted, ref } from "vue";
const template = `<component v-if="name.indexOf('ep-')===0" :is="name" /> <v-else g v-html="svg" /> `;
export default {
props: {
name: {
default: "file",
},
},
template,
setup(props) {
const svg = ref("");
onMounted(async () => {
if (props.name.indexOf("ep-") !== 0) {
try {
const response = await fetch(`./assets/icons/${props.name}.svg`);
if (response.ok && response.status === 200) {
svg.value = await response.text();
}
} catch (error) {
console.error(error);
}
if (!svg.value) {
const response = await fetch("./assets/icons/file.svg");
svg.value = await response.text();
}
}
});
return {
svg,
};
},
};