Compare commits

..

No commits in common. "043daac375b3b7d8de5963709269f18155151e8d" and "32c22478ae92df7b430265b5c4c9473760e5dcbb" have entirely different histories.

2 changed files with 11 additions and 25 deletions

View File

@ -73,8 +73,8 @@ const Upload = (props) => {
// 验证图片分辨率 // 验证图片分辨率
if (ratioArr.length === 2 && file.type?.startsWith("image/")) { if (ratioArr.length === 2 && file.type?.startsWith("image/")) {
const validateImageResolution = (imageUrl) => {
const img = new Image(); const img = new Image();
img.src = file.url || file.thumbUrl;
img.onload = () => { img.onload = () => {
if (img.width !== +ratioArr[0] || img.height !== +ratioArr[1]) { if (img.width !== +ratioArr[0] || img.height !== +ratioArr[1]) {
message.warning(`只能上传${ratio}分辨率的图片`); message.warning(`只能上传${ratio}分辨率的图片`);
@ -84,20 +84,6 @@ const Upload = (props) => {
} }
onChange?.(fileList); onChange?.(fileList);
}; };
img.src = imageUrl;
};
// 如果有现成的URL则直接使用否则使用FileReader读取本地文件
if (file.url) {
validateImageResolution(file.url);
}
else {
const reader = new FileReader();
reader.onload = (e) => {
validateImageResolution(e.target.result);
};
reader.readAsDataURL(file);
}
} }
else { else {
onChange?.(fileList); onChange?.(fileList);

View File

@ -1,7 +1,7 @@
{ {
"name": "zy-react-library", "name": "zy-react-library",
"private": false, "private": false,
"version": "1.0.9", "version": "1.0.8",
"type": "module", "type": "module",
"description": "", "description": "",
"author": "LiuJiaNan", "author": "LiuJiaNan",