style: 统一图片上传逻辑代码格式
This commit is contained in:
@@ -167,12 +167,16 @@ export function createProductDetailDataActions(
|
||||
}
|
||||
|
||||
function isAllowedProductImageFile(file: File) {
|
||||
const mimeType = String(file.type || '').trim().toLowerCase();
|
||||
const mimeType = String(file.type || '')
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
if (mimeType && ALLOWED_PRODUCT_IMAGE_MIME_SET.has(mimeType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const lowerName = String(file.name || '').trim().toLowerCase();
|
||||
const lowerName = String(file.name || '')
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
return ALLOWED_PRODUCT_IMAGE_EXT.some((ext) => lowerName.endsWith(ext));
|
||||
}
|
||||
|
||||
@@ -184,7 +188,9 @@ export function createProductDetailDataActions(
|
||||
return;
|
||||
}
|
||||
|
||||
const invalidFiles = files.filter((file) => !isAllowedProductImageFile(file));
|
||||
const invalidFiles = files.filter(
|
||||
(file) => !isAllowedProductImageFile(file),
|
||||
);
|
||||
if (invalidFiles.length > 0) {
|
||||
message.warning('仅支持 JPG/PNG/WEBP 格式');
|
||||
}
|
||||
@@ -235,7 +241,9 @@ export function createProductDetailDataActions(
|
||||
}
|
||||
if (failedCount > 0) {
|
||||
message.error(
|
||||
failedCount === 1 ? '1 张图片上传失败' : `${failedCount} 张图片上传失败`,
|
||||
failedCount === 1
|
||||
? '1 张图片上传失败'
|
||||
: `${failedCount} 张图片上传失败`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user