feat: add get real file url component and pass down (#77)
This commit is contained in:
parent
119e2c03a6
commit
732c81ed57
1 changed files with 28 additions and 0 deletions
28
src/components/upload-file/GetFileUrl.vue
Normal file
28
src/components/upload-file/GetFileUrl.vue
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue