文件上传修复
This commit is contained in:
@@ -169,6 +169,8 @@ interface Props {
|
||||
maxCount?: number
|
||||
title?: string
|
||||
buttonText?: string
|
||||
// 是否自动上传,默认 true,设为 false 时需要手动调用 uploadFiles
|
||||
autoUpload?: boolean
|
||||
// 自定义上传函数,如果提供则使用外部实现,否则使用默认上传逻辑
|
||||
customUpload?: (files: File[]) => Promise<TbSysFileDTO[] | void>
|
||||
}
|
||||
@@ -181,6 +183,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
maxCount: 10,
|
||||
title: '文件上传',
|
||||
buttonText: '上传文件',
|
||||
autoUpload: true,
|
||||
customUpload: undefined
|
||||
})
|
||||
|
||||
@@ -234,7 +237,7 @@ const handleDrop = (event: DragEvent) => {
|
||||
addFiles(Array.from(files))
|
||||
|
||||
// cover模式和content模式下拖拽文件后立即上传
|
||||
if (props.mode === 'cover' || props.mode === 'content') {
|
||||
if (props.autoUpload && (props.mode === 'cover' || props.mode === 'content')) {
|
||||
uploadFiles()
|
||||
}
|
||||
}
|
||||
@@ -321,8 +324,8 @@ const handleFileSelect = (event: Event) => {
|
||||
// 清空 input,允许重复选择同一文件
|
||||
target.value = ''
|
||||
|
||||
// cover模式和content模式下选择文件后立即上传
|
||||
if (props.mode === 'cover' || props.mode === 'content') {
|
||||
// cover模式和content模式下,如果 autoUpload 为 true 则立即上传
|
||||
if (props.autoUpload && (props.mode === 'cover' || props.mode === 'content')) {
|
||||
uploadFiles()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user