|
@ -223,7 +223,19 @@ const submitForm = async () => { |
|
|
message.error('请上传文件') |
|
|
message.error('请上传文件') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
file.value = fileList.value[0].name |
|
|
// 校验文件类型 |
|
|
|
|
|
const fileName = fileList.value[0].name |
|
|
|
|
|
const fileExtension = fileName.substring(fileName.lastIndexOf('.')).toLowerCase() |
|
|
|
|
|
const acceptedTypes = accept.value.split(',').map(type => type.toLowerCase()) |
|
|
|
|
|
|
|
|
|
|
|
// 检查文件扩展名是否在允许的类型列表中 |
|
|
|
|
|
if (!acceptedTypes.some(type => type === fileExtension || type === `.*${fileExtension}`)) { |
|
|
|
|
|
message.error(`只能上传 ${accept.value} 格式的文件`) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
file.value = fileName |
|
|
|
|
|
|
|
|
// 提交请求 |
|
|
// 提交请求 |
|
|
uploadHeaders.value = { |
|
|
uploadHeaders.value = { |
|
|
Authorization: 'Bearer ' + getAccessToken(), |
|
|
Authorization: 'Bearer ' + getAccessToken(), |
|
|