Skip to content

Commit 848a630

Browse files
authored
Update worker.js
1 parent 80fcac3 commit 848a630

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

worker.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,23 @@ $(document).ready(function() {
146146
const selectedInterface = $('#interfaceSelector').val();
147147
const file = $('#fileInput')[0].files[0];
148148
149-
if (file && file.size > 5 * 1024 * 1024) {
149+
if (file) {
150150
if (file.type === 'image/gif') {
151-
toastr.error('GIF 文件必须≤5MB');
151+
if (file.size > 5 * 1024 * 1024) {
152+
toastr.error('GIF 文件必须≤5MB');
153+
return;
154+
} else {
155+
await uploadFile(file);
156+
return;
157+
}
152158
} else {
153159
const compressedFile = await compressImage(file);
154160
await uploadFile(compressedFile);
161+
return;
155162
}
156-
return;
157-
}
158-
159-
if (file && (file.type === 'image/gif' || file.type.includes('image/'))) {
160-
await uploadFile(file);
161163
}
162164
}
163-
165+
164166
// 处理上传文件函数
165167
async function uploadFile(file) {
166168
try {
@@ -181,7 +183,7 @@ $(document).ready(function() {
181183
}
182184
183185
//处理图片压缩事件
184-
async function compressImage(file, quality = 0.6, maxResolution = 20000000) {
186+
async function compressImage(file, quality = 0.5, maxResolution = 20000000) {
185187
$('#compressingText').show();
186188
187189
return new Promise((resolve) => {

0 commit comments

Comments
 (0)