Commit 3dce3c3d by yancanhua

fix: 文件上传限制

1 parent 6f9f2550
Pipeline #162 for 3dce3c3d failed in 0 seconds
......@@ -47,9 +47,10 @@ async function onFileChange(ev: Event) {
const file = input.files?.[0];
input.value = "";
if (!file) return;
const fileSize = file.size / 1024 / 1024;
if (fileSize && fileSize > 5) {
return showToast(`文件大小不能超过5MB`);
const maxSize10MB = 10 * 1024 * 1024;
if (file.size > maxSize10MB) {
showToast("文件大小不能超过10MB");
return;
}
uploading.value = true;
try {
......
......@@ -48,16 +48,16 @@ async function onFileChange(ev: Event) {
const file = input.files?.[0];
input.value = "";
if (!file) return;
const fileSize = file.size / 1024 / 1024;
// 检查文件大小是否超过限制 10MB
if (props.item.interactionType == 'image_upload' && fileSize && fileSize > 5) {
return showToast(`文件大小不能超过5MB`);;
const maxSize10MB = 10 * 1024 * 1024;
const maxSize100MB = 100 * 1024 * 1024;
if (props.item.interactionType == 'image_upload' && file.size > maxSize10MB) {
showToast("文件大小不能超过10MB");
return;
}
// 检查文件大小是否超过限制 10MB
if (props.item.interactionType == 'video_upload' && fileSize && fileSize > 100) {
return showToast(`文件大小不能超过100MB`);
if (props.item.interactionType == 'video_upload' && file.size > maxSize100MB) {
showToast("文件大小不能超过100MB");
return;
}
uploading.value = true;
try {
const res = await uploadFile(file);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!