修改上传图片安全验证问题
This commit is contained in:
@@ -86,9 +86,9 @@ async function onChooseImageSuccess(tempFiles) {
|
||||
...fileRes,
|
||||
...(height > IMAGE_MAX_SIZE.height
|
||||
? {
|
||||
width: Math.floor(IMAGE_MAX_SIZE.height * image_aspect_ratio),
|
||||
height: IMAGE_MAX_SIZE.height,
|
||||
}
|
||||
width: Math.floor(IMAGE_MAX_SIZE.height * image_aspect_ratio),
|
||||
height: IMAGE_MAX_SIZE.height,
|
||||
}
|
||||
: { width: Math.floor(height * image_aspect_ratio), height }),
|
||||
};
|
||||
} else {
|
||||
@@ -96,9 +96,9 @@ async function onChooseImageSuccess(tempFiles) {
|
||||
...fileRes,
|
||||
...(width > IMAGE_MAX_SIZE.width
|
||||
? {
|
||||
width: IMAGE_MAX_SIZE.width,
|
||||
height: Math.floor(IMAGE_MAX_SIZE.width / image_aspect_ratio),
|
||||
}
|
||||
width: IMAGE_MAX_SIZE.width,
|
||||
height: Math.floor(IMAGE_MAX_SIZE.width / image_aspect_ratio),
|
||||
}
|
||||
: { width, height: Math.floor(width / image_aspect_ratio) }),
|
||||
};
|
||||
}
|
||||
@@ -119,7 +119,6 @@ export default function UploadFromWx(props: UploadFromWxProps) {
|
||||
sourceType: ["album", "camera"],
|
||||
}).then(async (res) => {
|
||||
const analyzedFiles = await onChooseImageSuccess(res.tempFiles);
|
||||
// cropping image to standard size
|
||||
const compressedTempFiles = await compressImage(analyzedFiles);
|
||||
|
||||
let start = Date.now();
|
||||
@@ -130,19 +129,22 @@ export default function UploadFromWx(props: UploadFromWxProps) {
|
||||
is_public: 1 as unknown as 0 | 1,
|
||||
id: (start++).toString(),
|
||||
}));
|
||||
const onFileUpdate = uploadApi.batchUpload(files).then((res) => {
|
||||
return res.map((item) => ({
|
||||
id: item.id,
|
||||
url: item ? item.data.file_url : "",
|
||||
}));
|
||||
});
|
||||
onAdd(
|
||||
files.map((item) => ({
|
||||
id: item.id,
|
||||
url: item.filePath,
|
||||
})),
|
||||
onFileUpdate
|
||||
);
|
||||
|
||||
Taro.showLoading({ title: "上传中..." });
|
||||
try {
|
||||
const uploadRes = await uploadApi.batchUpload(files);
|
||||
const successful = uploadRes
|
||||
.filter((item) => item.data != null)
|
||||
.map((item) => ({
|
||||
id: item.id,
|
||||
url: (item.data as { file_url: string }).file_url,
|
||||
}));
|
||||
onAdd(successful, Promise.resolve(successful));
|
||||
} catch (e) {
|
||||
console.warn("批量上传失败:", e);
|
||||
} finally {
|
||||
Taro.hideLoading();
|
||||
}
|
||||
});
|
||||
};
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user