zartui 3.1.75 → 3.1.76
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/es/media-picker/MediaPicker.d.ts +13 -0
- package/es/media-picker/MediaPicker.mjs +20 -2
- package/es/media-picker/index.d.ts +9 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/media-picker/MediaPicker.d.ts +13 -0
- package/lib/media-picker/MediaPicker.js +20 -2
- package/lib/media-picker/index.d.ts +9 -0
- package/lib/web-types.json +1 -1
- package/lib/zartui.cjs.js +21 -3
- package/lib/zartui.es.js +21 -3
- package/lib/zartui.js +58 -14
- package/lib/zartui.min.js +2 -2
- package/package.json +6 -6
package/lib/zartui.cjs.js
CHANGED
|
@@ -16091,6 +16091,11 @@ const mediaPickerProps = {
|
|
|
16091
16091
|
maxImageFileSize: makeNumberProp(1024),
|
|
16092
16092
|
// 单个文件大小限制(本单位为KB,默认最大1M)
|
|
16093
16093
|
maxFileSize: makeNumberProp(FILE_SIZE_LIMIT * 1024),
|
|
16094
|
+
// 是否保持原始文件类型(不转换为jpg)
|
|
16095
|
+
keepFileType: {
|
|
16096
|
+
type: Boolean,
|
|
16097
|
+
default: false
|
|
16098
|
+
},
|
|
16094
16099
|
/**
|
|
16095
16100
|
* {
|
|
16096
16101
|
* maxImageSideLength,
|
|
@@ -16398,10 +16403,22 @@ var stdin_default$C = vue.defineComponent({
|
|
|
16398
16403
|
}).finally(() => {
|
|
16399
16404
|
});
|
|
16400
16405
|
};
|
|
16406
|
+
const getExtensionFromMimeType = (mimeType) => {
|
|
16407
|
+
const mimeToExt = {
|
|
16408
|
+
"image/jpeg": "jpg",
|
|
16409
|
+
"image/jpg": "jpg",
|
|
16410
|
+
"image/png": "png",
|
|
16411
|
+
"image/gif": "gif",
|
|
16412
|
+
"image/webp": "webp",
|
|
16413
|
+
"image/bmp": "bmp",
|
|
16414
|
+
"image/svg+xml": "svg"
|
|
16415
|
+
};
|
|
16416
|
+
return mimeToExt[mimeType] || "jpg";
|
|
16417
|
+
};
|
|
16401
16418
|
const transformImageFiles = (files) => {
|
|
16402
16419
|
const promisesTodo = [];
|
|
16403
16420
|
const resizeOptions = new appMediaUtils.ResizeOptions(props.maxImageSideLength);
|
|
16404
|
-
const compressOptions = new appMediaUtils.CompressOptions(props.maxImageFileSize);
|
|
16421
|
+
const compressOptions = new appMediaUtils.CompressOptions(props.maxImageFileSize, props.keepFileType);
|
|
16405
16422
|
for (let i = 0; i < files.length; i++) {
|
|
16406
16423
|
const file = files[i];
|
|
16407
16424
|
const watermarkEnabled = props.watermarkOptions && props.watermarkOptions.watermarkConfigString && appMediaUtils.checkWatermarkConfigSupported(props.watermarkOptions.watermarkConfigString);
|
|
@@ -16427,7 +16444,8 @@ var stdin_default$C = vue.defineComponent({
|
|
|
16427
16444
|
return Promise.resolve(null);
|
|
16428
16445
|
}
|
|
16429
16446
|
return file2DataURL(f).then((base64) => {
|
|
16430
|
-
const
|
|
16447
|
+
const ext = props.keepFileType ? getExtensionFromMimeType(f.type) : "jpg";
|
|
16448
|
+
const uniqueFileName = getUniqueFileName(f, ext);
|
|
16431
16449
|
const media = {
|
|
16432
16450
|
showSrc: base64,
|
|
16433
16451
|
type: "photo",
|
|
@@ -23499,7 +23517,7 @@ const Lazyload = {
|
|
|
23499
23517
|
});
|
|
23500
23518
|
}
|
|
23501
23519
|
};
|
|
23502
|
-
const version = "3.1.
|
|
23520
|
+
const version = "3.1.76";
|
|
23503
23521
|
function install(app) {
|
|
23504
23522
|
const components = [
|
|
23505
23523
|
ActionSheet,
|
package/lib/zartui.es.js
CHANGED
|
@@ -16089,6 +16089,11 @@ const mediaPickerProps = {
|
|
|
16089
16089
|
maxImageFileSize: makeNumberProp(1024),
|
|
16090
16090
|
// 单个文件大小限制(本单位为KB,默认最大1M)
|
|
16091
16091
|
maxFileSize: makeNumberProp(FILE_SIZE_LIMIT * 1024),
|
|
16092
|
+
// 是否保持原始文件类型(不转换为jpg)
|
|
16093
|
+
keepFileType: {
|
|
16094
|
+
type: Boolean,
|
|
16095
|
+
default: false
|
|
16096
|
+
},
|
|
16092
16097
|
/**
|
|
16093
16098
|
* {
|
|
16094
16099
|
* maxImageSideLength,
|
|
@@ -16396,10 +16401,22 @@ var stdin_default$C = defineComponent({
|
|
|
16396
16401
|
}).finally(() => {
|
|
16397
16402
|
});
|
|
16398
16403
|
};
|
|
16404
|
+
const getExtensionFromMimeType = (mimeType) => {
|
|
16405
|
+
const mimeToExt = {
|
|
16406
|
+
"image/jpeg": "jpg",
|
|
16407
|
+
"image/jpg": "jpg",
|
|
16408
|
+
"image/png": "png",
|
|
16409
|
+
"image/gif": "gif",
|
|
16410
|
+
"image/webp": "webp",
|
|
16411
|
+
"image/bmp": "bmp",
|
|
16412
|
+
"image/svg+xml": "svg"
|
|
16413
|
+
};
|
|
16414
|
+
return mimeToExt[mimeType] || "jpg";
|
|
16415
|
+
};
|
|
16399
16416
|
const transformImageFiles = (files) => {
|
|
16400
16417
|
const promisesTodo = [];
|
|
16401
16418
|
const resizeOptions = new ResizeOptions(props.maxImageSideLength);
|
|
16402
|
-
const compressOptions = new CompressOptions(props.maxImageFileSize);
|
|
16419
|
+
const compressOptions = new CompressOptions(props.maxImageFileSize, props.keepFileType);
|
|
16403
16420
|
for (let i = 0; i < files.length; i++) {
|
|
16404
16421
|
const file = files[i];
|
|
16405
16422
|
const watermarkEnabled = props.watermarkOptions && props.watermarkOptions.watermarkConfigString && checkWatermarkConfigSupported(props.watermarkOptions.watermarkConfigString);
|
|
@@ -16425,7 +16442,8 @@ var stdin_default$C = defineComponent({
|
|
|
16425
16442
|
return Promise.resolve(null);
|
|
16426
16443
|
}
|
|
16427
16444
|
return file2DataURL(f).then((base64) => {
|
|
16428
|
-
const
|
|
16445
|
+
const ext = props.keepFileType ? getExtensionFromMimeType(f.type) : "jpg";
|
|
16446
|
+
const uniqueFileName = getUniqueFileName(f, ext);
|
|
16429
16447
|
const media = {
|
|
16430
16448
|
showSrc: base64,
|
|
16431
16449
|
type: "photo",
|
|
@@ -23497,7 +23515,7 @@ const Lazyload = {
|
|
|
23497
23515
|
});
|
|
23498
23516
|
}
|
|
23499
23517
|
};
|
|
23500
|
-
const version = "3.1.
|
|
23518
|
+
const version = "3.1.76";
|
|
23501
23519
|
function install(app) {
|
|
23502
23520
|
const components = [
|
|
23503
23521
|
ActionSheet,
|
package/lib/zartui.js
CHANGED
|
@@ -15383,9 +15383,10 @@
|
|
|
15383
15383
|
canvas.height = _height;
|
|
15384
15384
|
const ctx = canvas.getContext("2d");
|
|
15385
15385
|
if (ctx) {
|
|
15386
|
-
|
|
15387
|
-
if (
|
|
15386
|
+
const needWhiteBackground = type === "image/jpeg" || type === "image/jpg" || type === "image/bmp";
|
|
15387
|
+
if (needWhiteBackground) {
|
|
15388
15388
|
ctx.fillStyle = "#fff";
|
|
15389
|
+
ctx.fillRect(0, 0, _width, _height);
|
|
15389
15390
|
}
|
|
15390
15391
|
ctx.drawImage(img, 0, 0, _width, _height);
|
|
15391
15392
|
return Promise.resolve(canvas);
|
|
@@ -15468,13 +15469,14 @@
|
|
|
15468
15469
|
}
|
|
15469
15470
|
};
|
|
15470
15471
|
var CompressOptions = class {
|
|
15471
|
-
//
|
|
15472
|
-
constructor(photoFileSizeLimit) {
|
|
15472
|
+
// 是否保持原始文件类型
|
|
15473
|
+
constructor(photoFileSizeLimit, keepFileType = false) {
|
|
15473
15474
|
if (checkIsUndefinedOrNull(photoFileSizeLimit)) {
|
|
15474
15475
|
this.photoFileSizeLimit = PHOTO_FILE_SIZE_LIMIT;
|
|
15475
15476
|
} else {
|
|
15476
15477
|
this.photoFileSizeLimit = photoFileSizeLimit;
|
|
15477
15478
|
}
|
|
15479
|
+
this.keepFileType = keepFileType;
|
|
15478
15480
|
}
|
|
15479
15481
|
};
|
|
15480
15482
|
var ImageProcessor = class {
|
|
@@ -15488,12 +15490,15 @@
|
|
|
15488
15490
|
process() {
|
|
15489
15491
|
const filename = this.file.name;
|
|
15490
15492
|
const { lastModified } = this.file;
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
|
|
15495
|
-
|
|
15496
|
-
|
|
15493
|
+
const originalFileType = this.file.type;
|
|
15494
|
+
let fileType = originalFileType;
|
|
15495
|
+
if (!this.compressOptions.keepFileType) {
|
|
15496
|
+
if (this.file.size > this.compressOptions.photoFileSizeLimit * 1024) {
|
|
15497
|
+
fileType = "image/jpeg";
|
|
15498
|
+
}
|
|
15499
|
+
if (fileType === "image/gif") {
|
|
15500
|
+
fileType = "image/png";
|
|
15501
|
+
}
|
|
15497
15502
|
}
|
|
15498
15503
|
return file2Image(this.file).then((img) => {
|
|
15499
15504
|
return resize(img, {
|
|
@@ -15505,7 +15510,13 @@
|
|
|
15505
15510
|
const canvas = result;
|
|
15506
15511
|
return yield renderWatermark(canvas, this.watermarkOptions);
|
|
15507
15512
|
})).then((canvas) => {
|
|
15508
|
-
|
|
15513
|
+
let exportFilename;
|
|
15514
|
+
if (this.compressOptions.keepFileType) {
|
|
15515
|
+
const ext = this.getExtensionFromMimeType(fileType);
|
|
15516
|
+
exportFilename = filename.replace(/\.[^.]+$/, "") + "." + ext;
|
|
15517
|
+
} else {
|
|
15518
|
+
exportFilename = filename.replace(/\./g, "-") + ".jpg";
|
|
15519
|
+
}
|
|
15509
15520
|
return this.compress(
|
|
15510
15521
|
canvas,
|
|
15511
15522
|
exportFilename,
|
|
@@ -15515,6 +15526,21 @@
|
|
|
15515
15526
|
);
|
|
15516
15527
|
});
|
|
15517
15528
|
}
|
|
15529
|
+
/**
|
|
15530
|
+
* 根据 MIME 类型获取文件扩展名
|
|
15531
|
+
*/
|
|
15532
|
+
getExtensionFromMimeType(mimeType) {
|
|
15533
|
+
const mimeToExt = {
|
|
15534
|
+
"image/jpeg": "jpg",
|
|
15535
|
+
"image/jpg": "jpg",
|
|
15536
|
+
"image/png": "png",
|
|
15537
|
+
"image/gif": "gif",
|
|
15538
|
+
"image/webp": "webp",
|
|
15539
|
+
"image/bmp": "bmp",
|
|
15540
|
+
"image/svg+xml": "svg"
|
|
15541
|
+
};
|
|
15542
|
+
return mimeToExt[mimeType] || "jpg";
|
|
15543
|
+
}
|
|
15518
15544
|
compress(canvas, filename, lastModified, type, quality, lastCompressFileSize = -1) {
|
|
15519
15545
|
return canvas2File(canvas, filename, lastModified, type, quality).then(
|
|
15520
15546
|
(file) => {
|
|
@@ -17867,6 +17893,11 @@
|
|
|
17867
17893
|
maxImageFileSize: makeNumberProp(1024),
|
|
17868
17894
|
// 单个文件大小限制(本单位为KB,默认最大1M)
|
|
17869
17895
|
maxFileSize: makeNumberProp(FILE_SIZE_LIMIT * 1024),
|
|
17896
|
+
// 是否保持原始文件类型(不转换为jpg)
|
|
17897
|
+
keepFileType: {
|
|
17898
|
+
type: Boolean,
|
|
17899
|
+
default: false
|
|
17900
|
+
},
|
|
17870
17901
|
/**
|
|
17871
17902
|
* {
|
|
17872
17903
|
* maxImageSideLength,
|
|
@@ -18174,10 +18205,22 @@
|
|
|
18174
18205
|
}).finally(() => {
|
|
18175
18206
|
});
|
|
18176
18207
|
};
|
|
18208
|
+
const getExtensionFromMimeType = (mimeType) => {
|
|
18209
|
+
const mimeToExt = {
|
|
18210
|
+
"image/jpeg": "jpg",
|
|
18211
|
+
"image/jpg": "jpg",
|
|
18212
|
+
"image/png": "png",
|
|
18213
|
+
"image/gif": "gif",
|
|
18214
|
+
"image/webp": "webp",
|
|
18215
|
+
"image/bmp": "bmp",
|
|
18216
|
+
"image/svg+xml": "svg"
|
|
18217
|
+
};
|
|
18218
|
+
return mimeToExt[mimeType] || "jpg";
|
|
18219
|
+
};
|
|
18177
18220
|
const transformImageFiles = (files) => {
|
|
18178
18221
|
const promisesTodo = [];
|
|
18179
18222
|
const resizeOptions = new ResizeOptions(props.maxImageSideLength);
|
|
18180
|
-
const compressOptions = new CompressOptions(props.maxImageFileSize);
|
|
18223
|
+
const compressOptions = new CompressOptions(props.maxImageFileSize, props.keepFileType);
|
|
18181
18224
|
for (let i = 0; i < files.length; i++) {
|
|
18182
18225
|
const file = files[i];
|
|
18183
18226
|
const watermarkEnabled = props.watermarkOptions && props.watermarkOptions.watermarkConfigString && checkWatermarkConfigSupported(props.watermarkOptions.watermarkConfigString);
|
|
@@ -18203,7 +18246,8 @@
|
|
|
18203
18246
|
return Promise.resolve(null);
|
|
18204
18247
|
}
|
|
18205
18248
|
return file2DataURL$1(f).then((base64) => {
|
|
18206
|
-
const
|
|
18249
|
+
const ext = props.keepFileType ? getExtensionFromMimeType(f.type) : "jpg";
|
|
18250
|
+
const uniqueFileName = getUniqueFileName(f, ext);
|
|
18207
18251
|
const media = {
|
|
18208
18252
|
showSrc: base64,
|
|
18209
18253
|
type: "photo",
|
|
@@ -27559,7 +27603,7 @@
|
|
|
27559
27603
|
});
|
|
27560
27604
|
}
|
|
27561
27605
|
};
|
|
27562
|
-
const version = "3.1.
|
|
27606
|
+
const version = "3.1.76";
|
|
27563
27607
|
function install(app) {
|
|
27564
27608
|
const components = [
|
|
27565
27609
|
ActionSheet,
|