Commit 848a630 1 parent 80fcac3 commit 848a630 Copy full SHA for 848a630
File tree 1 file changed +11
-9
lines changed
1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -146,21 +146,23 @@ $(document).ready(function() {
146
146
const selectedInterface = $('#interfaceSelector').val();
147
147
const file = $('#fileInput')[0].files[0];
148
148
149
- if (file && file.size > 5 * 1024 * 1024 ) {
149
+ if (file) {
150
150
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
+ }
152
158
} else {
153
159
const compressedFile = await compressImage(file);
154
160
await uploadFile(compressedFile);
161
+ return;
155
162
}
156
- return;
157
- }
158
-
159
- if (file && (file.type === 'image/gif' || file.type.includes('image/'))) {
160
- await uploadFile(file);
161
163
}
162
164
}
163
-
165
+
164
166
// 处理上传文件函数
165
167
async function uploadFile(file) {
166
168
try {
@@ -181,7 +183,7 @@ $(document).ready(function() {
181
183
}
182
184
183
185
//处理图片压缩事件
184
- async function compressImage(file, quality = 0.6 , maxResolution = 20000000) {
186
+ async function compressImage(file, quality = 0.5 , maxResolution = 20000000) {
185
187
$('#compressingText').show();
186
188
187
189
return new Promise((resolve) => {
You can’t perform that action at this time.
0 commit comments