zartui 3.1.29 → 3.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/web-types.json +1 -1
- package/lib/zartui.cjs.js +1 -1
- package/lib/zartui.es.js +1 -1
- package/lib/zartui.js +35 -4
- package/lib/zartui.min.js +1 -1
- package/package.json +5 -5
package/lib/zartui.cjs.js
CHANGED
|
@@ -20554,7 +20554,7 @@ const Lazyload = {
|
|
|
20554
20554
|
});
|
|
20555
20555
|
}
|
|
20556
20556
|
};
|
|
20557
|
-
const version = "3.1.
|
|
20557
|
+
const version = "3.1.30";
|
|
20558
20558
|
function install(app) {
|
|
20559
20559
|
const components = [
|
|
20560
20560
|
ActionSheet,
|
package/lib/zartui.es.js
CHANGED
|
@@ -20552,7 +20552,7 @@ const Lazyload = {
|
|
|
20552
20552
|
});
|
|
20553
20553
|
}
|
|
20554
20554
|
};
|
|
20555
|
-
const version = "3.1.
|
|
20555
|
+
const version = "3.1.30";
|
|
20556
20556
|
function install(app) {
|
|
20557
20557
|
const components = [
|
|
20558
20558
|
ActionSheet,
|
package/lib/zartui.js
CHANGED
|
@@ -15384,16 +15384,28 @@
|
|
|
15384
15384
|
);
|
|
15385
15385
|
});
|
|
15386
15386
|
}
|
|
15387
|
-
compress(canvas, filename, lastModified, type, quality) {
|
|
15387
|
+
compress(canvas, filename, lastModified, type, quality, lastCompressFileSize = -1) {
|
|
15388
15388
|
return canvas2File(canvas, filename, lastModified, type, quality).then(
|
|
15389
15389
|
(file) => {
|
|
15390
|
-
|
|
15390
|
+
let qualityStep = JPEG_QUALITY_STEP;
|
|
15391
|
+
if (file.size > this.compressOptions.photoFileSizeLimit * 1024) {
|
|
15392
|
+
let factor = Math.floor(file.size / (1024 * this.compressOptions.photoFileSizeLimit));
|
|
15393
|
+
if (factor > 1 && quality > MIN_JPEG_QUALITY) {
|
|
15394
|
+
qualityStep = this.roundToDecimalPlace(JPEG_QUALITY_STEP * factor, 2);
|
|
15395
|
+
let maxQualityStep = this.roundToDecimalPlace(quality - MIN_JPEG_QUALITY, 2);
|
|
15396
|
+
qualityStep = Math.min(qualityStep, maxQualityStep);
|
|
15397
|
+
}
|
|
15398
|
+
}
|
|
15399
|
+
let compressFileSizeChanged = lastCompressFileSize === -1 || file.size < lastCompressFileSize;
|
|
15400
|
+
let nextCompressQuality = this.roundToDecimalPlace(quality - qualityStep, 2);
|
|
15401
|
+
if (compressFileSizeChanged && file.size > this.compressOptions.photoFileSizeLimit * 1024 && this.compareFloats(nextCompressQuality, MIN_JPEG_QUALITY) >= 0) {
|
|
15391
15402
|
return this.compress(
|
|
15392
15403
|
canvas,
|
|
15393
15404
|
filename,
|
|
15394
15405
|
lastModified,
|
|
15395
15406
|
type,
|
|
15396
|
-
|
|
15407
|
+
this.roundToDecimalPlace(nextCompressQuality, 2),
|
|
15408
|
+
file.size
|
|
15397
15409
|
);
|
|
15398
15410
|
} else {
|
|
15399
15411
|
return Promise.resolve(file);
|
|
@@ -15401,6 +15413,25 @@
|
|
|
15401
15413
|
}
|
|
15402
15414
|
);
|
|
15403
15415
|
}
|
|
15416
|
+
/**
|
|
15417
|
+
* 浮点型数据比较大小
|
|
15418
|
+
*/
|
|
15419
|
+
compareFloats(a, b) {
|
|
15420
|
+
const diff = Math.abs(a - b);
|
|
15421
|
+
if (diff < Number.EPSILON) {
|
|
15422
|
+
return 0;
|
|
15423
|
+
}
|
|
15424
|
+
return a - b > 0 ? 1 : -1;
|
|
15425
|
+
}
|
|
15426
|
+
/**
|
|
15427
|
+
* 浮点型数据保留小数(四舍五入)
|
|
15428
|
+
* @param num 浮点型数据
|
|
15429
|
+
* @param decimalPlaces 保留的小数位数
|
|
15430
|
+
*/
|
|
15431
|
+
roundToDecimalPlace(num, decimalPlaces) {
|
|
15432
|
+
const factor = Math.pow(10, decimalPlaces);
|
|
15433
|
+
return Math.round(num * factor) / factor;
|
|
15434
|
+
}
|
|
15404
15435
|
};
|
|
15405
15436
|
const chooseImage = (type) => {
|
|
15406
15437
|
return new Promise((resolve, reject) => {
|
|
@@ -24552,7 +24583,7 @@
|
|
|
24552
24583
|
});
|
|
24553
24584
|
}
|
|
24554
24585
|
};
|
|
24555
|
-
const version = "3.1.
|
|
24586
|
+
const version = "3.1.30";
|
|
24556
24587
|
function install(app) {
|
|
24557
24588
|
const components = [
|
|
24558
24589
|
ActionSheet,
|