mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 07:08:02 +00:00
feat(front): reintroduce FileUploadResultView component and enhance FileUploadProgressView with file_id handling for improved upload result management
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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>
|
||||
|
||||
23
front/components/Upload/File/FileUploadResultView.vue
Normal file
23
front/components/Upload/File/FileUploadResultView.vue
Normal 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>
|
||||
Reference in New Issue
Block a user