mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-07 23:31:08 +08:00
fix(upload): 修复文件大小校验失败后仍被加入列表的问题
通过返回 Upload.LIST_IGNORE 替代 false,防止不符合大小限制的文件被加入上传文件列表,解决 Safari 浏览器兼容性问题。
This commit is contained in:
@@ -22,7 +22,7 @@ import { computed, onUnmounted, ref, watch } from 'vue';
|
|||||||
|
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
import { message, Modal } from 'ant-design-vue';
|
import { message, Modal, Upload } from 'ant-design-vue';
|
||||||
import { isFunction, isString } from 'lodash-es';
|
import { isFunction, isString } from 'lodash-es';
|
||||||
|
|
||||||
import { ossInfo } from '#/api/system/oss';
|
import { ossInfo } from '#/api/system/oss';
|
||||||
@@ -271,7 +271,8 @@ export function useUpload(
|
|||||||
const isLtMax = file.size / 1024 / 1024 < props.maxSize!;
|
const isLtMax = file.size / 1024 / 1024 < props.maxSize!;
|
||||||
if (!isLtMax) {
|
if (!isLtMax) {
|
||||||
message.error($t('component.upload.maxSize', [props.maxSize]));
|
message.error($t('component.upload.maxSize', [props.maxSize]));
|
||||||
return false;
|
// 防止被加入文件列表 可以通过返回 Upload.LIST_IGNORE 实现。
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
}
|
}
|
||||||
// 大坑 Safari不支持file-type库 去除文件类型的校验
|
// 大坑 Safari不支持file-type库 去除文件类型的校验
|
||||||
return file;
|
return file;
|
||||||
|
|||||||
Reference in New Issue
Block a user