zartui 3.1.20 → 3.1.21
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/avatar/Avatar.mjs +1 -1
- package/es/icon/index.css +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/media-picker/MediaPicker.mjs +1 -4
- package/es/media-picker/util/media-util.d.ts +0 -55
- package/es/media-picker/util/media-util.mjs +1 -203
- package/es/tabs/Tabs.mjs +1 -0
- package/es/tabs/TabsTitle.d.ts +2 -0
- package/es/tabs/TabsTitle.mjs +24 -2
- package/es/uploader/Uploader.d.ts +1 -1
- package/es/uploader/index.d.ts +1 -1
- package/lib/avatar/Avatar.js +1 -1
- package/lib/icon/index.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/media-picker/MediaPicker.js +5 -8
- package/lib/media-picker/util/media-util.d.ts +0 -55
- package/lib/media-picker/util/media-util.js +1 -203
- package/lib/tabs/Tabs.js +1 -0
- package/lib/tabs/TabsTitle.d.ts +2 -0
- package/lib/tabs/TabsTitle.js +23 -1
- package/lib/uploader/Uploader.d.ts +1 -1
- package/lib/uploader/index.d.ts +1 -1
- package/lib/web-types.json +1 -1
- package/lib/zartui.cjs.js +57 -1017
- package/lib/zartui.es.js +53 -1013
- package/lib/zartui.js +1116 -648
- package/lib/zartui.min.js +1 -1
- package/package.json +7 -6
- package/es/media-picker/watermark/compress-options.d.ts +0 -5
- package/es/media-picker/watermark/compress-options.mjs +0 -23
- package/es/media-picker/watermark/image-processor.d.ts +0 -12
- package/es/media-picker/watermark/image-processor.mjs +0 -97
- package/es/media-picker/watermark/resize-options.d.ts +0 -4
- package/es/media-picker/watermark/resize-options.mjs +0 -27
- package/es/media-picker/watermark/watermark.d.ts +0 -42
- package/es/media-picker/watermark/watermark.mjs +0 -653
- package/lib/media-picker/watermark/compress-options.d.ts +0 -5
- package/lib/media-picker/watermark/compress-options.js +0 -41
- package/lib/media-picker/watermark/image-processor.d.ts +0 -12
- package/lib/media-picker/watermark/image-processor.js +0 -110
- package/lib/media-picker/watermark/resize-options.d.ts +0 -4
- package/lib/media-picker/watermark/resize-options.js +0 -45
- package/lib/media-picker/watermark/watermark.d.ts +0 -42
- package/lib/media-picker/watermark/watermark.js +0 -664
package/lib/zartui.js
CHANGED
|
@@ -8,20 +8,8 @@
|
|
|
8
8
|
const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
9
9
|
const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
|
|
10
10
|
const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
|
|
11
|
-
const isString = (val) => typeof val === "string";
|
|
12
|
-
const isValidString = (val) => typeof val === "string" && val !== "";
|
|
13
|
-
const isRegExp = (val) => Object.prototype.toString.call(val).replace(/\[object (\w+)\]/, "$1").toLowerCase() === "regexp";
|
|
14
11
|
const isIOS$1 = () => inBrowser$1 ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
|
|
15
|
-
const isAndroid = () => inBrowser$1 ? /android/.test(navigator.userAgent.toLowerCase()) : false;
|
|
16
12
|
const isWeixin = () => inBrowser$1 ? /micromessenger/.test(navigator.userAgent.toLowerCase()) : false;
|
|
17
|
-
const getIosVersion = () => {
|
|
18
|
-
const reg = /CPU iPhone OS (.*?) like Mac OS/i;
|
|
19
|
-
const verStr = navigator.userAgent.match(reg);
|
|
20
|
-
if (verStr && verStr[1]) {
|
|
21
|
-
return verStr[1].replace(/_/g, ".");
|
|
22
|
-
}
|
|
23
|
-
return "";
|
|
24
|
-
};
|
|
25
13
|
function noop() {
|
|
26
14
|
}
|
|
27
15
|
const extend = Object.assign;
|
|
@@ -1887,7 +1875,7 @@
|
|
|
1887
1875
|
"style": style.value,
|
|
1888
1876
|
"src": props.src
|
|
1889
1877
|
}, {
|
|
1890
|
-
error: renderText()
|
|
1878
|
+
error: () => renderText()
|
|
1891
1879
|
});
|
|
1892
1880
|
};
|
|
1893
1881
|
}
|
|
@@ -3638,7 +3626,8 @@
|
|
|
3638
3626
|
maxWidth: {
|
|
3639
3627
|
type: String,
|
|
3640
3628
|
default: "112px"
|
|
3641
|
-
}
|
|
3629
|
+
},
|
|
3630
|
+
setLine: Function
|
|
3642
3631
|
},
|
|
3643
3632
|
setup(props, {
|
|
3644
3633
|
slots
|
|
@@ -3698,9 +3687,30 @@
|
|
|
3698
3687
|
}
|
|
3699
3688
|
return Text;
|
|
3700
3689
|
};
|
|
3690
|
+
const mutationObserver = vue.ref();
|
|
3691
|
+
const dom = vue.ref(null);
|
|
3692
|
+
function mutation() {
|
|
3693
|
+
props.setLine && props.setLine();
|
|
3694
|
+
}
|
|
3695
|
+
vue.onMounted(() => {
|
|
3696
|
+
if (!dom.value) {
|
|
3697
|
+
return;
|
|
3698
|
+
}
|
|
3699
|
+
mutationObserver.value = new MutationObserver(mutation);
|
|
3700
|
+
mutationObserver.value.observe(dom.value, {
|
|
3701
|
+
characterData: true,
|
|
3702
|
+
childList: true,
|
|
3703
|
+
subtree: true
|
|
3704
|
+
});
|
|
3705
|
+
});
|
|
3706
|
+
vue.onBeforeUnmount(() => {
|
|
3707
|
+
var _a, _b;
|
|
3708
|
+
(_b = (_a = mutationObserver.value) == null ? void 0 : _a.unobserve) == null ? void 0 : _b.call(_a, dom.value);
|
|
3709
|
+
});
|
|
3701
3710
|
return () => vue.createVNode("div", {
|
|
3702
3711
|
"id": props.id,
|
|
3703
3712
|
"role": "tab",
|
|
3713
|
+
"ref": dom,
|
|
3704
3714
|
"class": [bem$18([props.type, {
|
|
3705
3715
|
grow: props.scrollable && !props.shrink,
|
|
3706
3716
|
shrink: props.shrink,
|
|
@@ -4385,6 +4395,7 @@
|
|
|
4385
4395
|
"scrollable": scrollable.value,
|
|
4386
4396
|
"activeColor": props.titleActiveColor,
|
|
4387
4397
|
"inactiveColor": props.titleInactiveColor,
|
|
4398
|
+
"setLine": setLine,
|
|
4388
4399
|
"onClick": (event) => onClickTab(item, index, event)
|
|
4389
4400
|
}, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
|
|
4390
4401
|
title: item.$slots.title,
|
|
@@ -8520,13 +8531,6 @@
|
|
|
8520
8531
|
}
|
|
8521
8532
|
return result;
|
|
8522
8533
|
};
|
|
8523
|
-
const parseDecimal = (obj, defaultValue) => {
|
|
8524
|
-
let result = parseFloat(obj);
|
|
8525
|
-
if (isNaN(result)) {
|
|
8526
|
-
result = defaultValue || 0;
|
|
8527
|
-
}
|
|
8528
|
-
return result;
|
|
8529
|
-
};
|
|
8530
8534
|
const [name$K, bem$K] = createNamespace("tag");
|
|
8531
8535
|
const tagProps = {
|
|
8532
8536
|
mark: Boolean,
|
|
@@ -13243,9 +13247,6 @@
|
|
|
13243
13247
|
}, null)])])]);
|
|
13244
13248
|
}
|
|
13245
13249
|
});
|
|
13246
|
-
const MAX_SIDE_LENGTH = 1920;
|
|
13247
|
-
const MIN_SIDE_LENGTH = 480;
|
|
13248
|
-
const PHOTO_FILE_SIZE_LIMIT = 1e3;
|
|
13249
13250
|
function isImageType(file) {
|
|
13250
13251
|
return file.type.indexOf("image/") >= 0;
|
|
13251
13252
|
}
|
|
@@ -13269,48 +13270,7 @@
|
|
|
13269
13270
|
)}`;
|
|
13270
13271
|
return suffix ? name2 + "." + suffix : name2;
|
|
13271
13272
|
}
|
|
13272
|
-
function
|
|
13273
|
-
switch (orientation) {
|
|
13274
|
-
case 3:
|
|
13275
|
-
ctx.rotate(180 * Math.PI / 180);
|
|
13276
|
-
ctx.drawImage(img, -width2, -height2, width2, height2);
|
|
13277
|
-
break;
|
|
13278
|
-
case 6:
|
|
13279
|
-
ctx.rotate(90 * Math.PI / 180);
|
|
13280
|
-
ctx.drawImage(img, 0, -width2, height2, width2);
|
|
13281
|
-
break;
|
|
13282
|
-
case 8:
|
|
13283
|
-
ctx.rotate(270 * Math.PI / 180);
|
|
13284
|
-
ctx.drawImage(img, -height2, 0, height2, width2);
|
|
13285
|
-
break;
|
|
13286
|
-
case 2:
|
|
13287
|
-
ctx.translate(width2, 0);
|
|
13288
|
-
ctx.scale(-1, 1);
|
|
13289
|
-
ctx.drawImage(img, 0, 0, width2, height2);
|
|
13290
|
-
break;
|
|
13291
|
-
case 4:
|
|
13292
|
-
ctx.translate(width2, 0);
|
|
13293
|
-
ctx.scale(-1, 1);
|
|
13294
|
-
ctx.rotate(180 * Math.PI / 180);
|
|
13295
|
-
ctx.drawImage(img, -width2, -height2, width2, height2);
|
|
13296
|
-
break;
|
|
13297
|
-
case 5:
|
|
13298
|
-
ctx.translate(width2, 0);
|
|
13299
|
-
ctx.scale(-1, 1);
|
|
13300
|
-
ctx.rotate(90 * Math.PI / 180);
|
|
13301
|
-
ctx.drawImage(img, 0, -width2, height2, width2);
|
|
13302
|
-
break;
|
|
13303
|
-
case 7:
|
|
13304
|
-
ctx.translate(width2, 0);
|
|
13305
|
-
ctx.scale(-1, 1);
|
|
13306
|
-
ctx.rotate(270 * Math.PI / 180);
|
|
13307
|
-
ctx.drawImage(img, -height2, 0, height2, width2);
|
|
13308
|
-
break;
|
|
13309
|
-
default:
|
|
13310
|
-
ctx.drawImage(img, 0, 0, width2, height2);
|
|
13311
|
-
}
|
|
13312
|
-
}
|
|
13313
|
-
function file2DataURL(file) {
|
|
13273
|
+
function file2DataURL$1(file) {
|
|
13314
13274
|
return new Promise((resolve, reject) => {
|
|
13315
13275
|
const a2 = new FileReader();
|
|
13316
13276
|
a2.onload = function(res) {
|
|
@@ -13323,40 +13283,7 @@
|
|
|
13323
13283
|
a2.readAsDataURL(file);
|
|
13324
13284
|
});
|
|
13325
13285
|
}
|
|
13326
|
-
function
|
|
13327
|
-
return new Promise((resolve, reject) => {
|
|
13328
|
-
file2DataURL(file).then((url) => {
|
|
13329
|
-
const img = new Image();
|
|
13330
|
-
img.src = url;
|
|
13331
|
-
img.onload = function() {
|
|
13332
|
-
if (img.complete) {
|
|
13333
|
-
resolve(img);
|
|
13334
|
-
} else {
|
|
13335
|
-
reject(new Error("文件加载失败"));
|
|
13336
|
-
}
|
|
13337
|
-
};
|
|
13338
|
-
}).catch(reject);
|
|
13339
|
-
});
|
|
13340
|
-
}
|
|
13341
|
-
function image2Canvas(img, type, orientation, width2, height2) {
|
|
13342
|
-
const canvas = document.createElement("canvas");
|
|
13343
|
-
const _width = width2 || img.width;
|
|
13344
|
-
const _height = height2 || img.height;
|
|
13345
|
-
canvas.width = _width;
|
|
13346
|
-
canvas.height = _height;
|
|
13347
|
-
const ctx = canvas.getContext("2d");
|
|
13348
|
-
if (ctx) {
|
|
13349
|
-
ctx.fillStyle = "transparent";
|
|
13350
|
-
if (type === "image/jpeg") {
|
|
13351
|
-
ctx.fillStyle = "#fff";
|
|
13352
|
-
}
|
|
13353
|
-
ctx.fillRect(0, 0, _width, _height);
|
|
13354
|
-
adjustImgOrientation(ctx, img, orientation, _width, _height);
|
|
13355
|
-
return Promise.resolve(canvas);
|
|
13356
|
-
}
|
|
13357
|
-
return Promise.reject(new Error("canvas getContext return null"));
|
|
13358
|
-
}
|
|
13359
|
-
function canvas2File(canvas, fileName, lastModified, type = "image/jpeg", quality = 0.8) {
|
|
13286
|
+
function canvas2File$1(canvas, fileName, lastModified, type = "image/jpeg", quality = 0.8) {
|
|
13360
13287
|
return new Promise((resolve, reject) => {
|
|
13361
13288
|
canvas.toBlob(
|
|
13362
13289
|
(blob) => {
|
|
@@ -13372,247 +13299,467 @@
|
|
|
13372
13299
|
);
|
|
13373
13300
|
});
|
|
13374
13301
|
}
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13302
|
+
var __create = Object.create;
|
|
13303
|
+
var __defProp = Object.defineProperty;
|
|
13304
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13305
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13306
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13307
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13308
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
13309
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13310
|
+
};
|
|
13311
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13312
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13313
|
+
for (let key of __getOwnPropNames(from))
|
|
13314
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13315
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13386
13316
|
}
|
|
13387
|
-
return
|
|
13388
|
-
}
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
offset2 += 1;
|
|
13317
|
+
return to;
|
|
13318
|
+
};
|
|
13319
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
13320
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
13321
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
13322
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
13323
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
13324
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
13325
|
+
mod
|
|
13326
|
+
));
|
|
13327
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
13328
|
+
return new Promise((resolve, reject) => {
|
|
13329
|
+
var fulfilled = (value) => {
|
|
13330
|
+
try {
|
|
13331
|
+
step(generator.next(value));
|
|
13332
|
+
} catch (e2) {
|
|
13333
|
+
reject(e2);
|
|
13405
13334
|
}
|
|
13406
|
-
}
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13335
|
+
};
|
|
13336
|
+
var rejected = (value) => {
|
|
13337
|
+
try {
|
|
13338
|
+
step(generator.throw(value));
|
|
13339
|
+
} catch (e2) {
|
|
13340
|
+
reject(e2);
|
|
13341
|
+
}
|
|
13342
|
+
};
|
|
13343
|
+
var step = (x2) => x2.done ? resolve(x2.value) : Promise.resolve(x2.value).then(fulfilled, rejected);
|
|
13344
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
13345
|
+
});
|
|
13346
|
+
};
|
|
13347
|
+
var require_dayjs_min = __commonJS({
|
|
13348
|
+
"../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/dayjs.min.js"(exports3, module2) {
|
|
13349
|
+
!function(t2, e2) {
|
|
13350
|
+
"object" == typeof exports3 && "undefined" != typeof module2 ? module2.exports = e2() : "function" == typeof define && define.amd ? define(e2) : (t2 = "undefined" != typeof globalThis ? globalThis : t2 || self).dayjs = e2();
|
|
13351
|
+
}(exports3, function() {
|
|
13352
|
+
var t2 = 1e3, e2 = 6e4, n2 = 36e5, r2 = "millisecond", i2 = "second", s2 = "minute", u2 = "hour", a2 = "day", o2 = "week", c2 = "month", f2 = "quarter", h2 = "year", d2 = "date", l2 = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y2 = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M2 = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t22) {
|
|
13353
|
+
var e22 = ["th", "st", "nd", "rd"], n22 = t22 % 100;
|
|
13354
|
+
return "[" + t22 + (e22[(n22 - 20) % 10] || e22[n22] || e22[0]) + "]";
|
|
13355
|
+
} }, m2 = function(t22, e22, n22) {
|
|
13356
|
+
var r22 = String(t22);
|
|
13357
|
+
return !r22 || r22.length >= e22 ? t22 : "" + Array(e22 + 1 - r22.length).join(n22) + t22;
|
|
13358
|
+
}, v2 = { s: m2, z: function(t22) {
|
|
13359
|
+
var e22 = -t22.utcOffset(), n22 = Math.abs(e22), r22 = Math.floor(n22 / 60), i22 = n22 % 60;
|
|
13360
|
+
return (e22 <= 0 ? "+" : "-") + m2(r22, 2, "0") + ":" + m2(i22, 2, "0");
|
|
13361
|
+
}, m: function t22(e22, n22) {
|
|
13362
|
+
if (e22.date() < n22.date())
|
|
13363
|
+
return -t22(n22, e22);
|
|
13364
|
+
var r22 = 12 * (n22.year() - e22.year()) + (n22.month() - e22.month()), i22 = e22.clone().add(r22, c2), s22 = n22 - i22 < 0, u22 = e22.clone().add(r22 + (s22 ? -1 : 1), c2);
|
|
13365
|
+
return +(-(r22 + (n22 - i22) / (s22 ? i22 - u22 : u22 - i22)) || 0);
|
|
13366
|
+
}, a: function(t22) {
|
|
13367
|
+
return t22 < 0 ? Math.ceil(t22) || 0 : Math.floor(t22);
|
|
13368
|
+
}, p: function(t22) {
|
|
13369
|
+
return { M: c2, y: h2, w: o2, d: a2, D: d2, h: u2, m: s2, s: i2, ms: r2, Q: f2 }[t22] || String(t22 || "").toLowerCase().replace(/s$/, "");
|
|
13370
|
+
}, u: function(t22) {
|
|
13371
|
+
return void 0 === t22;
|
|
13372
|
+
} }, g2 = "en", D2 = {};
|
|
13373
|
+
D2[g2] = M2;
|
|
13374
|
+
var p2 = "$isDayjsObject", S2 = function(t22) {
|
|
13375
|
+
return t22 instanceof _ || !(!t22 || !t22[p2]);
|
|
13376
|
+
}, w2 = function t22(e22, n22, r22) {
|
|
13377
|
+
var i22;
|
|
13378
|
+
if (!e22)
|
|
13379
|
+
return g2;
|
|
13380
|
+
if ("string" == typeof e22) {
|
|
13381
|
+
var s22 = e22.toLowerCase();
|
|
13382
|
+
D2[s22] && (i22 = s22), n22 && (D2[s22] = n22, i22 = s22);
|
|
13383
|
+
var u22 = e22.split("-");
|
|
13384
|
+
if (!i22 && u22.length > 1)
|
|
13385
|
+
return t22(u22[0]);
|
|
13386
|
+
} else {
|
|
13387
|
+
var a22 = e22.name;
|
|
13388
|
+
D2[a22] = e22, i22 = a22;
|
|
13389
|
+
}
|
|
13390
|
+
return !r22 && i22 && (g2 = i22), i22 || !r22 && g2;
|
|
13391
|
+
}, O2 = function(t22, e22) {
|
|
13392
|
+
if (S2(t22))
|
|
13393
|
+
return t22.clone();
|
|
13394
|
+
var n22 = "object" == typeof e22 ? e22 : {};
|
|
13395
|
+
return n22.date = t22, n22.args = arguments, new _(n22);
|
|
13396
|
+
}, b2 = v2;
|
|
13397
|
+
b2.l = w2, b2.i = S2, b2.w = function(t22, e22) {
|
|
13398
|
+
return O2(t22, { locale: e22.$L, utc: e22.$u, x: e22.$x, $offset: e22.$offset });
|
|
13399
|
+
};
|
|
13400
|
+
var _ = function() {
|
|
13401
|
+
function M22(t22) {
|
|
13402
|
+
this.$L = w2(t22.locale, null, true), this.parse(t22), this.$x = this.$x || t22.x || {}, this[p2] = true;
|
|
13403
|
+
}
|
|
13404
|
+
var m22 = M22.prototype;
|
|
13405
|
+
return m22.parse = function(t22) {
|
|
13406
|
+
this.$d = function(t3) {
|
|
13407
|
+
var e22 = t3.date, n22 = t3.utc;
|
|
13408
|
+
if (null === e22)
|
|
13409
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
13410
|
+
if (b2.u(e22))
|
|
13411
|
+
return /* @__PURE__ */ new Date();
|
|
13412
|
+
if (e22 instanceof Date)
|
|
13413
|
+
return new Date(e22);
|
|
13414
|
+
if ("string" == typeof e22 && !/Z$/i.test(e22)) {
|
|
13415
|
+
var r22 = e22.match($);
|
|
13416
|
+
if (r22) {
|
|
13417
|
+
var i22 = r22[2] - 1 || 0, s22 = (r22[7] || "0").substring(0, 3);
|
|
13418
|
+
return n22 ? new Date(Date.UTC(r22[1], i22, r22[3] || 1, r22[4] || 0, r22[5] || 0, r22[6] || 0, s22)) : new Date(r22[1], i22, r22[3] || 1, r22[4] || 0, r22[5] || 0, r22[6] || 0, s22);
|
|
13419
|
+
}
|
|
13421
13420
|
}
|
|
13421
|
+
return new Date(e22);
|
|
13422
|
+
}(t22), this.init();
|
|
13423
|
+
}, m22.init = function() {
|
|
13424
|
+
var t22 = this.$d;
|
|
13425
|
+
this.$y = t22.getFullYear(), this.$M = t22.getMonth(), this.$D = t22.getDate(), this.$W = t22.getDay(), this.$H = t22.getHours(), this.$m = t22.getMinutes(), this.$s = t22.getSeconds(), this.$ms = t22.getMilliseconds();
|
|
13426
|
+
}, m22.$utils = function() {
|
|
13427
|
+
return b2;
|
|
13428
|
+
}, m22.isValid = function() {
|
|
13429
|
+
return !(this.$d.toString() === l2);
|
|
13430
|
+
}, m22.isSame = function(t22, e22) {
|
|
13431
|
+
var n22 = O2(t22);
|
|
13432
|
+
return this.startOf(e22) <= n22 && n22 <= this.endOf(e22);
|
|
13433
|
+
}, m22.isAfter = function(t22, e22) {
|
|
13434
|
+
return O2(t22) < this.startOf(e22);
|
|
13435
|
+
}, m22.isBefore = function(t22, e22) {
|
|
13436
|
+
return this.endOf(e22) < O2(t22);
|
|
13437
|
+
}, m22.$g = function(t22, e22, n22) {
|
|
13438
|
+
return b2.u(t22) ? this[e22] : this.set(n22, t22);
|
|
13439
|
+
}, m22.unix = function() {
|
|
13440
|
+
return Math.floor(this.valueOf() / 1e3);
|
|
13441
|
+
}, m22.valueOf = function() {
|
|
13442
|
+
return this.$d.getTime();
|
|
13443
|
+
}, m22.startOf = function(t22, e22) {
|
|
13444
|
+
var n22 = this, r22 = !!b2.u(e22) || e22, f22 = b2.p(t22), l22 = function(t3, e3) {
|
|
13445
|
+
var i22 = b2.w(n22.$u ? Date.UTC(n22.$y, e3, t3) : new Date(n22.$y, e3, t3), n22);
|
|
13446
|
+
return r22 ? i22 : i22.endOf(a2);
|
|
13447
|
+
}, $2 = function(t3, e3) {
|
|
13448
|
+
return b2.w(n22.toDate()[t3].apply(n22.toDate("s"), (r22 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n22);
|
|
13449
|
+
}, y22 = this.$W, M3 = this.$M, m3 = this.$D, v22 = "set" + (this.$u ? "UTC" : "");
|
|
13450
|
+
switch (f22) {
|
|
13451
|
+
case h2:
|
|
13452
|
+
return r22 ? l22(1, 0) : l22(31, 11);
|
|
13453
|
+
case c2:
|
|
13454
|
+
return r22 ? l22(1, M3) : l22(0, M3 + 1);
|
|
13455
|
+
case o2:
|
|
13456
|
+
var g22 = this.$locale().weekStart || 0, D22 = (y22 < g22 ? y22 + 7 : y22) - g22;
|
|
13457
|
+
return l22(r22 ? m3 - D22 : m3 + (6 - D22), M3);
|
|
13458
|
+
case a2:
|
|
13459
|
+
case d2:
|
|
13460
|
+
return $2(v22 + "Hours", 0);
|
|
13461
|
+
case u2:
|
|
13462
|
+
return $2(v22 + "Minutes", 1);
|
|
13463
|
+
case s2:
|
|
13464
|
+
return $2(v22 + "Seconds", 2);
|
|
13465
|
+
case i2:
|
|
13466
|
+
return $2(v22 + "Milliseconds", 3);
|
|
13467
|
+
default:
|
|
13468
|
+
return this.clone();
|
|
13422
13469
|
}
|
|
13423
|
-
}
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
}
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13470
|
+
}, m22.endOf = function(t22) {
|
|
13471
|
+
return this.startOf(t22, false);
|
|
13472
|
+
}, m22.$set = function(t22, e22) {
|
|
13473
|
+
var n22, o22 = b2.p(t22), f22 = "set" + (this.$u ? "UTC" : ""), l22 = (n22 = {}, n22[a2] = f22 + "Date", n22[d2] = f22 + "Date", n22[c2] = f22 + "Month", n22[h2] = f22 + "FullYear", n22[u2] = f22 + "Hours", n22[s2] = f22 + "Minutes", n22[i2] = f22 + "Seconds", n22[r2] = f22 + "Milliseconds", n22)[o22], $2 = o22 === a2 ? this.$D + (e22 - this.$W) : e22;
|
|
13474
|
+
if (o22 === c2 || o22 === h2) {
|
|
13475
|
+
var y22 = this.clone().set(d2, 1);
|
|
13476
|
+
y22.$d[l22]($2), y22.init(), this.$d = y22.set(d2, Math.min(this.$D, y22.daysInMonth())).$d;
|
|
13477
|
+
} else
|
|
13478
|
+
l22 && this.$d[l22]($2);
|
|
13479
|
+
return this.init(), this;
|
|
13480
|
+
}, m22.set = function(t22, e22) {
|
|
13481
|
+
return this.clone().$set(t22, e22);
|
|
13482
|
+
}, m22.get = function(t22) {
|
|
13483
|
+
return this[b2.p(t22)]();
|
|
13484
|
+
}, m22.add = function(r22, f22) {
|
|
13485
|
+
var d22, l22 = this;
|
|
13486
|
+
r22 = Number(r22);
|
|
13487
|
+
var $2 = b2.p(f22), y22 = function(t22) {
|
|
13488
|
+
var e22 = O2(l22);
|
|
13489
|
+
return b2.w(e22.date(e22.date() + Math.round(t22 * r22)), l22);
|
|
13490
|
+
};
|
|
13491
|
+
if ($2 === c2)
|
|
13492
|
+
return this.set(c2, this.$M + r22);
|
|
13493
|
+
if ($2 === h2)
|
|
13494
|
+
return this.set(h2, this.$y + r22);
|
|
13495
|
+
if ($2 === a2)
|
|
13496
|
+
return y22(1);
|
|
13497
|
+
if ($2 === o2)
|
|
13498
|
+
return y22(7);
|
|
13499
|
+
var M3 = (d22 = {}, d22[s2] = e2, d22[u2] = n2, d22[i2] = t2, d22)[$2] || 1, m3 = this.$d.getTime() + r22 * M3;
|
|
13500
|
+
return b2.w(m3, this);
|
|
13501
|
+
}, m22.subtract = function(t22, e22) {
|
|
13502
|
+
return this.add(-1 * t22, e22);
|
|
13503
|
+
}, m22.format = function(t22) {
|
|
13504
|
+
var e22 = this, n22 = this.$locale();
|
|
13505
|
+
if (!this.isValid())
|
|
13506
|
+
return n22.invalidDate || l2;
|
|
13507
|
+
var r22 = t22 || "YYYY-MM-DDTHH:mm:ssZ", i22 = b2.z(this), s22 = this.$H, u22 = this.$m, a22 = this.$M, o22 = n22.weekdays, c22 = n22.months, f22 = n22.meridiem, h22 = function(t3, n3, i3, s3) {
|
|
13508
|
+
return t3 && (t3[n3] || t3(e22, r22)) || i3[n3].slice(0, s3);
|
|
13509
|
+
}, d22 = function(t3) {
|
|
13510
|
+
return b2.s(s22 % 12 || 12, t3, "0");
|
|
13511
|
+
}, $2 = f22 || function(t3, e3, n3) {
|
|
13512
|
+
var r3 = t3 < 12 ? "AM" : "PM";
|
|
13513
|
+
return n3 ? r3.toLowerCase() : r3;
|
|
13514
|
+
};
|
|
13515
|
+
return r22.replace(y2, function(t3, r3) {
|
|
13516
|
+
return r3 || function(t4) {
|
|
13517
|
+
switch (t4) {
|
|
13518
|
+
case "YY":
|
|
13519
|
+
return String(e22.$y).slice(-2);
|
|
13520
|
+
case "YYYY":
|
|
13521
|
+
return b2.s(e22.$y, 4, "0");
|
|
13522
|
+
case "M":
|
|
13523
|
+
return a22 + 1;
|
|
13524
|
+
case "MM":
|
|
13525
|
+
return b2.s(a22 + 1, 2, "0");
|
|
13526
|
+
case "MMM":
|
|
13527
|
+
return h22(n22.monthsShort, a22, c22, 3);
|
|
13528
|
+
case "MMMM":
|
|
13529
|
+
return h22(c22, a22);
|
|
13530
|
+
case "D":
|
|
13531
|
+
return e22.$D;
|
|
13532
|
+
case "DD":
|
|
13533
|
+
return b2.s(e22.$D, 2, "0");
|
|
13534
|
+
case "d":
|
|
13535
|
+
return String(e22.$W);
|
|
13536
|
+
case "dd":
|
|
13537
|
+
return h22(n22.weekdaysMin, e22.$W, o22, 2);
|
|
13538
|
+
case "ddd":
|
|
13539
|
+
return h22(n22.weekdaysShort, e22.$W, o22, 3);
|
|
13540
|
+
case "dddd":
|
|
13541
|
+
return o22[e22.$W];
|
|
13542
|
+
case "H":
|
|
13543
|
+
return String(s22);
|
|
13544
|
+
case "HH":
|
|
13545
|
+
return b2.s(s22, 2, "0");
|
|
13546
|
+
case "h":
|
|
13547
|
+
return d22(1);
|
|
13548
|
+
case "hh":
|
|
13549
|
+
return d22(2);
|
|
13550
|
+
case "a":
|
|
13551
|
+
return $2(s22, u22, true);
|
|
13552
|
+
case "A":
|
|
13553
|
+
return $2(s22, u22, false);
|
|
13554
|
+
case "m":
|
|
13555
|
+
return String(u22);
|
|
13556
|
+
case "mm":
|
|
13557
|
+
return b2.s(u22, 2, "0");
|
|
13558
|
+
case "s":
|
|
13559
|
+
return String(e22.$s);
|
|
13560
|
+
case "ss":
|
|
13561
|
+
return b2.s(e22.$s, 2, "0");
|
|
13562
|
+
case "SSS":
|
|
13563
|
+
return b2.s(e22.$ms, 3, "0");
|
|
13564
|
+
case "Z":
|
|
13565
|
+
return i22;
|
|
13566
|
+
}
|
|
13567
|
+
return null;
|
|
13568
|
+
}(t3) || i22.replace(":", "");
|
|
13569
|
+
});
|
|
13570
|
+
}, m22.utcOffset = function() {
|
|
13571
|
+
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
13572
|
+
}, m22.diff = function(r22, d22, l22) {
|
|
13573
|
+
var $2, y22 = this, M3 = b2.p(d22), m3 = O2(r22), v22 = (m3.utcOffset() - this.utcOffset()) * e2, g22 = this - m3, D22 = function() {
|
|
13574
|
+
return b2.m(y22, m3);
|
|
13575
|
+
};
|
|
13576
|
+
switch (M3) {
|
|
13577
|
+
case h2:
|
|
13578
|
+
$2 = D22() / 12;
|
|
13579
|
+
break;
|
|
13580
|
+
case c2:
|
|
13581
|
+
$2 = D22();
|
|
13582
|
+
break;
|
|
13583
|
+
case f2:
|
|
13584
|
+
$2 = D22() / 3;
|
|
13585
|
+
break;
|
|
13586
|
+
case o2:
|
|
13587
|
+
$2 = (g22 - v22) / 6048e5;
|
|
13588
|
+
break;
|
|
13589
|
+
case a2:
|
|
13590
|
+
$2 = (g22 - v22) / 864e5;
|
|
13591
|
+
break;
|
|
13592
|
+
case u2:
|
|
13593
|
+
$2 = g22 / n2;
|
|
13594
|
+
break;
|
|
13595
|
+
case s2:
|
|
13596
|
+
$2 = g22 / e2;
|
|
13597
|
+
break;
|
|
13598
|
+
case i2:
|
|
13599
|
+
$2 = g22 / t2;
|
|
13600
|
+
break;
|
|
13601
|
+
default:
|
|
13602
|
+
$2 = g22;
|
|
13603
|
+
}
|
|
13604
|
+
return l22 ? $2 : b2.a($2);
|
|
13605
|
+
}, m22.daysInMonth = function() {
|
|
13606
|
+
return this.endOf(c2).$D;
|
|
13607
|
+
}, m22.$locale = function() {
|
|
13608
|
+
return D2[this.$L];
|
|
13609
|
+
}, m22.locale = function(t22, e22) {
|
|
13610
|
+
if (!t22)
|
|
13611
|
+
return this.$L;
|
|
13612
|
+
var n22 = this.clone(), r22 = w2(t22, e22, true);
|
|
13613
|
+
return r22 && (n22.$L = r22), n22;
|
|
13614
|
+
}, m22.clone = function() {
|
|
13615
|
+
return b2.w(this.$d, this);
|
|
13616
|
+
}, m22.toDate = function() {
|
|
13617
|
+
return new Date(this.valueOf());
|
|
13618
|
+
}, m22.toJSON = function() {
|
|
13619
|
+
return this.isValid() ? this.toISOString() : null;
|
|
13620
|
+
}, m22.toISOString = function() {
|
|
13621
|
+
return this.$d.toISOString();
|
|
13622
|
+
}, m22.toString = function() {
|
|
13623
|
+
return this.$d.toUTCString();
|
|
13624
|
+
}, M22;
|
|
13625
|
+
}(), k2 = _.prototype;
|
|
13626
|
+
return O2.prototype = k2, [["$ms", r2], ["$s", i2], ["$m", s2], ["$H", u2], ["$W", a2], ["$M", c2], ["$y", h2], ["$D", d2]].forEach(function(t22) {
|
|
13627
|
+
k2[t22[1]] = function(e22) {
|
|
13628
|
+
return this.$g(e22, t22[0], t22[1]);
|
|
13629
|
+
};
|
|
13630
|
+
}), O2.extend = function(t22, e22) {
|
|
13631
|
+
return t22.$i || (t22(e22, _, O2), t22.$i = true), O2;
|
|
13632
|
+
}, O2.locale = w2, O2.isDayjs = S2, O2.unix = function(t22) {
|
|
13633
|
+
return O2(1e3 * t22);
|
|
13634
|
+
}, O2.en = D2[g2], O2.Ls = D2, O2.p = {}, O2;
|
|
13635
|
+
});
|
|
13442
13636
|
}
|
|
13443
|
-
|
|
13637
|
+
});
|
|
13638
|
+
var require_zh_cn = __commonJS({
|
|
13639
|
+
"../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/locale/zh-cn.js"(exports3, module2) {
|
|
13640
|
+
!function(e2, _) {
|
|
13641
|
+
"object" == typeof exports3 && "undefined" != typeof module2 ? module2.exports = _(require_dayjs_min()) : "function" == typeof define && define.amd ? define(["dayjs"], _) : (e2 = "undefined" != typeof globalThis ? globalThis : e2 || self).dayjs_locale_zh_cn = _(e2.dayjs);
|
|
13642
|
+
}(exports3, function(e2) {
|
|
13643
|
+
function _(e22) {
|
|
13644
|
+
return e22 && "object" == typeof e22 && "default" in e22 ? e22 : { default: e22 };
|
|
13645
|
+
}
|
|
13646
|
+
var t2 = _(e2), d2 = { name: "zh-cn", weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"), weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"), weekdaysMin: "日_一_二_三_四_五_六".split("_"), months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"), monthsShort: "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"), ordinal: function(e22, _2) {
|
|
13647
|
+
return "W" === _2 ? e22 + "周" : e22 + "日";
|
|
13648
|
+
}, weekStart: 1, yearStart: 4, formats: { LT: "HH:mm", LTS: "HH:mm:ss", L: "YYYY/MM/DD", LL: "YYYY年M月D日", LLL: "YYYY年M月D日Ah点mm分", LLLL: "YYYY年M月D日ddddAh点mm分", l: "YYYY/M/D", ll: "YYYY年M月D日", lll: "YYYY年M月D日 HH:mm", llll: "YYYY年M月D日dddd HH:mm" }, relativeTime: { future: "%s内", past: "%s前", s: "几秒", m: "1 分钟", mm: "%d 分钟", h: "1 小时", hh: "%d 小时", d: "1 天", dd: "%d 天", M: "1 个月", MM: "%d 个月", y: "1 年", yy: "%d 年" }, meridiem: function(e22, _2) {
|
|
13649
|
+
var t22 = 100 * e22 + _2;
|
|
13650
|
+
return t22 < 600 ? "凌晨" : t22 < 900 ? "早上" : t22 < 1100 ? "上午" : t22 < 1300 ? "中午" : t22 < 1800 ? "下午" : "晚上";
|
|
13651
|
+
} };
|
|
13652
|
+
return t2.default.locale(d2, null, true), d2;
|
|
13653
|
+
});
|
|
13654
|
+
}
|
|
13655
|
+
});
|
|
13656
|
+
function checkDataType(tgt, type) {
|
|
13657
|
+
const dataType = Object.prototype.toString.call(tgt).replace(/\[object (\w+)\]/, "$1").toLowerCase();
|
|
13658
|
+
return type ? dataType === type : dataType;
|
|
13444
13659
|
}
|
|
13445
|
-
function
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
}
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
scale = sideLengthLimit / scaleBaseFunc(imageWidth, imageHeight);
|
|
13461
|
-
} else if (img.width > 0 && img.height > 0) {
|
|
13462
|
-
scale = sideLengthLimit / scaleBaseFunc(img.width, img.height);
|
|
13463
|
-
imageWidth = img.width;
|
|
13464
|
-
imageHeight = img.height;
|
|
13660
|
+
function checkIsUndefined(tgt) {
|
|
13661
|
+
return checkDataType(tgt, "undefined");
|
|
13662
|
+
}
|
|
13663
|
+
function checkIsNull(tgt) {
|
|
13664
|
+
return checkDataType(tgt, "null");
|
|
13665
|
+
}
|
|
13666
|
+
function checkIsUndefinedOrNull(tgt) {
|
|
13667
|
+
return checkIsUndefined(tgt) || checkIsNull(tgt);
|
|
13668
|
+
}
|
|
13669
|
+
function checkIsString(tgt) {
|
|
13670
|
+
return checkDataType(tgt, "string");
|
|
13671
|
+
}
|
|
13672
|
+
function checkIsStringValid(tgt) {
|
|
13673
|
+
if (checkDataType(tgt, "string")) {
|
|
13674
|
+
return tgt !== "";
|
|
13465
13675
|
} else {
|
|
13466
|
-
return
|
|
13467
|
-
}
|
|
13468
|
-
const targetWidth = scale > 1 ? imageWidth : imageWidth * scale;
|
|
13469
|
-
const targetHeight = scale > 1 ? imageHeight : imageHeight * scale;
|
|
13470
|
-
if (resultType === "image") {
|
|
13471
|
-
return image2Canvas(
|
|
13472
|
-
img,
|
|
13473
|
-
inputType,
|
|
13474
|
-
orientation,
|
|
13475
|
-
targetWidth,
|
|
13476
|
-
targetHeight
|
|
13477
|
-
).then((canvas) => canvas2Image(canvas));
|
|
13478
|
-
}
|
|
13479
|
-
return image2Canvas(img, inputType, orientation, targetWidth, targetHeight);
|
|
13480
|
-
}
|
|
13481
|
-
var __defProp$3 = Object.defineProperty;
|
|
13482
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13483
|
-
var __publicField$3 = (obj, key, value) => {
|
|
13484
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
13485
|
-
return value;
|
|
13486
|
-
};
|
|
13487
|
-
class ResizeOptions {
|
|
13488
|
-
// 最大边长
|
|
13489
|
-
constructor(maxSideLength) {
|
|
13490
|
-
__publicField$3(this, "maxSideLength");
|
|
13491
|
-
if (!isDef(maxSideLength)) {
|
|
13492
|
-
this.maxSideLength = MAX_SIDE_LENGTH;
|
|
13493
|
-
} else {
|
|
13494
|
-
this.maxSideLength = maxSideLength;
|
|
13495
|
-
if (this.maxSideLength > MAX_SIDE_LENGTH) {
|
|
13496
|
-
this.maxSideLength = MAX_SIDE_LENGTH;
|
|
13497
|
-
} else if (this.maxSideLength < MIN_SIDE_LENGTH) {
|
|
13498
|
-
this.maxSideLength = MIN_SIDE_LENGTH;
|
|
13499
|
-
}
|
|
13500
|
-
}
|
|
13676
|
+
return false;
|
|
13501
13677
|
}
|
|
13502
13678
|
}
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
constructor(photoFileSizeLimit) {
|
|
13511
|
-
__publicField$2(this, "photoFileSizeLimit");
|
|
13512
|
-
__publicField$2(this, "checkOrientation", true);
|
|
13513
|
-
if (!isDef(photoFileSizeLimit)) {
|
|
13514
|
-
this.photoFileSizeLimit = PHOTO_FILE_SIZE_LIMIT;
|
|
13515
|
-
} else {
|
|
13516
|
-
this.photoFileSizeLimit = photoFileSizeLimit;
|
|
13517
|
-
}
|
|
13679
|
+
function checkIsRegExp(tgt) {
|
|
13680
|
+
return checkDataType(tgt, "regexp");
|
|
13681
|
+
}
|
|
13682
|
+
function parseInteger(obj, defaultValue) {
|
|
13683
|
+
let result = parseInt(obj, 10);
|
|
13684
|
+
if (isNaN(result)) {
|
|
13685
|
+
result = defaultValue || 0;
|
|
13518
13686
|
}
|
|
13687
|
+
return result;
|
|
13519
13688
|
}
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13689
|
+
function parseDecimal(obj, defaultValue) {
|
|
13690
|
+
let result = parseFloat(obj);
|
|
13691
|
+
if (isNaN(result)) {
|
|
13692
|
+
result = defaultValue || 0;
|
|
13523
13693
|
}
|
|
13524
|
-
return
|
|
13525
|
-
}
|
|
13526
|
-
var
|
|
13527
|
-
|
|
13694
|
+
return result;
|
|
13695
|
+
}
|
|
13696
|
+
var FORMAT = {
|
|
13697
|
+
//英文简写如:12:01
|
|
13528
13698
|
FORMAT_HM: "HH:mm",
|
|
13529
|
-
|
|
13699
|
+
//英文简写如:1-12 12:01
|
|
13530
13700
|
FORMAT_MDHM: "MM-dd HH:mm",
|
|
13531
|
-
|
|
13701
|
+
//中文简写如:1月12日
|
|
13532
13702
|
FORMAT_MD_CN: "MM月dd日",
|
|
13533
|
-
|
|
13703
|
+
//中文简写如:1月12日
|
|
13534
13704
|
FORMAT_MD: "MM-dd",
|
|
13535
|
-
|
|
13705
|
+
//英文简写(默认)如:2010-12-01
|
|
13536
13706
|
FORMAT_YMD: "yyyy-MM-dd",
|
|
13537
13707
|
FORMAT_YMD_SLASH: "yyyy/MM/dd",
|
|
13538
|
-
|
|
13708
|
+
//英文简写(默认)如:2010-12
|
|
13539
13709
|
FORMAT_YM: "yyyy-MM",
|
|
13540
|
-
|
|
13710
|
+
//英文全称 如:2010-12-01 23:15
|
|
13541
13711
|
FORMAT_YMDHM: "yyyy-MM-dd HH:mm",
|
|
13542
|
-
|
|
13712
|
+
//英文全称 如:2010-12-01 23:15:06
|
|
13543
13713
|
FORMAT_YMDHMS: "yyyy-MM-dd HH:mm:ss",
|
|
13544
|
-
|
|
13714
|
+
//英文全称 如:2010-12-01 23:15:06
|
|
13545
13715
|
FORMAT_YMDHMSMS: "yyyy-MM-dd HH:mm:ss msms",
|
|
13546
|
-
|
|
13716
|
+
//中文简写 如:2010年12月
|
|
13547
13717
|
FORMAT_YM_CN: "yyyy年MM月",
|
|
13548
|
-
|
|
13718
|
+
//中文简写 如:2010年12月01日
|
|
13549
13719
|
FORMAT_YMD_CN: "yyyy年MM月dd日",
|
|
13550
|
-
|
|
13720
|
+
//中文简写 如:2010年12月01日 12时
|
|
13551
13721
|
FORMAT_YMDH_CN: "yyyy年MM月dd日 HH时",
|
|
13552
|
-
|
|
13722
|
+
//中文简写 如:12月01日 12时
|
|
13553
13723
|
FORMAT_MDH_CN: "MM月dd日 HH时",
|
|
13554
|
-
|
|
13724
|
+
//中文简写 如:2010年12月01日 12时12分
|
|
13555
13725
|
FORMAT_YMDHM_CN: "yyyy年MM月dd日 HH时mm分",
|
|
13556
|
-
|
|
13726
|
+
//中文全称 如:2010年12月01日 23时15分06秒
|
|
13557
13727
|
FORMAT_YMDHMS_CN: "yyyy年MM月dd日 HH时mm分ss秒"
|
|
13558
13728
|
};
|
|
13559
|
-
function
|
|
13560
|
-
|
|
13561
|
-
return new Date(dateObj);
|
|
13562
|
-
}
|
|
13563
|
-
if (typeof dateObj === "string") {
|
|
13564
|
-
dateObj = dateObj.replace(/-/g, "/");
|
|
13565
|
-
if (dateObj.length === 7) {
|
|
13566
|
-
dateObj += "/01";
|
|
13567
|
-
}
|
|
13568
|
-
return new Date(dateObj);
|
|
13569
|
-
}
|
|
13570
|
-
return dateObj;
|
|
13729
|
+
function checkIsAndroid() {
|
|
13730
|
+
return /android/.test(navigator.userAgent.toLowerCase());
|
|
13571
13731
|
}
|
|
13572
|
-
function
|
|
13573
|
-
|
|
13574
|
-
let formatResult = formatType.replace(
|
|
13575
|
-
"yyyy",
|
|
13576
|
-
__formatNumber__(date.getFullYear())
|
|
13577
|
-
);
|
|
13578
|
-
formatResult = formatResult.replace(
|
|
13579
|
-
"yy",
|
|
13580
|
-
String(date.getFullYear()).substring(2)
|
|
13581
|
-
);
|
|
13582
|
-
formatResult = formatResult.replace(
|
|
13583
|
-
"MM",
|
|
13584
|
-
__formatNumber__(date.getMonth() + 1)
|
|
13585
|
-
);
|
|
13586
|
-
formatResult = formatResult.replace("dd", __formatNumber__(date.getDate()));
|
|
13587
|
-
formatResult = formatResult.replace("HH", __formatNumber__(date.getHours()));
|
|
13588
|
-
formatResult = formatResult.replace(
|
|
13589
|
-
"mm",
|
|
13590
|
-
__formatNumber__(date.getMinutes())
|
|
13591
|
-
);
|
|
13592
|
-
formatResult = formatResult.replace(
|
|
13593
|
-
"ss",
|
|
13594
|
-
__formatNumber__(date.getSeconds())
|
|
13595
|
-
);
|
|
13596
|
-
formatResult = formatResult.replace(
|
|
13597
|
-
"msms",
|
|
13598
|
-
__formatNumber__(date.getMilliseconds())
|
|
13599
|
-
);
|
|
13600
|
-
return formatResult;
|
|
13732
|
+
function checkIsIOS() {
|
|
13733
|
+
return /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase());
|
|
13601
13734
|
}
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13735
|
+
function checkIsWindows() {
|
|
13736
|
+
return navigator.platform.indexOf("Win") > -1;
|
|
13737
|
+
}
|
|
13738
|
+
var import_dayjs = __toESM(require_dayjs_min());
|
|
13739
|
+
__toESM(require_zh_cn());
|
|
13740
|
+
import_dayjs.default.locale("zh-cn");
|
|
13741
|
+
var Point = class {
|
|
13742
|
+
constructor(x2, y2) {
|
|
13743
|
+
this.x = x2;
|
|
13744
|
+
this.y = y2;
|
|
13745
|
+
}
|
|
13746
|
+
};
|
|
13747
|
+
var Size = class {
|
|
13748
|
+
constructor(width2, height2) {
|
|
13749
|
+
this.width = width2;
|
|
13750
|
+
this.height = height2;
|
|
13751
|
+
}
|
|
13607
13752
|
};
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
if (
|
|
13753
|
+
var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
13754
|
+
var subString = (str, startIndex, length) => {
|
|
13755
|
+
if (checkIsUndefinedOrNull(length)) {
|
|
13611
13756
|
return str.substring(startIndex);
|
|
13757
|
+
} else {
|
|
13758
|
+
return str.substring(startIndex, startIndex + length);
|
|
13612
13759
|
}
|
|
13613
|
-
return str.substring(startIndex, startIndex + length);
|
|
13614
13760
|
};
|
|
13615
|
-
|
|
13761
|
+
var DEFAULT_ADDRESS_ICON = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAACjpJREFUeF7tnQGO2zgMRe2TtT1Z25Nte7IsFNitG9iJKUvWJ/kGKHYwKznRp54+KTnOPPGDAihwqMCMNiiAAscKAAizAwXeKAAgTA8UABDmAArUKYCD1OlGryQKAEiSQDPMOgUApE43eiVRAECSBJph1ikAIHW60SuJAgCSJNAMs04BAKnTjV5JFACQJIFmmHUKAEidbvRKogCAJAk0w6xTAEDqdKNXEgUAJEmgGWadAgBSpxu9kigAIEkCzTDrFACQOt3olUQBAEkSaIZZpwCA1OlGryQKAEiSQDPMOgUApE43eiVRAECSBJph1ikAIHW6mXs9Ho+v0zSVf+vPl83v27+vf/618yK/p2l6/n2e573/b35fdHivAIB0mCEbGAoEe5O/1auukDzBAZpWsv69DoA00vTxePxYLvW90SVrL1Og+YnL1Mr3bz8AuaDjAsVoIN6N4AkLzlIfZAAxaifkFMZ3/qxdgMWoGoCcFMyBW5wcybNZAWVNCS390rUFkA8hDwbG62gB5UP8AeRAoOBgAMpJLwSQF6GSgfE6Tb5R0LOLdbh2JIdj1YVifjNDcJBpmgBjd82gPil3LJxMxcI2ezwe/3U+7fasXXo3SQsIrmHiNm1tkhIQ4DDBsTZOmXKlAwQ4quD4U8DP8/zt0hWcdU4FCPVGk9lZ7hpOA0kKQJbbz0sxzk8bBdIU7+EBAY42RBxcJXzxHhoQ4OgKx3rx0JCEBQQ4boEjPCSRAeEA8EZG5nkOOZdCDordqhvJ+PtSIXe3wgECHEPgCHuYGAoQDgGHwhESkjCAUJRLwBEOkhCAAIcUHM83E6VojwIIO1Z6jIQo2t0DQt2hR8bmHbm/A9g1IKRW0nCEqEe8A0Jqpc+I61TLLSCkVvpkREi1PAPycDVF3r/Z7VPaP30tgsthe93VcgmIc/d4Pnnd8nUFS61V+pQHZff8OoWe8Lks2N0B4rQwL1A0+/6ORYP1qfJugPHoIh4B8VKYr9/R0fUh0RtYPIDizkVcAeLIPW6fCF5A8eYi3gBRd4/bwXgtGhzUZ8M1shRa3gBR3bmS2+tXvu3fk4u4AUR4ZZRdEdHM4hX7bT0BougesnCs4VaFxIuLuABEtDiXh0McEhf6eQFErTh3Edxt0iDoJC409AKIUnrlIrB7GbUaJB7SLHlAxNIrud0qaxkqBon8YuMBEJX0yj0cm5pERVMAsa5wOwdfKulVmEdsKrmyepol7SBCgZRf6awLkVCqJb3wqANSbvRb71q1zoFm7dVXudqBPh4PBXeWXnzUAVHIlaUDWAtH6SfiItK1nTogw1e4qO6xKdjR+M0qIwuISP0hnR9fcQ+xU3ZZnQHk3eoR9JH+gjuFsmmsMiCjC3Tp3LiFewi5CIBYAyrweQZZ27dq+am9QLEuuxgpO8joHaw0gCw7WiOLdQD5tIqJ5cWyAbPqeLb9aMdW3S2UdBCBHSzZnPjshLe2G51mAYghYgKApEqvlhSrPDaopLWjfiQ1x0H2p4NksHrOXBalfXUBBED+KDD43izJRQlAdgBRzYd7OojATpZk3acKyNBDQgDpjeLu9QHkrOyDd1TSbfFuTtRHnj0BCICcVWBMu8FnIQByNuyDHSTMVxif1RsHOVaKGoQiXWUXCwc5u6KN3pOnSD8bqabt2OY9K+doQKZpkgzWWf1q2qE5B4WWeQMgFrXatJXUXLUGGX1fkGQ+3GYe7l8FB3HkIJzq9kThEJCRZyCyO4eSDiIAiGzAeqEz+D4sWb2VARm6ok3TlCbNEkivZO9eUAZk6P1YyQAZvRgBiDU1GH2aXt5vlvOQ0emV8mKEg7wnN3yaJZBelQhIbvE+F0nryn5ne1a2/moPvkHxOUBlp1YHZHRuXOIX1kVE3EO2/vDgIKMLdfkV7orHKLjHNE0AUhtEhUJ9ee/hXETEPaTrD3kHUTgwXOFWzpNrFiAR9wCQmuBt+wgFMoyLCDmzdHrlxUEk6pAoqZYQHPLu4QIQpTTLOyRCdceaJMief/xJra+mQHf0F0qz3AT2NS6CcMinV54cRCnNKrq5CK5oLedqkZE+KHwJ8MjvrzgySvkUQdA5AKRH2iVWXG6HKLu7JayZGwf25CBqaZY0JMJwuNi9clWkr29WPOi/lvu2yn+H/qjrNM/zt6ECGV7cjYMs273KLrLKPizlEgfDVe3h0kEEz0TerUW3geIEDJe7f64cxJGLrOCs6VaBpWnqtexOlccjfTdkDKObyu/6vQrkDpAFEoXPiVgn22VYFqcor+sJij+Lhafaw22K5dBFjkDaOsrvcvi4aVicYf35svyy/ZsVToX27tyjiObSQQJBojBx73gPbs49QqRY6yAEPrN+x+SK8Bou3cO1g+Aibri5bTevhyJuU6yNi3gs2HvEUvGablMr10X6diYI34ynOGHvfk9uU6swgJBq3T3nT7+e69QqFCBAcnrS3tXQfWoVDpAFEsXPjNw1KVVeJwwc7nexXmcE9YgEI+7rjq2K7nexdiDxcMevxEzu8CZCwRHOQTZbv0DSYfZ/uGSIovx1jOEcBEjuJyPyA77DAsLO1m2ghHSOkLtYe1PC0YeJbpvRDV8oNBxhaxAK94YIHF8qPBxpACHdag5MCjhSAQIkzSBJA0c6QIDkMiSp4EgJCJBUQ5IOjrSAAIkZkpRwpAYESE5DkhaO9IAAyUdIUsMBIMv84DBxF5T0cADIZl4AyT+QAMciR+h7sT4mEC8NBL/qzTqEFu1DfeDpqiAAAiRbBYDjZT4AyM4Sk9RJgGNnLgDIgQcngwQ4DuYBgLxJUpNAAhxv5gCAfKjigkMCHB/iDyAntjmCQgIcJ2IPICdEWk7cIz0DGDhOxh1ATgoVCBLgMMQcQAxiBYAEOIzxBhCjYI4hAY6KWANIhWgOIQGOyjgDSKVwjiABjgsxBpAL4jmABDguxhdALgooDAlwNIgtgDQQURAS4GgUVwBpJKQQJMDRMKYA0lBMAUiAo3E8AaSxoAMhAY4OsQSQDqIOgAQ4OsURQDoJeyMkwNExhgDSUdwbIAGOzvEDkM4Cd/7m3XBfmtk5HObLA4hZMnuHTpAAhz0U5h4AYpasrkNjSICjLgzmXgBilqy+QyNIgKM+BOaeAGKW7FqHi5AAxzX5zb0BxCzZ9Q6VkADHdenNVwAQs2RtOhghAY42spuvAiBmydp1WCD5Pk3T14Or8pT1dnJXXQlAqmRr22kDSrlwgeVn+WWe5x9tX4mrWRUAEKtitE+lAICkCjeDtSoAIFbFaJ9KAQBJFW4Ga1UAQKyK0T6VAgCSKtwM1qoAgFgVo30qBQAkVbgZrFUBALEqRvtUCgBIqnAzWKsCAGJVjPapFACQVOFmsFYFAMSqGO1TKQAgqcLNYK0KAIhVMdqnUgBAUoWbwVoVABCrYrRPpQCApAo3g7UqACBWxWifSgEASRVuBmtVAECsitE+lQIAkircDNaqAIBYFaN9KgUAJFW4GaxVAQCxKkb7VAr8D3T7HgXIMUYQAAAAAElFTkSuQmCC";
|
|
13762
|
+
var ColorMap = {
|
|
13616
13763
|
transparent: "#00000000",
|
|
13617
13764
|
white: "#FFFFFF",
|
|
13618
13765
|
black: "#000000",
|
|
@@ -13647,21 +13794,83 @@
|
|
|
13647
13794
|
}
|
|
13648
13795
|
return null;
|
|
13649
13796
|
}
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13797
|
+
var CONTENT_PADDING = 10;
|
|
13798
|
+
var DEFAULT_PADDING = 2;
|
|
13799
|
+
var DEFAULT_FONT_SIZE = 25;
|
|
13800
|
+
var DEFAULT_CANVAS_SIZE = 480;
|
|
13801
|
+
var DEFAULT_BACKGROUND_OPACITY = 128;
|
|
13802
|
+
var LOGO_DEFAULT_PADDING = 4;
|
|
13803
|
+
var WatermarkStyle = class {
|
|
13804
|
+
//是否是简化配置
|
|
13805
|
+
/**
|
|
13806
|
+
* Watermark Style
|
|
13807
|
+
* @param fontName
|
|
13808
|
+
* @param fontWeight
|
|
13809
|
+
* @param fontColor
|
|
13810
|
+
* @param fontSize
|
|
13811
|
+
* @param backgroundColor
|
|
13812
|
+
* @param backgroundOpacity
|
|
13813
|
+
* @param paddingTop
|
|
13814
|
+
* @param paddingBottom
|
|
13815
|
+
* @param position
|
|
13816
|
+
* @param scale
|
|
13817
|
+
* @param simplified
|
|
13818
|
+
*/
|
|
13819
|
+
constructor(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, simplified) {
|
|
13820
|
+
this.fontName = fontName;
|
|
13821
|
+
this.fontWeight = fontWeight;
|
|
13822
|
+
this.fontColor = fontColor;
|
|
13823
|
+
this.fontSize = fontSize;
|
|
13824
|
+
this.backgroundColor = backgroundColor;
|
|
13825
|
+
this.backgroundOpacity = backgroundOpacity;
|
|
13826
|
+
this.paddingTop = paddingTop;
|
|
13827
|
+
this.paddingBottom = paddingBottom;
|
|
13828
|
+
this.position = position;
|
|
13829
|
+
this.scale = scale;
|
|
13830
|
+
this.simplified = simplified;
|
|
13831
|
+
}
|
|
13832
|
+
};
|
|
13833
|
+
var WatermarkImage = class {
|
|
13834
|
+
constructor(image = "", width2 = 20, height2 = 20, position = 0) {
|
|
13835
|
+
this.image = image;
|
|
13836
|
+
this.width = width2;
|
|
13837
|
+
this.height = height2;
|
|
13838
|
+
this.position = position;
|
|
13660
13839
|
}
|
|
13661
|
-
|
|
13840
|
+
};
|
|
13841
|
+
var Watermark = class {
|
|
13842
|
+
/**
|
|
13843
|
+
* 水印对象,包含需要渲染的文本、图像,以及相应的style
|
|
13844
|
+
* @param content
|
|
13845
|
+
* @param watermarkStyle
|
|
13846
|
+
*/
|
|
13847
|
+
constructor(content, watermarkStyle, watermarkImage) {
|
|
13848
|
+
this.content = content;
|
|
13849
|
+
this.style = watermarkStyle;
|
|
13850
|
+
this.watermarkImage = watermarkImage;
|
|
13851
|
+
}
|
|
13852
|
+
};
|
|
13853
|
+
function getHeitiFontFamily(fontFamily = "") {
|
|
13854
|
+
let defaultFontFamily;
|
|
13855
|
+
if (checkIsWindows()) {
|
|
13856
|
+
if (fontFamily.includes("黑体")) {
|
|
13857
|
+
fontFamily = "";
|
|
13858
|
+
}
|
|
13859
|
+
defaultFontFamily = "'Roboto Black', 'Droid Sans'";
|
|
13860
|
+
} else if (checkIsIOS()) {
|
|
13861
|
+
if (fontFamily.includes("黑体")) {
|
|
13862
|
+
fontFamily = "";
|
|
13863
|
+
}
|
|
13864
|
+
defaultFontFamily = "'PingFang SC Medium'";
|
|
13865
|
+
} else if (checkIsAndroid()) {
|
|
13866
|
+
defaultFontFamily = "'Roboto Black', 'Droid Sans'";
|
|
13867
|
+
} else {
|
|
13868
|
+
defaultFontFamily = '"PingFang SC Medium", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';
|
|
13869
|
+
}
|
|
13870
|
+
return fontFamily ? `${fontFamily}, ${defaultFontFamily}` : defaultFontFamily;
|
|
13662
13871
|
}
|
|
13663
13872
|
function parseWatermarkStyle(styleString, canvasSize) {
|
|
13664
|
-
if (!
|
|
13873
|
+
if (!checkIsStringValid(styleString)) {
|
|
13665
13874
|
return null;
|
|
13666
13875
|
}
|
|
13667
13876
|
const styleParts = styleString.split("$");
|
|
@@ -13669,121 +13878,120 @@
|
|
|
13669
13878
|
return null;
|
|
13670
13879
|
}
|
|
13671
13880
|
const scale = Math.min(canvasSize.width, canvasSize.height) / DEFAULT_CANVAS_SIZE;
|
|
13672
|
-
if (
|
|
13673
|
-
const
|
|
13881
|
+
if (parseInteger(styleParts[0], -1) !== -1) {
|
|
13882
|
+
const fontSize = Math.round(
|
|
13674
13883
|
parseDecimal(styleParts[0], DEFAULT_FONT_SIZE) * scale
|
|
13675
13884
|
);
|
|
13676
|
-
let
|
|
13885
|
+
let position = "lefttop";
|
|
13677
13886
|
if (styleParts[1]) {
|
|
13678
|
-
|
|
13887
|
+
position = styleParts[1];
|
|
13679
13888
|
}
|
|
13680
|
-
let
|
|
13681
|
-
let
|
|
13889
|
+
let paddingTop = DEFAULT_PADDING * scale;
|
|
13890
|
+
let paddingBottom = DEFAULT_PADDING * scale;
|
|
13682
13891
|
if (styleParts[2]) {
|
|
13683
13892
|
const paddingParts = styleParts[2].split("_");
|
|
13684
|
-
|
|
13893
|
+
paddingTop = parseInteger(paddingParts[0], DEFAULT_PADDING) * scale;
|
|
13685
13894
|
if (paddingParts[1]) {
|
|
13686
|
-
|
|
13895
|
+
paddingBottom = parseInteger(paddingParts[1], DEFAULT_PADDING) * scale;
|
|
13687
13896
|
}
|
|
13688
13897
|
}
|
|
13689
|
-
const
|
|
13690
|
-
const
|
|
13691
|
-
const
|
|
13692
|
-
const
|
|
13693
|
-
const
|
|
13694
|
-
return
|
|
13695
|
-
fontName
|
|
13696
|
-
fontWeight
|
|
13697
|
-
fontColor
|
|
13698
|
-
fontSize
|
|
13699
|
-
backgroundColor
|
|
13700
|
-
backgroundOpacity
|
|
13701
|
-
paddingTop
|
|
13702
|
-
paddingBottom
|
|
13703
|
-
position
|
|
13898
|
+
const fontName = getHeitiFontFamily();
|
|
13899
|
+
const fontWeight = "normal";
|
|
13900
|
+
const fontColor = ColorMap.transparent;
|
|
13901
|
+
const backgroundColor = ColorMap.transparent;
|
|
13902
|
+
const backgroundOpacity = 128;
|
|
13903
|
+
return new WatermarkStyle(
|
|
13904
|
+
fontName,
|
|
13905
|
+
fontWeight,
|
|
13906
|
+
fontColor,
|
|
13907
|
+
fontSize,
|
|
13908
|
+
backgroundColor,
|
|
13909
|
+
backgroundOpacity,
|
|
13910
|
+
paddingTop,
|
|
13911
|
+
paddingBottom,
|
|
13912
|
+
position,
|
|
13704
13913
|
scale,
|
|
13705
|
-
|
|
13706
|
-
};
|
|
13707
|
-
}
|
|
13708
|
-
const fontName = styleParts[0] + ", " + getHeitiFontFamily();
|
|
13709
|
-
let fontWeight = "normal";
|
|
13710
|
-
if (styleParts[1]) {
|
|
13711
|
-
fontWeight = styleParts[1];
|
|
13712
|
-
}
|
|
13713
|
-
let fontColor = ColorMap.white;
|
|
13714
|
-
if (styleParts[2]) {
|
|
13715
|
-
const color = getColorValue(styleParts[2]);
|
|
13716
|
-
if (color) {
|
|
13717
|
-
fontColor = color;
|
|
13718
|
-
}
|
|
13719
|
-
}
|
|
13720
|
-
let fontSize = Math.round(DEFAULT_FONT_SIZE * scale);
|
|
13721
|
-
if (styleParts[3]) {
|
|
13722
|
-
fontSize = Math.round(
|
|
13723
|
-
parseDecimal(styleParts[3], DEFAULT_FONT_SIZE) * scale
|
|
13914
|
+
true
|
|
13724
13915
|
);
|
|
13725
|
-
}
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
backgroundColor = color;
|
|
13916
|
+
} else {
|
|
13917
|
+
const fontName = getHeitiFontFamily(styleParts[0]);
|
|
13918
|
+
let fontWeight = "normal";
|
|
13919
|
+
if (styleParts[1]) {
|
|
13920
|
+
fontWeight = styleParts[1];
|
|
13731
13921
|
}
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
if (styleParts[6]) {
|
|
13739
|
-
let opacity = parseNumber(styleParts[6], DEFAULT_BACKGROUND_OPACITY);
|
|
13740
|
-
opacity = clamp(opacity, 0, 255);
|
|
13741
|
-
backgroundOpacity = opacity;
|
|
13742
|
-
}
|
|
13743
|
-
let paddingTop = DEFAULT_PADDING * scale;
|
|
13744
|
-
let paddingBottom = DEFAULT_PADDING * scale;
|
|
13745
|
-
if (styleParts[7]) {
|
|
13746
|
-
const paddingParts = styleParts[7].split("_");
|
|
13747
|
-
paddingTop = parseNumber(paddingParts[0], DEFAULT_PADDING) * scale;
|
|
13748
|
-
if (paddingParts[1]) {
|
|
13749
|
-
paddingBottom = parseNumber(paddingParts[1], DEFAULT_PADDING) * scale;
|
|
13922
|
+
let fontColor = ColorMap.white;
|
|
13923
|
+
if (styleParts[2]) {
|
|
13924
|
+
const color = getColorValue(styleParts[2]);
|
|
13925
|
+
if (color) {
|
|
13926
|
+
fontColor = color;
|
|
13927
|
+
}
|
|
13750
13928
|
}
|
|
13929
|
+
let fontSize = Math.round(DEFAULT_FONT_SIZE * scale);
|
|
13930
|
+
if (styleParts[3]) {
|
|
13931
|
+
fontSize = Math.round(
|
|
13932
|
+
parseDecimal(styleParts[3], DEFAULT_FONT_SIZE) * scale
|
|
13933
|
+
);
|
|
13934
|
+
}
|
|
13935
|
+
let backgroundColor = ColorMap.blue;
|
|
13936
|
+
if (styleParts[4]) {
|
|
13937
|
+
const color = getColorValue(styleParts[4]);
|
|
13938
|
+
if (color) {
|
|
13939
|
+
backgroundColor = color;
|
|
13940
|
+
}
|
|
13941
|
+
}
|
|
13942
|
+
let position = "lefttop";
|
|
13943
|
+
if (styleParts[5]) {
|
|
13944
|
+
position = styleParts[5];
|
|
13945
|
+
}
|
|
13946
|
+
let backgroundOpacity = 255;
|
|
13947
|
+
if (styleParts[6]) {
|
|
13948
|
+
let opacity = parseInteger(styleParts[6], DEFAULT_BACKGROUND_OPACITY);
|
|
13949
|
+
opacity = clamp(opacity, 0, 255);
|
|
13950
|
+
backgroundOpacity = opacity;
|
|
13951
|
+
}
|
|
13952
|
+
let paddingTop = DEFAULT_PADDING * scale;
|
|
13953
|
+
let paddingBottom = DEFAULT_PADDING * scale;
|
|
13954
|
+
if (styleParts[7]) {
|
|
13955
|
+
const paddingParts = styleParts[7].split("_");
|
|
13956
|
+
paddingTop = parseInteger(paddingParts[0], DEFAULT_PADDING) * scale;
|
|
13957
|
+
if (paddingParts[1]) {
|
|
13958
|
+
paddingBottom = parseInteger(paddingParts[1], DEFAULT_PADDING) * scale;
|
|
13959
|
+
}
|
|
13960
|
+
}
|
|
13961
|
+
return new WatermarkStyle(
|
|
13962
|
+
fontName,
|
|
13963
|
+
fontWeight,
|
|
13964
|
+
fontColor,
|
|
13965
|
+
fontSize,
|
|
13966
|
+
backgroundColor,
|
|
13967
|
+
backgroundOpacity,
|
|
13968
|
+
paddingTop,
|
|
13969
|
+
paddingBottom,
|
|
13970
|
+
position,
|
|
13971
|
+
scale,
|
|
13972
|
+
false
|
|
13973
|
+
);
|
|
13751
13974
|
}
|
|
13752
|
-
return {
|
|
13753
|
-
fontName,
|
|
13754
|
-
fontWeight,
|
|
13755
|
-
fontColor,
|
|
13756
|
-
fontSize,
|
|
13757
|
-
backgroundColor,
|
|
13758
|
-
backgroundOpacity,
|
|
13759
|
-
paddingTop,
|
|
13760
|
-
paddingBottom,
|
|
13761
|
-
position,
|
|
13762
|
-
scale,
|
|
13763
|
-
simplified: false
|
|
13764
|
-
};
|
|
13765
13975
|
}
|
|
13766
|
-
|
|
13976
|
+
var TextScanner = class {
|
|
13767
13977
|
/**
|
|
13768
13978
|
* The content to scan
|
|
13769
13979
|
* @param text
|
|
13770
13980
|
*/
|
|
13771
13981
|
constructor(text) {
|
|
13772
|
-
__publicField$1(this, "text");
|
|
13773
|
-
__publicField$1(this, "cursor");
|
|
13774
13982
|
this.text = text;
|
|
13775
13983
|
this.cursor = 0;
|
|
13776
13984
|
}
|
|
13777
13985
|
hasNext(obj) {
|
|
13778
|
-
if (
|
|
13986
|
+
if (checkIsUndefinedOrNull(obj)) {
|
|
13779
13987
|
return this.cursor < this.text.length;
|
|
13780
|
-
} else if (
|
|
13988
|
+
} else if (checkIsString(obj)) {
|
|
13781
13989
|
const str = obj;
|
|
13782
13990
|
const current2 = subString(this.text, this.cursor, str.length);
|
|
13783
13991
|
if (current2 === str) {
|
|
13784
13992
|
return true;
|
|
13785
13993
|
}
|
|
13786
|
-
} else if (
|
|
13994
|
+
} else if (checkIsRegExp(obj)) {
|
|
13787
13995
|
const regex = obj;
|
|
13788
13996
|
const subText = subString(this.text, this.cursor);
|
|
13789
13997
|
const matchResults = subText.match(regex);
|
|
@@ -13796,14 +14004,14 @@
|
|
|
13796
14004
|
return false;
|
|
13797
14005
|
}
|
|
13798
14006
|
next(obj) {
|
|
13799
|
-
if (
|
|
14007
|
+
if (checkIsUndefinedOrNull(obj)) {
|
|
13800
14008
|
return subString(this.text, this.cursor, 1);
|
|
13801
|
-
} else if (
|
|
14009
|
+
} else if (checkIsString(obj)) {
|
|
13802
14010
|
const str = obj;
|
|
13803
14011
|
if (subString(this.text, this.cursor, str.length) === str) {
|
|
13804
14012
|
return str;
|
|
13805
14013
|
}
|
|
13806
|
-
} else if (
|
|
14014
|
+
} else if (checkIsRegExp(obj)) {
|
|
13807
14015
|
const regex = obj;
|
|
13808
14016
|
const subText = subString(this.text, this.cursor);
|
|
13809
14017
|
const matchResults = subText.match(regex);
|
|
@@ -13816,20 +14024,57 @@
|
|
|
13816
14024
|
return null;
|
|
13817
14025
|
}
|
|
13818
14026
|
skip(obj) {
|
|
13819
|
-
if (
|
|
14027
|
+
if (checkIsUndefinedOrNull(obj)) {
|
|
13820
14028
|
this.cursor += 1;
|
|
13821
|
-
} else if (
|
|
14029
|
+
} else if (checkIsStringValid(obj)) {
|
|
13822
14030
|
const str = obj;
|
|
13823
14031
|
this.cursor += str.length;
|
|
13824
14032
|
}
|
|
13825
14033
|
return this;
|
|
13826
14034
|
}
|
|
14035
|
+
};
|
|
14036
|
+
function transformFormatString(format) {
|
|
14037
|
+
let transformString = format;
|
|
14038
|
+
if (format.includes("d")) {
|
|
14039
|
+
transformString = transformString.replace(/d/g, "D");
|
|
14040
|
+
}
|
|
14041
|
+
if (format.includes("y")) {
|
|
14042
|
+
transformString = transformString.replace(/y/g, "Y");
|
|
14043
|
+
}
|
|
14044
|
+
if (format.includes("E")) {
|
|
14045
|
+
transformString = transformString.replace(/E/g, "d");
|
|
14046
|
+
}
|
|
14047
|
+
return transformString;
|
|
13827
14048
|
}
|
|
13828
|
-
function buildContent(contentConfigString, watermarkContext) {
|
|
14049
|
+
function buildContent(contentConfigString, watermarkContext, style, canvasSize) {
|
|
13829
14050
|
let content = "";
|
|
14051
|
+
const watermarkImage = new WatermarkImage();
|
|
14052
|
+
if (contentConfigString.includes("{logo")) {
|
|
14053
|
+
const start2 = contentConfigString.indexOf("{logo");
|
|
14054
|
+
const end2 = contentConfigString.indexOf("}", start2);
|
|
14055
|
+
if (end2 != -1) {
|
|
14056
|
+
const logoConfigWithBrace = contentConfigString.substring(start2, end2 + 1);
|
|
14057
|
+
if (contentConfigString.startsWith(logoConfigWithBrace) || contentConfigString.endsWith(logoConfigWithBrace)) {
|
|
14058
|
+
if (contentConfigString.startsWith(logoConfigWithBrace)) {
|
|
14059
|
+
watermarkImage.position = 0;
|
|
14060
|
+
} else {
|
|
14061
|
+
watermarkImage.position = 1;
|
|
14062
|
+
}
|
|
14063
|
+
const imgWidthHeight = (style == null ? void 0 : style.fontSize) || 20;
|
|
14064
|
+
watermarkImage.image = watermarkContext.logo;
|
|
14065
|
+
watermarkImage.height = imgWidthHeight;
|
|
14066
|
+
watermarkImage.width = imgWidthHeight;
|
|
14067
|
+
}
|
|
14068
|
+
contentConfigString = contentConfigString.replace(
|
|
14069
|
+
logoConfigWithBrace,
|
|
14070
|
+
""
|
|
14071
|
+
);
|
|
14072
|
+
}
|
|
14073
|
+
}
|
|
13830
14074
|
const scanner = new TextScanner(contentConfigString);
|
|
13831
14075
|
let steps = 0;
|
|
13832
|
-
while (scanner.hasNext() &&
|
|
14076
|
+
while (scanner.hasNext() && /* 防止scanner代码错误产生无限循环,设置一个最大scan步数*/
|
|
14077
|
+
steps < contentConfigString.length) {
|
|
13833
14078
|
const dateRegex = new RegExp(
|
|
13834
14079
|
"date{(.*?)}|date"
|
|
13835
14080
|
/* Date */
|
|
@@ -13838,28 +14083,25 @@
|
|
|
13838
14083
|
const regexResult = scanner.next(dateRegex);
|
|
13839
14084
|
if (regexResult) {
|
|
13840
14085
|
const matchResults = regexResult;
|
|
13841
|
-
let format =
|
|
14086
|
+
let format = FORMAT.FORMAT_YMD;
|
|
13842
14087
|
if (matchResults && matchResults.length >= 2) {
|
|
13843
|
-
if (
|
|
14088
|
+
if (checkIsStringValid(matchResults[1])) {
|
|
13844
14089
|
format = matchResults[1];
|
|
13845
14090
|
}
|
|
13846
14091
|
}
|
|
13847
|
-
|
|
13848
|
-
|
|
13849
|
-
|
|
14092
|
+
content += (0, import_dayjs.default)(watermarkContext.watermarkTime).format(
|
|
14093
|
+
transformFormatString(format)
|
|
14094
|
+
);
|
|
13850
14095
|
scanner.skip(matchResults.input);
|
|
13851
14096
|
}
|
|
13852
14097
|
} else if (scanner.hasNext(
|
|
13853
14098
|
"time"
|
|
13854
14099
|
/* Time */
|
|
13855
14100
|
)) {
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
13859
|
-
|
|
13860
|
-
);
|
|
13861
|
-
content += value;
|
|
13862
|
-
}
|
|
14101
|
+
const value = (0, import_dayjs.default)(watermarkContext.watermarkTime).format(
|
|
14102
|
+
FORMAT.FORMAT_HM
|
|
14103
|
+
);
|
|
14104
|
+
content += value;
|
|
13863
14105
|
scanner.skip(
|
|
13864
14106
|
"time"
|
|
13865
14107
|
/* Time */
|
|
@@ -13868,8 +14110,12 @@
|
|
|
13868
14110
|
"address"
|
|
13869
14111
|
/* Address */
|
|
13870
14112
|
)) {
|
|
13871
|
-
|
|
13872
|
-
|
|
14113
|
+
content += watermarkContext.address;
|
|
14114
|
+
if (!watermarkImage.image) {
|
|
14115
|
+
const imgWidthHeight = (style == null ? void 0 : style.fontSize) || 20;
|
|
14116
|
+
watermarkImage.image = DEFAULT_ADDRESS_ICON;
|
|
14117
|
+
watermarkImage.height = imgWidthHeight;
|
|
14118
|
+
watermarkImage.width = imgWidthHeight;
|
|
13873
14119
|
}
|
|
13874
14120
|
scanner.skip(
|
|
13875
14121
|
"address"
|
|
@@ -13879,9 +14125,7 @@
|
|
|
13879
14125
|
"humanname"
|
|
13880
14126
|
/* HumanName */
|
|
13881
14127
|
)) {
|
|
13882
|
-
|
|
13883
|
-
content += watermarkContext.humanName;
|
|
13884
|
-
}
|
|
14128
|
+
content += watermarkContext.humanName;
|
|
13885
14129
|
scanner.skip(
|
|
13886
14130
|
"humanname"
|
|
13887
14131
|
/* HumanName */
|
|
@@ -13890,32 +14134,57 @@
|
|
|
13890
14134
|
"projectName"
|
|
13891
14135
|
/* ProjectName */
|
|
13892
14136
|
)) {
|
|
13893
|
-
|
|
13894
|
-
content += watermarkContext.projectName;
|
|
13895
|
-
}
|
|
14137
|
+
content += watermarkContext.projectName;
|
|
13896
14138
|
scanner.skip(
|
|
13897
14139
|
"projectName"
|
|
13898
14140
|
/* ProjectName */
|
|
13899
14141
|
);
|
|
13900
14142
|
} else if (scanner.hasNext(
|
|
13901
|
-
"
|
|
13902
|
-
/*
|
|
14143
|
+
"applicationName"
|
|
14144
|
+
/* ApplicationName */
|
|
13903
14145
|
)) {
|
|
13904
|
-
|
|
14146
|
+
content += watermarkContext.applicationName;
|
|
13905
14147
|
scanner.skip(
|
|
13906
|
-
"
|
|
13907
|
-
/*
|
|
14148
|
+
"applicationName"
|
|
14149
|
+
/* ApplicationName */
|
|
14150
|
+
);
|
|
14151
|
+
} else if (scanner.hasNext(
|
|
14152
|
+
"pixel"
|
|
14153
|
+
/* Pixel */
|
|
14154
|
+
)) {
|
|
14155
|
+
content += `${canvasSize.width} * ${canvasSize.height}`;
|
|
14156
|
+
scanner.skip(
|
|
14157
|
+
"pixel"
|
|
14158
|
+
/* Pixel */
|
|
14159
|
+
);
|
|
14160
|
+
} else if (scanner.hasNext(
|
|
14161
|
+
"width"
|
|
14162
|
+
/* Width */
|
|
14163
|
+
)) {
|
|
14164
|
+
content += canvasSize.width;
|
|
14165
|
+
scanner.skip(
|
|
14166
|
+
"width"
|
|
14167
|
+
/* Width */
|
|
14168
|
+
);
|
|
14169
|
+
} else if (scanner.hasNext(
|
|
14170
|
+
"height"
|
|
14171
|
+
/* Height */
|
|
14172
|
+
)) {
|
|
14173
|
+
content += canvasSize.height;
|
|
14174
|
+
scanner.skip(
|
|
14175
|
+
"height"
|
|
14176
|
+
/* Height */
|
|
13908
14177
|
);
|
|
13909
14178
|
} else {
|
|
13910
14179
|
const nextChar = scanner.next();
|
|
13911
|
-
if (
|
|
14180
|
+
if (checkIsString(nextChar)) {
|
|
13912
14181
|
content += nextChar;
|
|
13913
14182
|
}
|
|
13914
14183
|
scanner.skip();
|
|
13915
14184
|
}
|
|
13916
14185
|
steps++;
|
|
13917
14186
|
}
|
|
13918
|
-
return content;
|
|
14187
|
+
return { content, watermarkImage };
|
|
13919
14188
|
}
|
|
13920
14189
|
function parseWatermarks(watermarkConfigString, canvasSize, watermarkContext) {
|
|
13921
14190
|
const watermarks = [];
|
|
@@ -13927,39 +14196,55 @@
|
|
|
13927
14196
|
const styleString = configParts[0];
|
|
13928
14197
|
const contentString = configParts[1];
|
|
13929
14198
|
const style = parseWatermarkStyle(styleString, canvasSize);
|
|
13930
|
-
const
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
|
|
13934
|
-
|
|
13935
|
-
|
|
14199
|
+
const data = buildContent(
|
|
14200
|
+
contentString,
|
|
14201
|
+
watermarkContext,
|
|
14202
|
+
style,
|
|
14203
|
+
canvasSize
|
|
14204
|
+
);
|
|
14205
|
+
if (style && (data.content || data.watermarkImage.image)) {
|
|
14206
|
+
const watermark = new Watermark(
|
|
14207
|
+
data.content,
|
|
14208
|
+
style,
|
|
14209
|
+
data.watermarkImage
|
|
14210
|
+
);
|
|
13936
14211
|
watermarks.push(watermark);
|
|
13937
14212
|
}
|
|
13938
14213
|
}
|
|
13939
14214
|
}
|
|
13940
14215
|
return watermarks;
|
|
13941
14216
|
}
|
|
14217
|
+
var Tile = class {
|
|
14218
|
+
constructor(origin, size, lineHeight, lineWidths, lines, style, watermarkImage) {
|
|
14219
|
+
this.origin = origin;
|
|
14220
|
+
this.size = size;
|
|
14221
|
+
this.lineHeight = lineHeight;
|
|
14222
|
+
this.lineWidths = lineWidths;
|
|
14223
|
+
this.lines = lines;
|
|
14224
|
+
this.style = style;
|
|
14225
|
+
this.watermarkImage = watermarkImage;
|
|
14226
|
+
}
|
|
14227
|
+
};
|
|
13942
14228
|
function getCanvasScale(canvas, len) {
|
|
13943
14229
|
const min = Math.min(canvas.width, canvas.height);
|
|
13944
14230
|
return min / DEFAULT_CANVAS_SIZE * len;
|
|
13945
14231
|
}
|
|
13946
|
-
function buildTile(canvas,
|
|
13947
|
-
const
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
};
|
|
13951
|
-
const size = {
|
|
13952
|
-
width: 0,
|
|
13953
|
-
height: 0
|
|
13954
|
-
};
|
|
14232
|
+
function buildTile(canvas, watermark) {
|
|
14233
|
+
const { content, style, watermarkImage } = watermark;
|
|
14234
|
+
const origin = new Point(0, 0);
|
|
14235
|
+
const size = new Size(0, 0);
|
|
13955
14236
|
const lines = [];
|
|
13956
14237
|
const ctx = canvas.getContext("2d");
|
|
13957
14238
|
if (!ctx) {
|
|
13958
14239
|
return null;
|
|
13959
14240
|
}
|
|
14241
|
+
let imageWidth = 0;
|
|
14242
|
+
if (watermarkImage.image) {
|
|
14243
|
+
imageWidth = watermarkImage.width + LOGO_DEFAULT_PADDING * style.scale;
|
|
14244
|
+
}
|
|
13960
14245
|
ctx.font = `${style.fontWeight} ${style.fontSize}px ${style.fontName}`;
|
|
13961
14246
|
const contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
|
|
13962
|
-
const contentWidth = canvas.width - contentPadding * 2;
|
|
14247
|
+
const contentWidth = canvas.width - contentPadding * 2 - imageWidth;
|
|
13963
14248
|
const lineHeight = ctx.measureText("M").width;
|
|
13964
14249
|
const lineWidths = [];
|
|
13965
14250
|
let temp = "";
|
|
@@ -13967,9 +14252,11 @@
|
|
|
13967
14252
|
for (let i2 = 0; i2 < content.length; i2++) {
|
|
13968
14253
|
const lineWidth = ctx.measureText(temp).width;
|
|
13969
14254
|
if (lineWidth >= contentWidth) {
|
|
13970
|
-
|
|
13971
|
-
|
|
13972
|
-
|
|
14255
|
+
const line = temp.substring(0, temp.length - 1);
|
|
14256
|
+
const preLineWidth = ctx.measureText(line).width;
|
|
14257
|
+
lines.push(line);
|
|
14258
|
+
lineWidths.push(preLineWidth);
|
|
14259
|
+
temp = temp.substring(temp.length - 1);
|
|
13973
14260
|
}
|
|
13974
14261
|
lastWidth = lineWidth;
|
|
13975
14262
|
temp += content[i2];
|
|
@@ -13978,17 +14265,64 @@
|
|
|
13978
14265
|
lineWidths.push(lastWidth);
|
|
13979
14266
|
size.width = contentWidth;
|
|
13980
14267
|
size.height = lines.length * lineHeight;
|
|
13981
|
-
return
|
|
14268
|
+
return new Tile(
|
|
14269
|
+
origin,
|
|
14270
|
+
size,
|
|
14271
|
+
lineHeight,
|
|
14272
|
+
lineWidths,
|
|
14273
|
+
lines,
|
|
14274
|
+
style,
|
|
14275
|
+
watermarkImage
|
|
14276
|
+
);
|
|
13982
14277
|
}
|
|
13983
|
-
function getAxisPoint(canvasWidth, origin,
|
|
14278
|
+
function getAxisPoint(canvasWidth, width2, tile, origin, line) {
|
|
14279
|
+
const { style, watermarkImage, lines, lineHeight } = tile;
|
|
13984
14280
|
const padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
|
|
13985
|
-
let axisPoint =
|
|
14281
|
+
let axisPoint = new Point(padding, origin.y);
|
|
13986
14282
|
if (style.position.startsWith("center")) {
|
|
13987
|
-
axisPoint =
|
|
14283
|
+
axisPoint = new Point(canvasWidth / 2, origin.y);
|
|
13988
14284
|
} else if (style.position.startsWith("right")) {
|
|
13989
|
-
axisPoint =
|
|
14285
|
+
axisPoint = new Point(canvasWidth - padding, origin.y);
|
|
14286
|
+
}
|
|
14287
|
+
const imagePoint = new Point(axisPoint.x, axisPoint.y);
|
|
14288
|
+
if (watermarkImage.image) {
|
|
14289
|
+
const maxWidth = Math.max(...tile.lineWidths);
|
|
14290
|
+
if (watermarkImage.position === 0) {
|
|
14291
|
+
if (style.position.startsWith("left")) {
|
|
14292
|
+
axisPoint.x = axisPoint.x + watermarkImage.width + LOGO_DEFAULT_PADDING * style.scale;
|
|
14293
|
+
} else if (style.position.startsWith("center")) {
|
|
14294
|
+
if (line) {
|
|
14295
|
+
axisPoint.x = axisPoint.x + watermarkImage.width / 2 + LOGO_DEFAULT_PADDING / 2 * style.scale;
|
|
14296
|
+
imagePoint.x = lines.length === 1 ? imagePoint.x - width2 / 2 - watermarkImage.width - LOGO_DEFAULT_PADDING / 2 * style.scale : imagePoint.x - maxWidth / 2 - watermarkImage.width / 2 - LOGO_DEFAULT_PADDING / 2 * style.scale;
|
|
14297
|
+
} else {
|
|
14298
|
+
imagePoint.x = imagePoint.x - watermarkImage.width / 2;
|
|
14299
|
+
}
|
|
14300
|
+
} else {
|
|
14301
|
+
if (line) {
|
|
14302
|
+
imagePoint.x = lines.length === 1 ? imagePoint.x - width2 - 2 * watermarkImage.width - LOGO_DEFAULT_PADDING / 2 * style.scale : imagePoint.x - maxWidth - watermarkImage.width - LOGO_DEFAULT_PADDING / 2 * style.scale;
|
|
14303
|
+
} else {
|
|
14304
|
+
imagePoint.x = imagePoint.x - watermarkImage.width;
|
|
14305
|
+
}
|
|
14306
|
+
}
|
|
14307
|
+
} else {
|
|
14308
|
+
if (style.position.startsWith("left")) {
|
|
14309
|
+
imagePoint.x = lines.length === 1 ? axisPoint.x + width2 + watermarkImage.width + LOGO_DEFAULT_PADDING * style.scale : axisPoint.x + maxWidth + LOGO_DEFAULT_PADDING * style.scale;
|
|
14310
|
+
} else if (style.position.startsWith("center")) {
|
|
14311
|
+
axisPoint.x = axisPoint.x - watermarkImage.width / 2;
|
|
14312
|
+
imagePoint.x = lines.length === 1 ? imagePoint.x + width2 / 2 + LOGO_DEFAULT_PADDING * style.scale : imagePoint.x + maxWidth / 2 - watermarkImage.width / 2 + LOGO_DEFAULT_PADDING * style.scale;
|
|
14313
|
+
} else {
|
|
14314
|
+
axisPoint.x = axisPoint.x - watermarkImage.width;
|
|
14315
|
+
imagePoint.x = imagePoint.x - watermarkImage.width + LOGO_DEFAULT_PADDING / 2 * style.scale;
|
|
14316
|
+
}
|
|
14317
|
+
}
|
|
14318
|
+
if (lines.length > 1) {
|
|
14319
|
+
imagePoint.y = imagePoint.y + lines.length * lineHeight / 2 - watermarkImage.height / 2;
|
|
14320
|
+
}
|
|
13990
14321
|
}
|
|
13991
|
-
return
|
|
14322
|
+
return {
|
|
14323
|
+
text: axisPoint,
|
|
14324
|
+
image: imagePoint
|
|
14325
|
+
};
|
|
13992
14326
|
}
|
|
13993
14327
|
function getTextAlign(style) {
|
|
13994
14328
|
let align = "left";
|
|
@@ -13999,35 +14333,62 @@
|
|
|
13999
14333
|
}
|
|
14000
14334
|
return align;
|
|
14001
14335
|
}
|
|
14002
|
-
function
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
|
|
14007
|
-
|
|
14008
|
-
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
|
|
14018
|
-
|
|
14019
|
-
ctx
|
|
14020
|
-
|
|
14021
|
-
|
|
14336
|
+
function loadImage(url) {
|
|
14337
|
+
return new Promise((resolve, reject) => {
|
|
14338
|
+
const img = new Image();
|
|
14339
|
+
img.src = url;
|
|
14340
|
+
img.crossOrigin = "anonymous";
|
|
14341
|
+
img.onload = function(e2) {
|
|
14342
|
+
if (img.complete) {
|
|
14343
|
+
resolve(img);
|
|
14344
|
+
} else {
|
|
14345
|
+
console.error(e2);
|
|
14346
|
+
reject(new Error("文件加载失败"));
|
|
14347
|
+
}
|
|
14348
|
+
};
|
|
14349
|
+
});
|
|
14350
|
+
}
|
|
14351
|
+
function drawLine(canvas, line, width2, origin, tile, drawImage) {
|
|
14352
|
+
return __async$1(this, null, function* () {
|
|
14353
|
+
const ctx = canvas.getContext("2d");
|
|
14354
|
+
if (!ctx) {
|
|
14355
|
+
return;
|
|
14356
|
+
}
|
|
14357
|
+
const { style, watermarkImage } = tile;
|
|
14358
|
+
ctx.textBaseline = "top";
|
|
14359
|
+
ctx.font = `${style.fontWeight} ${style.fontSize}px ${style.fontName}`;
|
|
14360
|
+
const point = getAxisPoint(canvas.width, width2, tile, origin, line);
|
|
14361
|
+
ctx.textAlign = getTextAlign(style);
|
|
14362
|
+
if (watermarkImage.image && drawImage) {
|
|
14363
|
+
const image = yield loadImage(watermarkImage.image);
|
|
14364
|
+
ctx.drawImage(
|
|
14365
|
+
image,
|
|
14366
|
+
Math.round(point.image.x),
|
|
14367
|
+
Math.round(point.image.y),
|
|
14368
|
+
watermarkImage.width,
|
|
14369
|
+
watermarkImage.height
|
|
14370
|
+
);
|
|
14371
|
+
}
|
|
14372
|
+
if (style.simplified) {
|
|
14373
|
+
ctx.shadowBlur = 4;
|
|
14374
|
+
ctx.shadowColor = "rgba(0, 0, 0, 0.5)";
|
|
14375
|
+
const offset2 = clamp(style.fontSize / 40, 2, 4);
|
|
14376
|
+
ctx.shadowOffsetY = offset2;
|
|
14377
|
+
ctx.shadowOffsetX = offset2;
|
|
14378
|
+
ctx.fillStyle = "rgba(255,255,255, 0.5)";
|
|
14379
|
+
} else {
|
|
14380
|
+
ctx.fillStyle = style.fontColor;
|
|
14381
|
+
}
|
|
14382
|
+
ctx.fillText(line, Math.round(point.text.x), Math.round(point.text.y));
|
|
14383
|
+
});
|
|
14022
14384
|
}
|
|
14023
14385
|
function hexToRGB(hex, alpha) {
|
|
14024
|
-
const r2 = parseInt(hex.slice(1, 3), 16);
|
|
14025
|
-
const g2 = parseInt(hex.slice(3, 5), 16);
|
|
14026
|
-
const b2 = parseInt(hex.slice(5, 7), 16);
|
|
14386
|
+
const r2 = parseInt(hex.slice(1, 3), 16), g2 = parseInt(hex.slice(3, 5), 16), b2 = parseInt(hex.slice(5, 7), 16);
|
|
14027
14387
|
if (alpha) {
|
|
14028
14388
|
return "rgba(" + r2 + ", " + g2 + ", " + b2 + ", " + alpha + ")";
|
|
14389
|
+
} else {
|
|
14390
|
+
return "rgb(" + r2 + ", " + g2 + ", " + b2 + ")";
|
|
14029
14391
|
}
|
|
14030
|
-
return "rgb(" + r2 + ", " + g2 + ", " + b2 + ")";
|
|
14031
14392
|
}
|
|
14032
14393
|
function drawBackground(canvas, tile) {
|
|
14033
14394
|
const ctx = canvas.getContext("2d");
|
|
@@ -14042,14 +14403,13 @@
|
|
|
14042
14403
|
if (backgroundOpacity > 255) {
|
|
14043
14404
|
backgroundOpacity = 255;
|
|
14044
14405
|
}
|
|
14045
|
-
const
|
|
14046
|
-
const paddingBottom =
|
|
14406
|
+
const { style } = tile;
|
|
14407
|
+
const { paddingTop, paddingBottom } = style;
|
|
14047
14408
|
if (backgroundColor !== "transparent") {
|
|
14048
14409
|
if (backgroundColor.startsWith("#") && backgroundOpacity >= 0) {
|
|
14049
14410
|
backgroundColor = hexToRGB(backgroundColor, backgroundOpacity / 255);
|
|
14050
14411
|
}
|
|
14051
14412
|
ctx.fillStyle = backgroundColor;
|
|
14052
|
-
const { style } = tile;
|
|
14053
14413
|
const padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
|
|
14054
14414
|
const paddingScale = tile.style.fontSize / DEFAULT_FONT_SIZE;
|
|
14055
14415
|
for (let j = 0; j < tile.lineWidths.length; j++) {
|
|
@@ -14057,31 +14417,29 @@
|
|
|
14057
14417
|
const lineWidth = tile.lineWidths[j];
|
|
14058
14418
|
let paddingRight = 30 * paddingScale;
|
|
14059
14419
|
let paddingLeft = 10 * paddingScale;
|
|
14060
|
-
let axisPoint =
|
|
14061
|
-
x: padding - paddingLeft,
|
|
14062
|
-
y: tile.origin.y
|
|
14063
|
-
};
|
|
14420
|
+
let axisPoint = new Point(padding - paddingLeft, tile.origin.y);
|
|
14064
14421
|
if (style.position.startsWith("center")) {
|
|
14065
14422
|
paddingLeft = 20 * paddingScale;
|
|
14066
14423
|
paddingRight = 20 * paddingScale;
|
|
14067
|
-
axisPoint =
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14424
|
+
axisPoint = new Point(
|
|
14425
|
+
(canvas.width - lineWidth) / 2 - paddingLeft,
|
|
14426
|
+
tile.origin.y
|
|
14427
|
+
);
|
|
14071
14428
|
} else if (style.position.startsWith("right")) {
|
|
14072
14429
|
paddingLeft = 30 * paddingScale;
|
|
14073
14430
|
paddingRight = 10 * paddingScale;
|
|
14074
|
-
axisPoint =
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14431
|
+
axisPoint = new Point(
|
|
14432
|
+
canvas.width - lineWidth - padding - paddingLeft,
|
|
14433
|
+
tile.origin.y
|
|
14434
|
+
);
|
|
14078
14435
|
}
|
|
14079
14436
|
if (j === 0) {
|
|
14437
|
+
const top2 = checkIsWindows() ? paddingTop + 6 * style.scale : paddingTop;
|
|
14080
14438
|
ctx.fillRect(
|
|
14081
14439
|
axisPoint.x,
|
|
14082
|
-
axisPoint.y - paddingTop > 0 ? axisPoint.y -
|
|
14440
|
+
axisPoint.y - paddingTop > 0 ? axisPoint.y - top2 : 0,
|
|
14083
14441
|
paddingLeft + lineWidth + paddingRight,
|
|
14084
|
-
|
|
14442
|
+
top2
|
|
14085
14443
|
);
|
|
14086
14444
|
}
|
|
14087
14445
|
ctx.fillRect(
|
|
@@ -14091,77 +14449,89 @@
|
|
|
14091
14449
|
lineHeight
|
|
14092
14450
|
);
|
|
14093
14451
|
if (j === tile.lineWidths.length - 1) {
|
|
14452
|
+
const bottom2 = checkIsIOS() ? paddingBottom + 4 * style.scale : paddingBottom;
|
|
14094
14453
|
ctx.fillRect(
|
|
14095
14454
|
axisPoint.x,
|
|
14096
14455
|
axisPoint.y + (j + 1) * lineHeight,
|
|
14097
14456
|
paddingLeft + lineWidth + paddingRight,
|
|
14098
|
-
|
|
14457
|
+
bottom2
|
|
14099
14458
|
);
|
|
14100
14459
|
}
|
|
14101
14460
|
}
|
|
14102
14461
|
}
|
|
14103
14462
|
}
|
|
14104
14463
|
function drawTile(canvas, tile) {
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14464
|
+
return __async$1(this, null, function* () {
|
|
14465
|
+
if (!tile.style.simplified) {
|
|
14466
|
+
drawBackground(canvas, tile);
|
|
14467
|
+
}
|
|
14468
|
+
for (let i2 = 0; i2 < tile.lines.length; i2++) {
|
|
14469
|
+
const origin = new Point(
|
|
14470
|
+
tile.origin.x,
|
|
14471
|
+
i2 * tile.lineHeight + tile.origin.y
|
|
14472
|
+
);
|
|
14473
|
+
yield drawLine(
|
|
14474
|
+
canvas,
|
|
14475
|
+
tile.lines[i2],
|
|
14476
|
+
tile.lineWidths[i2],
|
|
14477
|
+
origin,
|
|
14478
|
+
tile,
|
|
14479
|
+
i2 === 0
|
|
14480
|
+
);
|
|
14481
|
+
}
|
|
14482
|
+
});
|
|
14115
14483
|
}
|
|
14116
14484
|
function drawGroupedWatermarks(canvas, watermarks, groupPosition) {
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
const tiles = [];
|
|
14121
|
-
let totalHeight = 0;
|
|
14122
|
-
for (let i2 = 0; i2 < watermarks.length; i2++) {
|
|
14123
|
-
const watermark = watermarks[i2];
|
|
14124
|
-
const tile = buildTile(canvas, watermark.content, watermark.style);
|
|
14125
|
-
if (tile) {
|
|
14126
|
-
tiles.push(tile);
|
|
14127
|
-
totalHeight += tile.size.height;
|
|
14485
|
+
return __async$1(this, null, function* () {
|
|
14486
|
+
if (!watermarks || watermarks.length === 0) {
|
|
14487
|
+
return;
|
|
14128
14488
|
}
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
|
|
14140
|
-
|
|
14141
|
-
|
|
14142
|
-
|
|
14143
|
-
|
|
14144
|
-
|
|
14145
|
-
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
14152
|
-
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
lastMarginTop
|
|
14160
|
-
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14489
|
+
const tiles = [];
|
|
14490
|
+
let totalHeight = 0;
|
|
14491
|
+
for (let i2 = 0; i2 < watermarks.length; i2++) {
|
|
14492
|
+
const watermark = watermarks[i2];
|
|
14493
|
+
const tile = buildTile(canvas, watermark);
|
|
14494
|
+
if (tile) {
|
|
14495
|
+
tiles.push(tile);
|
|
14496
|
+
totalHeight += tile.size.height + CONTENT_PADDING;
|
|
14497
|
+
}
|
|
14498
|
+
}
|
|
14499
|
+
if (totalHeight <= 0) {
|
|
14500
|
+
console.error("watermarks height " + totalHeight);
|
|
14501
|
+
console.error(JSON.stringify(watermarks));
|
|
14502
|
+
return;
|
|
14503
|
+
}
|
|
14504
|
+
const contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
|
|
14505
|
+
let baseOrigin = new Point(contentPadding, contentPadding);
|
|
14506
|
+
if (groupPosition === "center") {
|
|
14507
|
+
baseOrigin = new Point(
|
|
14508
|
+
contentPadding,
|
|
14509
|
+
Math.round((canvas.height - totalHeight) / 2)
|
|
14510
|
+
);
|
|
14511
|
+
} else if (groupPosition === "bottom") {
|
|
14512
|
+
baseOrigin = new Point(
|
|
14513
|
+
contentPadding,
|
|
14514
|
+
canvas.height - totalHeight - contentPadding
|
|
14515
|
+
);
|
|
14516
|
+
} else if (groupPosition === "top") {
|
|
14517
|
+
baseOrigin = new Point(contentPadding, contentPadding);
|
|
14518
|
+
}
|
|
14519
|
+
let lastMarginTop = 0;
|
|
14520
|
+
for (let i2 = 0; i2 < tiles.length; i2++) {
|
|
14521
|
+
const tile = tiles[i2];
|
|
14522
|
+
lastMarginTop += tile.style.paddingTop;
|
|
14523
|
+
tile.origin = new Point(
|
|
14524
|
+
tile.origin.x + baseOrigin.x,
|
|
14525
|
+
lastMarginTop + baseOrigin.y
|
|
14526
|
+
);
|
|
14527
|
+
lastMarginTop += tile.size.height;
|
|
14528
|
+
lastMarginTop += tile.style.paddingBottom;
|
|
14529
|
+
}
|
|
14530
|
+
for (let i2 = 0; i2 < tiles.length; i2++) {
|
|
14531
|
+
const tile = tiles[i2];
|
|
14532
|
+
yield drawTile(canvas, tile);
|
|
14533
|
+
}
|
|
14534
|
+
});
|
|
14165
14535
|
}
|
|
14166
14536
|
function groupingWatermarks(watermarks) {
|
|
14167
14537
|
const topList = [];
|
|
@@ -14193,56 +14563,51 @@
|
|
|
14193
14563
|
};
|
|
14194
14564
|
}
|
|
14195
14565
|
function renderWatermark(canvas, options) {
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
watermarkConfigString
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14566
|
+
return __async$1(this, null, function* () {
|
|
14567
|
+
if (!options.enabled || options.watermarkConfigString === "no") {
|
|
14568
|
+
return Promise.resolve(canvas);
|
|
14569
|
+
}
|
|
14570
|
+
let { watermarkConfigString = "" } = options;
|
|
14571
|
+
if (watermarkConfigString === "default") {
|
|
14572
|
+
watermarkConfigString = "50$lefttop$50*#*time###25$lefttop*#*date";
|
|
14573
|
+
}
|
|
14574
|
+
const watermarks = parseWatermarks(
|
|
14575
|
+
watermarkConfigString,
|
|
14576
|
+
new Size(canvas.width, canvas.height),
|
|
14577
|
+
options.context
|
|
14578
|
+
);
|
|
14579
|
+
const groupedWatermarks = groupingWatermarks(watermarks);
|
|
14580
|
+
yield drawGroupedWatermarks(
|
|
14581
|
+
canvas,
|
|
14582
|
+
groupedWatermarks[
|
|
14583
|
+
"top"
|
|
14584
|
+
/* Top */
|
|
14585
|
+
],
|
|
14215
14586
|
"top"
|
|
14216
14587
|
/* Top */
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14588
|
+
);
|
|
14589
|
+
yield drawGroupedWatermarks(
|
|
14590
|
+
canvas,
|
|
14591
|
+
groupedWatermarks[
|
|
14592
|
+
"center"
|
|
14593
|
+
/* Center */
|
|
14594
|
+
],
|
|
14224
14595
|
"center"
|
|
14225
14596
|
/* Center */
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14597
|
+
);
|
|
14598
|
+
yield drawGroupedWatermarks(
|
|
14599
|
+
canvas,
|
|
14600
|
+
groupedWatermarks[
|
|
14601
|
+
"bottom"
|
|
14602
|
+
/* Bottom */
|
|
14603
|
+
],
|
|
14233
14604
|
"bottom"
|
|
14234
14605
|
/* Bottom */
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
);
|
|
14239
|
-
return Promise.resolve(canvas);
|
|
14606
|
+
);
|
|
14607
|
+
return Promise.resolve(canvas);
|
|
14608
|
+
});
|
|
14240
14609
|
}
|
|
14241
14610
|
function checkWatermarkConfigSupported(watermarkConfigString) {
|
|
14242
|
-
if (watermarkConfigString.indexOf("{logo}") > -1) {
|
|
14243
|
-
console.error("水印不支持logo");
|
|
14244
|
-
return false;
|
|
14245
|
-
}
|
|
14246
14611
|
const configStringArray = watermarkConfigString.split("###");
|
|
14247
14612
|
for (let i2 = 0; i2 < configStringArray.length; i2++) {
|
|
14248
14613
|
const configString = configStringArray[i2];
|
|
@@ -14258,22 +14623,139 @@
|
|
|
14258
14623
|
}
|
|
14259
14624
|
return true;
|
|
14260
14625
|
}
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14626
|
+
function file2DataURL(file) {
|
|
14627
|
+
return new Promise((resolve, reject) => {
|
|
14628
|
+
const a2 = new FileReader();
|
|
14629
|
+
a2.onload = function(res) {
|
|
14630
|
+
if (res && res.target) {
|
|
14631
|
+
resolve(res.target.result);
|
|
14632
|
+
} else {
|
|
14633
|
+
reject(new Error("读取文件url失败"));
|
|
14634
|
+
}
|
|
14635
|
+
};
|
|
14636
|
+
a2.readAsDataURL(file);
|
|
14637
|
+
});
|
|
14638
|
+
}
|
|
14639
|
+
function file2Image(file) {
|
|
14640
|
+
return new Promise((resolve, reject) => {
|
|
14641
|
+
file2DataURL(file).then((url) => {
|
|
14642
|
+
const img = new Image();
|
|
14643
|
+
img.src = url;
|
|
14644
|
+
img.onload = function() {
|
|
14645
|
+
if (img.complete) {
|
|
14646
|
+
resolve(img);
|
|
14647
|
+
} else {
|
|
14648
|
+
reject(new Error("文件加载失败"));
|
|
14649
|
+
}
|
|
14650
|
+
};
|
|
14651
|
+
}).catch(reject);
|
|
14652
|
+
});
|
|
14653
|
+
}
|
|
14654
|
+
function image2Canvas(img, type, width2, height2) {
|
|
14655
|
+
const canvas = document.createElement("canvas");
|
|
14656
|
+
const _width = width2 || img.width;
|
|
14657
|
+
const _height = height2 || img.height;
|
|
14658
|
+
canvas.width = _width;
|
|
14659
|
+
canvas.height = _height;
|
|
14660
|
+
const ctx = canvas.getContext("2d");
|
|
14661
|
+
if (ctx) {
|
|
14662
|
+
ctx.fillStyle = "transparent";
|
|
14663
|
+
if (type === "image/jpeg") {
|
|
14664
|
+
ctx.fillStyle = "#fff";
|
|
14665
|
+
}
|
|
14666
|
+
ctx.drawImage(img, 0, 0, _width, _height);
|
|
14667
|
+
return Promise.resolve(canvas);
|
|
14668
|
+
} else {
|
|
14669
|
+
return Promise.reject(null);
|
|
14670
|
+
}
|
|
14671
|
+
}
|
|
14672
|
+
function canvas2Image(canvas, type = "image/jpeg", quality = 0.8) {
|
|
14673
|
+
const image = new Image();
|
|
14674
|
+
image.src = canvas.toDataURL(type, quality);
|
|
14675
|
+
return Promise.resolve(image);
|
|
14676
|
+
}
|
|
14677
|
+
function canvas2File(canvas, fileName, lastModified, type = "image/jpeg", quality = 0.8) {
|
|
14678
|
+
return new Promise((resolve, reject) => {
|
|
14679
|
+
canvas.toBlob(
|
|
14680
|
+
(blob) => {
|
|
14681
|
+
if (!blob) {
|
|
14682
|
+
reject(new Error("canvas文件导出失败"));
|
|
14683
|
+
} else {
|
|
14684
|
+
const file = new File([blob], fileName, { lastModified, type });
|
|
14685
|
+
resolve(file);
|
|
14686
|
+
}
|
|
14687
|
+
},
|
|
14688
|
+
type,
|
|
14689
|
+
quality
|
|
14690
|
+
);
|
|
14691
|
+
});
|
|
14692
|
+
}
|
|
14693
|
+
function resize(img, {
|
|
14694
|
+
inputType = "image/jpeg",
|
|
14695
|
+
imageWidth = -1,
|
|
14696
|
+
imageHeight = -1,
|
|
14697
|
+
sideLengthLimit = 640,
|
|
14698
|
+
baseOnShortSide = true,
|
|
14699
|
+
// 是否以短边为基准缩放
|
|
14700
|
+
resultType = "image"
|
|
14701
|
+
}) {
|
|
14702
|
+
let scale = 1;
|
|
14703
|
+
const scaleBaseFunc = baseOnShortSide ? Math.min : Math.max;
|
|
14704
|
+
if (imageWidth > 0 && imageHeight > 0) {
|
|
14705
|
+
scale = sideLengthLimit / scaleBaseFunc(imageWidth, imageHeight);
|
|
14706
|
+
} else if (img.width > 0 && img.height > 0) {
|
|
14707
|
+
scale = sideLengthLimit / scaleBaseFunc(img.width, img.height);
|
|
14708
|
+
imageWidth = img.width;
|
|
14709
|
+
imageHeight = img.height;
|
|
14710
|
+
} else {
|
|
14711
|
+
return Promise.reject(new Error("image width/height 无效"));
|
|
14712
|
+
}
|
|
14713
|
+
const targetWidth = scale > 1 ? imageWidth : imageWidth * scale;
|
|
14714
|
+
const targetHeight = scale > 1 ? imageHeight : imageHeight * scale;
|
|
14715
|
+
if (resultType === "image") {
|
|
14716
|
+
return image2Canvas(img, inputType, targetWidth, targetHeight).then(
|
|
14717
|
+
(canvas) => {
|
|
14718
|
+
return canvas2Image(canvas);
|
|
14719
|
+
}
|
|
14720
|
+
);
|
|
14721
|
+
} else {
|
|
14722
|
+
return image2Canvas(img, inputType, targetWidth, targetHeight);
|
|
14723
|
+
}
|
|
14724
|
+
}
|
|
14725
|
+
var MAX_SIDE_LENGTH = 1920;
|
|
14726
|
+
var MIN_SIDE_LENGTH = 480;
|
|
14727
|
+
var PHOTO_FILE_SIZE_LIMIT = 1e3;
|
|
14728
|
+
var DEFAULT_JPEG_QUALITY = 0.8;
|
|
14729
|
+
var MIN_JPEG_QUALITY = 0.1;
|
|
14730
|
+
var JPEG_QUALITY_STEP = 0.05;
|
|
14731
|
+
var ResizeOptions = class {
|
|
14732
|
+
// 最大边长
|
|
14733
|
+
constructor(maxSideLength) {
|
|
14734
|
+
if (checkIsUndefinedOrNull(maxSideLength)) {
|
|
14735
|
+
this.maxSideLength = MAX_SIDE_LENGTH;
|
|
14736
|
+
} else {
|
|
14737
|
+
this.maxSideLength = maxSideLength;
|
|
14738
|
+
if (this.maxSideLength > MAX_SIDE_LENGTH) {
|
|
14739
|
+
this.maxSideLength = MAX_SIDE_LENGTH;
|
|
14740
|
+
} else if (this.maxSideLength < MIN_SIDE_LENGTH) {
|
|
14741
|
+
this.maxSideLength = MIN_SIDE_LENGTH;
|
|
14742
|
+
}
|
|
14743
|
+
}
|
|
14744
|
+
}
|
|
14745
|
+
};
|
|
14746
|
+
var CompressOptions = class {
|
|
14747
|
+
// 图片大小限制,单位kb
|
|
14748
|
+
constructor(photoFileSizeLimit) {
|
|
14749
|
+
if (checkIsUndefinedOrNull(photoFileSizeLimit)) {
|
|
14750
|
+
this.photoFileSizeLimit = PHOTO_FILE_SIZE_LIMIT;
|
|
14751
|
+
} else {
|
|
14752
|
+
this.photoFileSizeLimit = photoFileSizeLimit;
|
|
14753
|
+
}
|
|
14754
|
+
}
|
|
14266
14755
|
};
|
|
14267
|
-
|
|
14268
|
-
const MIN_JPEG_QUALITY = 0.1;
|
|
14269
|
-
const JPEG_QUALITY_STEP = 0.05;
|
|
14270
|
-
class ImageProcessor {
|
|
14756
|
+
var ImageProcessor = class {
|
|
14271
14757
|
// 压缩图片的配置
|
|
14272
14758
|
constructor(file, resizeOptions, watermarkOptions, compressOptions) {
|
|
14273
|
-
__publicField(this, "file");
|
|
14274
|
-
__publicField(this, "resizeOptions");
|
|
14275
|
-
__publicField(this, "watermarkOptions");
|
|
14276
|
-
__publicField(this, "compressOptions");
|
|
14277
14759
|
this.file = file;
|
|
14278
14760
|
this.resizeOptions = resizeOptions;
|
|
14279
14761
|
this.watermarkOptions = watermarkOptions;
|
|
@@ -14281,39 +14763,24 @@
|
|
|
14281
14763
|
}
|
|
14282
14764
|
process() {
|
|
14283
14765
|
const filename = this.file.name;
|
|
14284
|
-
let fileType = this.file.type;
|
|
14285
14766
|
const { lastModified } = this.file;
|
|
14286
|
-
let
|
|
14767
|
+
let fileType = this.file.type;
|
|
14287
14768
|
if (this.file.size > this.compressOptions.photoFileSizeLimit * 1024) {
|
|
14288
14769
|
fileType = "image/jpeg";
|
|
14289
14770
|
}
|
|
14290
|
-
if (isIOS$1() && fileType === "image/jpeg" && getIosVersion() < "13.4") {
|
|
14291
|
-
const reader = new FileReader();
|
|
14292
|
-
reader.readAsArrayBuffer(this.file);
|
|
14293
|
-
reader.onload = function(_ref) {
|
|
14294
|
-
const { target } = _ref;
|
|
14295
|
-
if (target == null ? void 0 : target.result) {
|
|
14296
|
-
orientation = getOrientation(target == null ? void 0 : target.result);
|
|
14297
|
-
}
|
|
14298
|
-
};
|
|
14299
|
-
}
|
|
14300
14771
|
if (fileType === "image/gif") {
|
|
14301
14772
|
fileType = "image/png";
|
|
14302
14773
|
}
|
|
14303
|
-
return file2Image(this.file).then(
|
|
14304
|
-
(img
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
|
|
14310
|
-
resultType: "canvas"
|
|
14311
|
-
})
|
|
14312
|
-
)
|
|
14313
|
-
).then((result) => {
|
|
14774
|
+
return file2Image(this.file).then((img) => {
|
|
14775
|
+
return resize(img, {
|
|
14776
|
+
inputType: fileType,
|
|
14777
|
+
sideLengthLimit: this.resizeOptions.maxSideLength,
|
|
14778
|
+
resultType: "canvas"
|
|
14779
|
+
});
|
|
14780
|
+
}).then((result) => __async$1(this, null, function* () {
|
|
14314
14781
|
const canvas = result;
|
|
14315
|
-
return renderWatermark(canvas, this.watermarkOptions);
|
|
14316
|
-
}).then((canvas) => {
|
|
14782
|
+
return yield renderWatermark(canvas, this.watermarkOptions);
|
|
14783
|
+
})).then((canvas) => {
|
|
14317
14784
|
const exportFilename = filename.replace(/\./g, "-") + ".jpg";
|
|
14318
14785
|
return this.compress(
|
|
14319
14786
|
canvas,
|
|
@@ -14335,12 +14802,13 @@
|
|
|
14335
14802
|
type,
|
|
14336
14803
|
quality - JPEG_QUALITY_STEP
|
|
14337
14804
|
);
|
|
14805
|
+
} else {
|
|
14806
|
+
return Promise.resolve(file);
|
|
14338
14807
|
}
|
|
14339
|
-
return Promise.resolve(file);
|
|
14340
14808
|
}
|
|
14341
14809
|
);
|
|
14342
14810
|
}
|
|
14343
|
-
}
|
|
14811
|
+
};
|
|
14344
14812
|
const chooseImage = (type) => {
|
|
14345
14813
|
return new Promise((resolve, reject) => {
|
|
14346
14814
|
window.wx.chooseImage({
|
|
@@ -14665,7 +15133,7 @@
|
|
|
14665
15133
|
};
|
|
14666
15134
|
const transformImageFilesWithoutCompress = (files) => {
|
|
14667
15135
|
const mediaList = files.map((file) => {
|
|
14668
|
-
return file2DataURL(file).then((base64) => {
|
|
15136
|
+
return file2DataURL$1(file).then((base64) => {
|
|
14669
15137
|
const media = {
|
|
14670
15138
|
showSrc: base64,
|
|
14671
15139
|
type: "photo",
|
|
@@ -14732,7 +15200,7 @@
|
|
|
14732
15200
|
if (!f2) {
|
|
14733
15201
|
return Promise.resolve(null);
|
|
14734
15202
|
}
|
|
14735
|
-
return file2DataURL(f2).then((base64) => {
|
|
15203
|
+
return file2DataURL$1(f2).then((base64) => {
|
|
14736
15204
|
const uniqueFileName = getUniqueFileName(f2, "jpg");
|
|
14737
15205
|
const media = {
|
|
14738
15206
|
showSrc: base64,
|
|
@@ -19099,10 +19567,10 @@
|
|
|
19099
19567
|
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
19100
19568
|
if (props.imageType === "png") {
|
|
19101
19569
|
const exportFilename2 = timestamp + ".png";
|
|
19102
|
-
return canvas2File(canvas, exportFilename2, timestamp, "image/png");
|
|
19570
|
+
return canvas2File$1(canvas, exportFilename2, timestamp, "image/png");
|
|
19103
19571
|
}
|
|
19104
19572
|
const exportFilename = timestamp + ".jpg";
|
|
19105
|
-
return canvas2File(canvas, exportFilename, timestamp);
|
|
19573
|
+
return canvas2File$1(canvas, exportFilename, timestamp);
|
|
19106
19574
|
}
|
|
19107
19575
|
return Promise.resolve(null);
|
|
19108
19576
|
})).then((results) => {
|
|
@@ -22427,7 +22895,7 @@
|
|
|
22427
22895
|
});
|
|
22428
22896
|
}
|
|
22429
22897
|
};
|
|
22430
|
-
const version = "3.1.
|
|
22898
|
+
const version = "3.1.21";
|
|
22431
22899
|
function install(app) {
|
|
22432
22900
|
const components = [
|
|
22433
22901
|
ActionSheet,
|