feat: add get real file url component and pass down (#77)

This commit is contained in:
Methapon Metanipat 2024-11-19 09:14:43 +07:00 committed by GitHub
parent 119e2c03a6
commit 732c81ed57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,28 @@
<script setup lang="ts">
import { api } from 'src/boot/axios';
import { onMounted } from 'vue';
import { ref, watch } from 'vue';
const props = defineProps<{
url: string;
auth?: boolean;
}>();
const file = ref<string>('');
onMounted(getFile);
watch(
() => props.url,
() => getFile,
);
async function getFile() {
file.value = props.auth
? await api.get<string>(props.url).then((res) => res.data)
: props.url;
}
</script>
<template>
<slot :file />
</template>