feat: 功能优化

This commit is contained in:
2025-11-16 22:09:41 +08:00
parent 995385f520
commit 3a9e823375
5 changed files with 129 additions and 42 deletions

View File

@@ -39,10 +39,9 @@ export const MaterialService = {
const formData = new FormData()
formData.append('file', file)
formData.append('fileCategory', fileCategory)
// 大文件上传需要更长的超时时间30分钟
return http.post(`${BASE_URL}/upload`, formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
timeout: 30 * 60 * 1000 // 30分钟
})
},

View File

@@ -25,7 +25,7 @@
</p>
<p class="ant-upload-text">点击或拖拽文件到此处上传</p>
<p class="ant-upload-hint">
支持多文件上传单个文件不超过 500MB
支持多文件上传单个文件不超过 100MB
<br />
支持格式视频MP4MOVAVI等图片JPGPNGGIF等音频MP3WAV等
</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;
}

View File

@@ -148,7 +148,6 @@ const uploading = ref(false)
// 筛选条件
const filters = reactive({
fileCategory: undefined,
fileName: '',
createTime: undefined
})
@@ -204,11 +203,6 @@ const handleConfirmUpload = async (files, fileCategory) => {
return
}
if (!fileCategory) {
message.warning('请选择文件分类')
return
}
uploading.value = true
let successCount = 0
let failCount = 0
@@ -289,7 +283,6 @@ const handleFilterChange = () => {
}
const handleResetFilters = () => {
filters.fileCategory = undefined
filters.fileName = ''
filters.createTime = undefined
pagination.pageNo = 1