feat: 功能优化
This commit is contained in:
@@ -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分钟
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user