mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 07:08:02 +00:00
feat(front): add FileShareView component for file download functionality
This commit is contained in:
34
front/components/Share/FileShareView.vue
Normal file
34
front/components/Share/FileShareView.vue
Normal 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>
|
||||
Reference in New Issue
Block a user