feat: harden CMPP delivery and platform workflows

This commit is contained in:
hectorzhao
2026-07-20 18:07:29 +08:00
parent 80fb5a8f53
commit f02c33cbb7
61 changed files with 1834 additions and 281 deletions
+16
View File
@@ -0,0 +1,16 @@
export const IMAGE_UPLOAD_MAX_BYTES = 2 * 1024 * 1024;
export const FILE_UPLOAD_MAX_BYTES = 10 * 1024 * 1024;
const IMAGE_FILE_EXTENSION = /\.(?:avif|bmp|gif|heic|heif|jpe?g|png|svg|webp)$/i;
export function isImageUpload(file: Pick<File, 'name' | 'type'>) {
return file.type.toLowerCase().startsWith('image/') || IMAGE_FILE_EXTENSION.test(file.name);
}
export function assertUploadFileSize(file: Pick<File, 'name' | 'size' | 'type'>) {
const image = isImageUpload(file);
const limit = image ? IMAGE_UPLOAD_MAX_BYTES : FILE_UPLOAD_MAX_BYTES;
if (file.size > limit) {
throw new Error(image ? '图片大小不能超过 2MB' : '文件大小不能超过 10MB');
}
}