From 838d4253696d1b2bb214e0b441778832f7a13fd5 Mon Sep 17 00:00:00 2001 From: keven1024 Date: Mon, 19 May 2025 21:24:40 +0800 Subject: [PATCH] refactor(front): update file handling properties in FileUploadProgressView and FileShareResult components for consistency --- .../Home/File/FileUploadProgressView.vue | 2 +- front/components/Result/FileShareResult.vue | 55 +++++++++++-------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/front/components/Home/File/FileUploadProgressView.vue b/front/components/Home/File/FileUploadProgressView.vue index bb0682e..f4763f1 100644 --- a/front/components/Home/File/FileUploadProgressView.vue +++ b/front/components/Home/File/FileUploadProgressView.vue @@ -5,7 +5,7 @@ import { cx } from 'class-variance-authority' import calcFileHash from '~/lib/calcFileHash'; import { filesize } from 'filesize'; const props = defineProps<{ - data: { file: File, config: any, file_handle_type: string } + data: { file: File, config: any, handle_type: string } }>() const emit = defineEmits<{ diff --git a/front/components/Result/FileShareResult.vue b/front/components/Result/FileShareResult.vue index 6b07484..93ffad7 100644 --- a/front/components/Result/FileShareResult.vue +++ b/front/components/Result/FileShareResult.vue @@ -4,32 +4,39 @@ import FilePreviewView from '@/components/FilePreviewView.vue'; import { Input } from '@/components/ui/input' import { useClipboard } from '@vueuse/core' import { toast } from 'vue-sonner' +import { useQuery } from '@tanstack/vue-query'; const props = defineProps<{ - data: { file: File, config: any, file_handle_type: string, file_id: string } + data: { file: File, config: any, handle_type: string, file_id: string } }>() +const emit = defineEmits<{ + (e: 'change', key: string): void +}>() +const { data } = useQuery({ + queryKey: ['create-share', props?.data?.file_id], + queryFn: async () => { + const { file_id, config, file } = props?.data || {} + const { name } = file || {} + const data = await $fetch<{ + code: number + data: { + id?: string + } + }>(`/api/share`, { + method: 'POST', + body: { + type: 'file', + config, + data: file_id, + file_name: name + } + }) + return data?.data + } +}) -const { state } = useAsyncState(async () => { - const { file_id, config, file } = props?.data || {} - const { name } = file || {} - const data = await $fetch<{ - code: number - data: { - id?: string - } - }>(`/api/share`, { - method: 'POST', - body: { - type: 'file', - config, - data: file_id, - file_name: name - } - }) - return data?.data -}, null) const appConfig = useAppConfig() const url = computed(() => { - const { id } = state?.value || {} + const { id } = data?.value || {} return `${appConfig?.value?.site_url}/s/${id}` }) @@ -42,7 +49,7 @@ const { copy } = useClipboard()

上传成功

- +
@@ -57,7 +64,9 @@ const { copy } = useClipboard()
-