相关bug调整

This commit is contained in:
fuenmao
2026-09-18 16:08:27 +08:00
parent c812071d8a
commit ea2c823b75
8 changed files with 432 additions and 166 deletions
+16 -6
View File
@@ -1396,12 +1396,16 @@ function getRemainingFileCount(mat: any) {
);
}
const PUBLIC_MATERIAL_MAX_FILE_SIZE_MB = 20;
const PUBLIC_MATERIAL_DEFAULT_EXTENSIONS = ["png", "jpg", "jpeg", "pdf"];
function getAllowedExtensions(mat: any) {
return String(mat.allowedExtensions || "")
const configured = String(mat.allowedExtensions || "")
.toLowerCase()
.split(",")
.map((item: string) => item.trim().replace(/^\./, ""))
.filter(Boolean);
return configured.length ? configured : [...PUBLIC_MATERIAL_DEFAULT_EXTENSIONS];
}
function getUploadAccept(mat: any) {
@@ -1415,9 +1419,11 @@ function getMaterialLimitText(mat: any) {
const formatText = allowedExtensions.length
? allowedExtensions.join("、").toUpperCase()
: "不限";
const sizeText = mat.maxFileSizeMb
? ` · 单个不超过 ${mat.maxFileSizeMb} MB`
: "";
const configuredSize = Number(mat.maxFileSizeMb);
const maxFileSizeMb = configuredSize > 0
? Math.min(configuredSize, PUBLIC_MATERIAL_MAX_FILE_SIZE_MB)
: PUBLIC_MATERIAL_MAX_FILE_SIZE_MB;
const sizeText = ` · 单个不超过 ${maxFileSizeMb} MB`;
return `最多 ${getMaxFileCount(mat)} 份 · 格式:${formatText}${sizeText}`;
}
@@ -1702,8 +1708,12 @@ function beforeUpload(file: File, mat: any) {
ElMessage.error(`仅支持格式:${mat.allowedExtensions}`);
return false;
}
if (mat.maxFileSizeMb && file.size > Number(mat.maxFileSizeMb) * 1024 * 1024) {
ElMessage.error(`单个文件不能超过 ${mat.maxFileSizeMb} MB`);
const configuredSize = Number(mat.maxFileSizeMb);
const maxFileSizeMb = configuredSize > 0
? Math.min(configuredSize, PUBLIC_MATERIAL_MAX_FILE_SIZE_MB)
: PUBLIC_MATERIAL_MAX_FILE_SIZE_MB;
if (file.size > maxFileSizeMb * 1024 * 1024) {
ElMessage.error(`单个文件不能超过 ${maxFileSizeMb} MB,请压缩后重新上传`);
return false;
}
setMaterialUploading(mat.materialTypeId, true);