29 lines
483 B
Vue
29 lines
483 B
Vue
|
|
<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>
|