feat: 功能优化
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
</p>
|
||||
<p class="ant-upload-text">点击或拖拽文件到此处上传</p>
|
||||
<p class="ant-upload-hint">
|
||||
支持多文件上传,单个文件不超过 500MB
|
||||
支持多文件上传,单个文件不超过 100MB
|
||||
<br />
|
||||
支持格式:视频(MP4、MOV、AVI等)、图片(JPG、PNG、GIF等)、音频(MP3、WAV等)
|
||||
</p>
|
||||
@@ -63,7 +63,7 @@
|
||||
<a-button
|
||||
type="primary"
|
||||
:loading="uploading"
|
||||
:disabled="fileList.length === 0 || !fileCategory"
|
||||
:disabled="fileList.length === 0"
|
||||
@click="handleConfirm"
|
||||
>
|
||||
{{ uploading ? '上传中...' : `上传 (${fileList.length})` }}
|
||||
@@ -94,16 +94,16 @@ const emit = defineEmits(['update:visible', 'confirm', 'cancel'])
|
||||
|
||||
// 数据
|
||||
const fileList = ref([])
|
||||
const fileCategory = ref('video') // 文件分类,默认为视频集
|
||||
// 文件分类使用默认值,不再在UI中显示
|
||||
const DEFAULT_FILE_CATEGORY = 'video'
|
||||
|
||||
// 支持的文件类型
|
||||
const acceptTypes = 'video/*,image/*,audio/*,.mp4,.mov,.avi,.mkv,.jpg,.jpeg,.png,.gif,.webp,.mp3,.wav,.aac'
|
||||
|
||||
// 监听 visible 变化,重置文件列表和分类
|
||||
// 监听 visible 变化,重置文件列表
|
||||
watch(() => props.visible, (newVal) => {
|
||||
if (!newVal) {
|
||||
fileList.value = []
|
||||
fileCategory.value = 'video' // 重置为默认分类
|
||||
}
|
||||
})
|
||||
|
||||
@@ -134,9 +134,9 @@ const formatFileSize = (bytes) => {
|
||||
|
||||
// 上传前处理
|
||||
const handleBeforeUpload = (file) => {
|
||||
// 检查文件大小(500MB)
|
||||
if (file.size > 500 * 1024 * 1024) {
|
||||
message.warning(`文件 ${file.name} 超过 500MB,已跳过`)
|
||||
// 检查文件大小(100MB)
|
||||
if (file.size > 100 * 1024 * 1024) {
|
||||
message.warning(`文件 ${file.name} 超过 100MB,已跳过`)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -214,12 +214,8 @@ const handleConfirm = () => {
|
||||
return
|
||||
}
|
||||
|
||||
if (!fileCategory.value) {
|
||||
message.warning('请选择文件分类')
|
||||
return
|
||||
}
|
||||
|
||||
emit('confirm', files, fileCategory.value)
|
||||
// 使用默认分类
|
||||
emit('confirm', files, DEFAULT_FILE_CATEGORY)
|
||||
}
|
||||
|
||||
// 处理 visible 变化
|
||||
@@ -239,16 +235,6 @@ const handleCancel = () => {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.upload-category-select {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.upload-label {
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.upload-area {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user