feat(front): reintroduce FileUploadResultView component and enhance FileUploadProgressView with file_id handling for improved upload result management

This commit is contained in:
keven1024
2025-05-01 15:58:28 +08:00
parent a853d9f276
commit 610da371bc
3 changed files with 30 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ import FileUploadResultView from './FileUploadResultView.vue'
const fileStepList = [
{ component: FileUploadInputFileView, key: 'input' },
{ component: FileUploadProgressView, key: 'progress' },
// { component: FileUploadResultView, key: 'result' },
{ component: FileUploadResultView, key: 'result' },
]
const step = ref('input')

View File

@@ -5,13 +5,15 @@ import { cx } from 'class-variance-authority'
import calcFileHash from '~/lib/calcFileHash';
import { filesize } from 'filesize';
const props = defineProps<{
data: any
data: { file: File, config: any, file_handle_type: string }
}>()
const emit = defineEmits<{
(e: 'change', key: string): void
}>()
const form = useFormContext()
const step = ref<'hash' | 'upload'>('hash')
const calcHashTime = ref(0)
const chunkSize = ref(0)
@@ -52,6 +54,8 @@ useAsyncState(async () => {
const { id, chunk_size, type: createType } = createData?.data || {}
if (createType !== 'init') {
// 文件存在
form.setFieldValue('file_id', id)
emit('change', 'result')
return;
}
chunkSize.value = chunk_size
@@ -107,6 +111,7 @@ useAsyncState(async () => {
if (r?.code !== 200) {
throw new Error('上传失败')
}
form.setFieldValue('file_id', id)
emit('change', 'result')
}, null)
</script>

View File

@@ -0,0 +1,23 @@
<script lang="ts" setup>
import FileShareResult from '@/components/Result/FileShareResult.vue'
const props = defineProps<{
data: { file: File, config: any, file_handle_type: string, file_id: string }
}>()
// console.log(props.data)
const handleList = [
{ component: FileShareResult, key: 'file-share' },
// { component: FileShareResult, key: 'file-share' },
]
const handleComponent = computed(() => {
return handleList.find((item) => item.key === props?.data?.file_handle_type)?.component
})
</script>
<template>
<div class="">
<component :is="handleComponent" :data="data" />
</div>
</template>