feat(front): add FileShareView component for file download functionality

This commit is contained in:
keven1024
2025-05-15 17:07:24 +08:00
parent dca8799f04
commit 7564a7de0a

View File

@@ -0,0 +1,34 @@
<script setup lang="ts">
import AsyncButton from '@/components/ui/button/AsyncButton.vue'
const props = defineProps<{
data: any
}>()
const router = useRouter()
const handleDownload = async () => {
const { id } = props?.data || {}
const data = await $fetch<any>(`/api/download`, {
method: 'POST',
body: {
share_id: id
}
})
const { token } = data?.data || {}
if (!token) {
return
}
(window as any)?.open(`/api/download?token=${token}`)
}
</script>
<template>
<div class="flex flex-col gap-5 items-center">
<h1>下载文件</h1>
<FilePreviewView :value="props?.data" />
<div>
<AsyncButton @click="handleDownload">下载</AsyncButton>
</div>
</div>
</template>