zartui 1.0.19 → 1.0.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/lib/zart.js CHANGED
@@ -55081,6 +55081,7 @@ __webpack_require__.d(__webpack_exports__, "Cell", function() { return /* reexpo
55081
55081
  __webpack_require__.d(__webpack_exports__, "CellGroup", function() { return /* reexport */ cell_group; });
55082
55082
  __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return /* reexport */ es_checkbox; });
55083
55083
  __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return /* reexport */ checkbox_group; });
55084
+ __webpack_require__.d(__webpack_exports__, "Circle", function() { return /* reexport */ circle; });
55084
55085
  __webpack_require__.d(__webpack_exports__, "Col", function() { return /* reexport */ col; });
55085
55086
  __webpack_require__.d(__webpack_exports__, "Collapse", function() { return /* reexport */ collapse; });
55086
55087
  __webpack_require__.d(__webpack_exports__, "CollapseItem", function() { return /* reexport */ collapse_item; });
@@ -55123,7 +55124,7 @@ __webpack_require__.d(__webpack_exports__, "Popup", function() { return /* reexp
55123
55124
  __webpack_require__.d(__webpack_exports__, "PullRefresh", function() { return /* reexport */ pull_refresh; });
55124
55125
  __webpack_require__.d(__webpack_exports__, "Radio", function() { return /* reexport */ es_radio; });
55125
55126
  __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return /* reexport */ radio_group; });
55126
- __webpack_require__.d(__webpack_exports__, "Rate", function() { return /* reexport */ rate; });
55127
+ __webpack_require__.d(__webpack_exports__, "Rate", function() { return /* reexport */ es_rate; });
55127
55128
  __webpack_require__.d(__webpack_exports__, "Row", function() { return /* reexport */ row; });
55128
55129
  __webpack_require__.d(__webpack_exports__, "Search", function() { return /* reexport */ search; });
55129
55130
  __webpack_require__.d(__webpack_exports__, "Signature", function() { return /* reexport */ signature; });
@@ -62121,6 +62122,182 @@ var checkbox_group_createNamespace = Object(utils["b" /* createNamespace */])('c
62121
62122
  }, [this.slots()]);
62122
62123
  }
62123
62124
  }));
62125
+ // CONCATENATED MODULE: ./es/circle/index.js
62126
+
62127
+
62128
+
62129
+ var circle_createNamespace = Object(utils["b" /* createNamespace */])('circle'),
62130
+ circle_createComponent = circle_createNamespace[0],
62131
+ circle_bem = circle_createNamespace[1];
62132
+
62133
+ var PERIMETER = 3140;
62134
+ var circle_uid = 0;
62135
+
62136
+ function circle_format(rate) {
62137
+ return Math.min(Math.max(rate, 0), 100);
62138
+ }
62139
+
62140
+ function getPath(clockwise, viewBoxSize) {
62141
+ var sweepFlag = clockwise ? 1 : 0;
62142
+ return "M " + viewBoxSize / 2 + " " + viewBoxSize / 2 + " m 0, -500 a 500, 500 0 1, " + sweepFlag + " 0, 1000 a 500, 500 0 1, " + sweepFlag + " 0, -1000";
62143
+ }
62144
+
62145
+ /* harmony default export */ var circle = (circle_createComponent({
62146
+ props: {
62147
+ text: String,
62148
+ size: [Number, String],
62149
+ color: [String, Object],
62150
+ layerColor: String,
62151
+ strokeLinecap: String,
62152
+ value: {
62153
+ type: Number,
62154
+ default: 0
62155
+ },
62156
+ speed: {
62157
+ type: [Number, String],
62158
+ default: 0
62159
+ },
62160
+ fill: {
62161
+ type: String,
62162
+ default: 'none'
62163
+ },
62164
+ rate: {
62165
+ type: [Number, String],
62166
+ default: 100
62167
+ },
62168
+ strokeWidth: {
62169
+ type: [Number, String],
62170
+ default: 40
62171
+ },
62172
+ clockwise: {
62173
+ type: Boolean,
62174
+ default: true
62175
+ }
62176
+ },
62177
+ beforeCreate: function beforeCreate() {
62178
+ this.uid = "zt-circle-gradient-" + circle_uid++;
62179
+ },
62180
+ computed: {
62181
+ style: function style() {
62182
+ var size = Object(utils["a" /* addUnit */])(this.size);
62183
+ return {
62184
+ width: size,
62185
+ height: size
62186
+ };
62187
+ },
62188
+ path: function path() {
62189
+ return getPath(this.clockwise, this.viewBoxSize);
62190
+ },
62191
+ viewBoxSize: function viewBoxSize() {
62192
+ return +this.strokeWidth + 1000;
62193
+ },
62194
+ layerStyle: function layerStyle() {
62195
+ return {
62196
+ fill: "" + this.fill,
62197
+ stroke: "" + this.layerColor,
62198
+ strokeWidth: this.strokeWidth + "px"
62199
+ };
62200
+ },
62201
+ hoverStyle: function hoverStyle() {
62202
+ var offset = PERIMETER * this.value / 100;
62203
+ return {
62204
+ stroke: "" + (this.gradient ? "url(#" + this.uid + ")" : this.color),
62205
+ strokeWidth: +this.strokeWidth + 1 + "px",
62206
+ strokeLinecap: this.strokeLinecap,
62207
+ strokeDasharray: offset + "px " + PERIMETER + "px"
62208
+ };
62209
+ },
62210
+ gradient: function gradient() {
62211
+ return Object(utils["g" /* isObject */])(this.color);
62212
+ },
62213
+ LinearGradient: function LinearGradient() {
62214
+ var _this = this;
62215
+
62216
+ var h = this.$createElement;
62217
+
62218
+ if (!this.gradient) {
62219
+ return;
62220
+ }
62221
+
62222
+ var Stops = Object.keys(this.color).sort(function (a, b) {
62223
+ return parseFloat(a) - parseFloat(b);
62224
+ }).map(function (key, index) {
62225
+ return h("stop", {
62226
+ "key": index,
62227
+ "attrs": {
62228
+ "offset": key,
62229
+ "stop-color": _this.color[key]
62230
+ }
62231
+ });
62232
+ });
62233
+ return h("defs", [h("linearGradient", {
62234
+ "attrs": {
62235
+ "id": this.uid,
62236
+ "x1": "100%",
62237
+ "y1": "0%",
62238
+ "x2": "0%",
62239
+ "y2": "0%"
62240
+ }
62241
+ }, [Stops])]);
62242
+ }
62243
+ },
62244
+ watch: {
62245
+ rate: {
62246
+ handler: function handler(rate) {
62247
+ this.startTime = Date.now();
62248
+ this.startRate = this.value;
62249
+ this.endRate = circle_format(rate);
62250
+ this.increase = this.endRate > this.startRate;
62251
+ this.duration = Math.abs((this.startRate - this.endRate) * 1000 / this.speed);
62252
+
62253
+ if (this.speed) {
62254
+ Object(dom_raf["a" /* cancelRaf */])(this.rafId);
62255
+ this.rafId = Object(dom_raf["c" /* raf */])(this.animate);
62256
+ } else {
62257
+ this.$emit('input', this.endRate);
62258
+ }
62259
+ },
62260
+ immediate: true
62261
+ }
62262
+ },
62263
+ methods: {
62264
+ animate: function animate() {
62265
+ var now = Date.now();
62266
+ var progress = Math.min((now - this.startTime) / this.duration, 1);
62267
+ var rate = progress * (this.endRate - this.startRate) + this.startRate;
62268
+ this.$emit('input', circle_format(parseFloat(rate.toFixed(1))));
62269
+
62270
+ if (this.increase ? rate < this.endRate : rate > this.endRate) {
62271
+ this.rafId = Object(dom_raf["c" /* raf */])(this.animate);
62272
+ }
62273
+ }
62274
+ },
62275
+ render: function render() {
62276
+ var h = arguments[0];
62277
+ return h("div", {
62278
+ "class": circle_bem(),
62279
+ "style": this.style
62280
+ }, [h("svg", {
62281
+ "attrs": {
62282
+ "viewBox": "0 0 " + this.viewBoxSize + " " + this.viewBoxSize
62283
+ }
62284
+ }, [this.LinearGradient, h("path", {
62285
+ "class": circle_bem('layer'),
62286
+ "style": this.layerStyle,
62287
+ "attrs": {
62288
+ "d": this.path
62289
+ }
62290
+ }), h("path", {
62291
+ "attrs": {
62292
+ "d": this.path
62293
+ },
62294
+ "class": circle_bem('hover'),
62295
+ "style": this.hoverStyle
62296
+ })]), this.slots() || this.text && h("div", {
62297
+ "class": circle_bem('text')
62298
+ }, [this.text])]);
62299
+ }
62300
+ }));
62124
62301
  // CONCATENATED MODULE: ./es/col/index.js
62125
62302
 
62126
62303
 
@@ -74627,1036 +74804,1272 @@ function checkIsWindows() {
74627
74804
 
74628
74805
  //# sourceMappingURL=index.js.map
74629
74806
  // CONCATENATED MODULE: ./node_modules/@egova/media/lib/watermark.js
74630
- /**
74631
- * 水印配置 {@link http://faq.egova.com.cn:7777/projects/redmine/wiki/%E6%8B%8D%E7%85%A7%E6%B0%B4%E5%8D%B0%E9%85%8D%E7%BD%AE|文档}
74632
- * @description 水印渲染类
74633
- * @author Jiaji Yin
74634
- * @date 2021-11-05
74635
- */
74636
-
74637
- var Point = /** @class */ (function () {
74638
- function Point(x, y) {
74639
- this.x = x;
74640
- this.y = y;
74641
- }
74642
- return Point;
74643
- }());
74644
- var Size = /** @class */ (function () {
74645
- function Size(width, height) {
74646
- this.width = width;
74647
- this.height = height;
74648
- }
74649
- return Size;
74650
- }());
74651
- var clamp = function (value, min, max) { return Math.min(Math.max(value, min), max); };
74652
- var subString = function (str, startIndex, length) {
74653
- if (checkIsUndefinedOrNull(length)) {
74654
- return str.substring(startIndex);
74655
- }
74656
- else {
74657
- return str.substring(startIndex, startIndex + length);
74658
- }
74659
- };
74660
- /**
74661
- * {@link http://faq.egova.com.cn:7777/files/ueditor/image/20180621/1529574697677847.png|水印位置图}
74662
- */
74663
- var WatermarkPosition;
74664
- (function (WatermarkPosition) {
74665
- WatermarkPosition["LeftTop"] = "lefttop";
74666
- WatermarkPosition["CenterTop"] = "centertop";
74667
- WatermarkPosition["RightTop"] = "righttop";
74668
- WatermarkPosition["LeftCenter"] = "leftcenter";
74669
- WatermarkPosition["Center"] = "center";
74670
- WatermarkPosition["RightCenter"] = "rightcenter";
74671
- WatermarkPosition["LeftBottom"] = "leftbottom";
74672
- WatermarkPosition["CenterBottom"] = "centerbottom";
74673
- WatermarkPosition["RightBottom"] = "rightbottom";
74674
- })(WatermarkPosition || (WatermarkPosition = {}));
74675
- var WatermarkFontWeight;
74676
- (function (WatermarkFontWeight) {
74677
- WatermarkFontWeight["Normal"] = "normal";
74678
- WatermarkFontWeight["Bold"] = "bold";
74679
- })(WatermarkFontWeight || (WatermarkFontWeight = {}));
74680
- var DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
74681
- var DEFAULT_TIME_FORMAT = "HH:mm";
74682
- var WatermarkContent;
74683
- (function (WatermarkContent) {
74684
- WatermarkContent["Raw"] = "";
74685
- WatermarkContent["Date"] = "date{(.*?)}|date";
74686
- WatermarkContent["Time"] = "time";
74687
- WatermarkContent["Address"] = "address";
74688
- WatermarkContent["HumanName"] = "humanname";
74689
- WatermarkContent["ProjectName"] = "projectName";
74690
- WatermarkContent["Logo"] = "{logo}";
74691
- })(WatermarkContent || (WatermarkContent = {}));
74692
- var ColorMap = {
74693
- "transparent": "#00000000",
74694
- "white": "#FFFFFF",
74695
- "black": "#000000",
74696
- "darkgray": "#444444",
74697
- "gray": "#888888",
74698
- "lightgray": "#CCCCCC",
74699
- "darkgrey": "#444444",
74700
- "grey": "#888888",
74701
- "lightgrey": "#CCCCCC",
74702
- "red": "#FF0000",
74703
- "green": "#00FF00",
74704
- "blue": "#0000FF",
74705
- "yellow": "#FFFF00",
74706
- "cyan": "#00FFFF",
74707
- "magenta": "#FF00FF",
74708
- "aqua": "#00FFFF",
74709
- "fuchsia": "#FF00FF",
74710
- "lime": "#00FF00",
74711
- "maroon": "#800000",
74712
- "navy": "#000080",
74713
- "olive": "#808000",
74714
- "purple": "#800080",
74715
- "silver": "#C0C0C0",
74716
- "teal": "#008080",
74717
- "orange": "#FF9933",
74718
- };
74719
- function getColorValue(key) {
74720
- for (var _i = 0, _a = Object.getOwnPropertyNames(ColorMap); _i < _a.length; _i++) {
74721
- var k = _a[_i];
74722
- if (k === key) {
74723
- return ColorMap[k];
74724
- }
74725
- }
74726
- return null;
74727
- }
74728
- var CONTENT_PADDING = 10;
74729
- var DEFAULT_PADDING = 2;
74730
- var DEFAULT_FONT_SIZE = 25.0;
74731
- var DEFAULT_CANVAS_SIZE = 480.0;
74732
- var DEFAULT_BACKGROUND_OPACITY = 128;
74733
- var WatermarkStyle = /** @class */ (function () {
74734
- /**
74735
- * Watermark Style
74736
- * @param fontName
74737
- * @param fontWeight
74738
- * @param fontColor
74739
- * @param fontSize
74740
- * @param backgroundColor
74741
- * @param backgroundOpacity
74742
- * @param paddingTop
74743
- * @param paddingBottom
74744
- * @param position
74745
- * @param scale
74746
- * @param simplified
74747
- */
74748
- function WatermarkStyle(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, simplified) {
74749
- this.fontName = fontName;
74750
- this.fontWeight = fontWeight;
74751
- this.fontColor = fontColor;
74752
- this.fontSize = fontSize;
74753
- this.backgroundColor = backgroundColor;
74754
- this.backgroundOpacity = backgroundOpacity;
74755
- this.paddingTop = paddingTop;
74756
- this.paddingBottom = paddingBottom;
74757
- this.position = position;
74758
- this.scale = scale;
74759
- this.simplified = simplified;
74760
- }
74761
- return WatermarkStyle;
74762
- }());
74763
- var WatermarkImage = /** @class */ (function () {
74764
- function WatermarkImage(image) {
74765
- this.image = image;
74766
- }
74767
- return WatermarkImage;
74768
- }());
74769
- var Watermark = /** @class */ (function () {
74770
- /**
74771
- * 水印对象,包含需要渲染的文本、图像,以及相应的style
74772
- * @param content
74773
- * @param watermarkStyle
74774
- */
74775
- function Watermark(content, watermarkStyle) {
74776
- this.content = content;
74777
- this.style = watermarkStyle;
74778
- }
74779
- return Watermark;
74780
- }());
74781
- var WatermarkContext = /** @class */ (function () {
74782
- /**
74783
- * 打水印需要的环境信息
74784
- * @param address
74785
- * @param watermarkTime
74786
- * @param humanName
74787
- * @param projectName
74788
- * @param logo
74789
- */
74790
- function WatermarkContext(params) {
74791
- this.address = params.address;
74792
- this.watermarkTime = params.watermarkTime;
74793
- this.humanName = params.humanName;
74794
- this.projectName = params.projectName;
74795
- this.logo = params.logo;
74796
- }
74797
- return WatermarkContext;
74798
- }());
74799
-
74800
- var WatermarkOptions = /** @class */ (function () {
74801
- /**
74802
- * 水印配置项
74803
- * @param enabled, 是否开启水印
74804
- * @param watermarkConfigString,水印配置的字符串
74805
- * @param context,打水印需要的环境信息
74806
- */
74807
- function WatermarkOptions(params) {
74808
- this.enabled = params.enabled;
74809
- this.watermarkConfigString = params.watermarkConfigString;
74810
- this.context = params.context;
74811
- }
74812
- return WatermarkOptions;
74813
- }());
74814
-
74815
- function parseWatermarkStyle(styleString, canvasSize) {
74816
- if (!checkIsStringValid(styleString)) {
74817
- return null;
74818
- }
74819
- var styleParts = styleString.split("$");
74820
- if (styleParts.length <= 0) {
74821
- return null;
74822
- }
74823
- var scale = Math.min(canvasSize.width, canvasSize.height) / DEFAULT_CANVAS_SIZE;
74824
- /**
74825
- 1. 20190314版本开始可以使用简化版配置,格式为[文字大小]$[水印位置]$[上下padding]*#*[水印内容] 其中[上下padding]一般不设置,如需设置,格式为"上padding_下padding",下padding可省略
74826
- 2. 简化版配置使用条件:字体(黑体)、字体样式(normal)、文字颜色(transparent)、背景颜色(transparent)、背景不透明度(128)全部使用默认值(括号中的值)
74827
- */
74828
- if (parseInteger(styleParts[0], -1) !== -1) { // 第一项为数字,则为新的简化配置
74829
- var fontSize = Math.round(parseDecimal(styleParts[0], DEFAULT_FONT_SIZE) * scale);
74830
- var position = WatermarkPosition.LeftTop;
74831
- if (styleParts[1]) {
74832
- position = styleParts[1];
74833
- }
74834
- var paddingTop = DEFAULT_PADDING * scale;
74835
- var paddingBottom = DEFAULT_PADDING * scale;
74836
- if (styleParts[2]) {
74837
- var paddingParts = styleParts[2].split("_");
74838
- paddingTop = parseInteger(paddingParts[0], DEFAULT_PADDING) * scale;
74839
- if (paddingParts[1]) {
74840
- paddingBottom = parseInteger(paddingParts[1], DEFAULT_PADDING) * scale;
74841
- }
74842
- }
74843
- var fontName = getHeitiFontFamily();
74844
- var fontWeight = WatermarkFontWeight.Normal;
74845
- var fontColor = ColorMap.transparent;
74846
- var backgroundColor = ColorMap.transparent;
74847
- var backgroundOpacity = 128;
74848
- return new WatermarkStyle(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, true);
74849
- }
74850
- else { // [字体]$[文字样式]$[文字颜色]$[文字大小]$[背景颜色]$[水印位置]$[背景不透明度]$[上下padding]*#*[水印内容]
74851
- var fontName = styleParts[0] + ', ' + getHeitiFontFamily();
74852
- var fontWeight = WatermarkFontWeight.Normal;
74853
- if (styleParts[1]) {
74854
- fontWeight = styleParts[1];
74855
- }
74856
- var fontColor = ColorMap.white;
74857
- if (styleParts[2]) {
74858
- var color = getColorValue(styleParts[2]);
74859
- if (color) {
74860
- fontColor = color;
74861
- }
74862
- }
74863
- var fontSize = Math.round(DEFAULT_FONT_SIZE * scale);
74864
- if (styleParts[3]) {
74865
- fontSize = Math.round(parseDecimal(styleParts[3], DEFAULT_FONT_SIZE) * scale);
74866
- }
74867
- var backgroundColor = ColorMap.blue;
74868
- if (styleParts[4]) {
74869
- var color = getColorValue(styleParts[4]);
74870
- if (color) {
74871
- backgroundColor = color;
74872
- }
74873
- }
74874
- var position = WatermarkPosition.LeftTop;
74875
- if (styleParts[5]) {
74876
- position = styleParts[5];
74877
- }
74878
- var backgroundOpacity = 255;
74879
- if (styleParts[6]) {
74880
- var opacity = parseInteger(styleParts[6], DEFAULT_BACKGROUND_OPACITY);
74881
- opacity = clamp(opacity, 0, 255);
74882
- backgroundOpacity = opacity;
74883
- }
74884
- var paddingTop = DEFAULT_PADDING * scale;
74885
- var paddingBottom = DEFAULT_PADDING * scale;
74886
- if (styleParts[7]) {
74887
- var paddingParts = styleParts[7].split("_");
74888
- paddingTop = parseInteger(paddingParts[0], DEFAULT_PADDING) * scale;
74889
- if (paddingParts[1]) {
74890
- paddingBottom = parseInteger(paddingParts[1], DEFAULT_PADDING) * scale;
74891
- }
74892
- }
74893
- return new WatermarkStyle(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, false);
74894
- }
74895
- }
74896
- /**
74897
- * A JavaScript Scanner like Java's
74898
- * @see java.util.Scanner
74899
- */
74900
- var watermark_TextScanner = /** @class */ (function () {
74901
- /**
74902
- * The content to scan
74903
- * @param text
74904
- */
74905
- function TextScanner(text) {
74906
- this.text = text;
74907
- this.cursor = 0;
74908
- }
74909
- TextScanner.prototype.hasNext = function (obj) {
74910
- if (checkIsUndefinedOrNull(obj)) {
74911
- return this.cursor < this.text.length;
74912
- }
74913
- else if (checkIsString(obj)) {
74914
- var str = obj;
74915
- var current = subString(this.text, this.cursor, str.length);
74916
- if (current === str) {
74917
- return true;
74918
- }
74919
- }
74920
- else if (checkIsRegExp(obj)) {
74921
- var regex = obj;
74922
- var subText = subString(this.text, this.cursor);
74923
- var matchResults = subText.match(regex);
74924
- if (matchResults) {
74925
- if (matchResults.index === 0) {
74926
- return true;
74927
- }
74928
- }
74929
- }
74930
- return false;
74931
- };
74932
- TextScanner.prototype.next = function (obj) {
74933
- if (checkIsUndefinedOrNull(obj)) {
74934
- return subString(this.text, this.cursor, 1);
74935
- }
74936
- else if (checkIsString(obj)) {
74937
- var str = obj;
74938
- if (subString(this.text, this.cursor, str.length) === str) {
74939
- return str;
74940
- }
74941
- }
74942
- else if (checkIsRegExp(obj)) {
74943
- var regex = obj;
74944
- var subText = subString(this.text, this.cursor);
74945
- var matchResults = subText.match(regex);
74946
- if (matchResults) {
74947
- if (matchResults.index === 0) {
74948
- return matchResults;
74949
- }
74950
- }
74951
- }
74952
- return null;
74953
- };
74954
- TextScanner.prototype.skip = function (obj) {
74955
- if (checkIsUndefinedOrNull(obj)) {
74956
- this.cursor += 1;
74957
- }
74958
- else if (checkIsStringValid(obj)) {
74959
- var str = obj;
74960
- this.cursor += str.length;
74961
- }
74962
- return this;
74963
- };
74964
- return TextScanner;
74965
- }());
74966
-
74967
- function buildContent(contentConfigString, watermarkContext) {
74968
- var content = "";
74969
- var scanner = new watermark_TextScanner(contentConfigString);
74970
- var steps = 0;
74971
- while (scanner.hasNext() &&
74972
- /* 防止scanner代码错误产生无限循环,设置一个最大scan步数*/
74973
- steps < contentConfigString.length) {
74974
- var dateRegex = new RegExp(WatermarkContent.Date);
74975
- if (scanner.hasNext(dateRegex)) {
74976
- var regexResult = scanner.next(dateRegex);
74977
- if (regexResult) {
74978
- var matchResults = regexResult;
74979
- var format = date_FORMAT.FORMAT_YMD;
74980
- if (matchResults && matchResults.length >= 2) {
74981
- if (checkIsStringValid(matchResults[1])) {
74982
- format = matchResults[1];
74983
- }
74984
- }
74985
- content += date_formatDate(watermarkContext.watermarkTime, format);
74986
- scanner.skip(matchResults.input);
74987
- }
74988
- }
74989
- else if (scanner.hasNext(WatermarkContent.Time)) {
74990
- var value = date_formatDate(watermarkContext.watermarkTime, date_FORMAT.FORMAT_HM);
74991
- content += value;
74992
- scanner.skip(WatermarkContent.Time);
74993
- }
74994
- else if (scanner.hasNext(WatermarkContent.Address)) {
74995
- content += watermarkContext.address;
74996
- scanner.skip(WatermarkContent.Address);
74997
- }
74998
- else if (scanner.hasNext(WatermarkContent.HumanName)) {
74999
- content += watermarkContext.humanName;
75000
- scanner.skip(WatermarkContent.HumanName);
75001
- }
75002
- else if (scanner.hasNext(WatermarkContent.ProjectName)) {
75003
- content += watermarkContext.projectName;
75004
- scanner.skip(WatermarkContent.ProjectName);
75005
- }
75006
- else if (scanner.hasNext(WatermarkContent.Logo)) {
75007
- console.error("watermark logo ignored");
75008
- scanner.skip(WatermarkContent.Logo);
75009
- }
75010
- else {
75011
- var nextChar = scanner.next();
75012
- // console.log(`next out "${nextChar}"`)
75013
- if (checkIsString(nextChar)) {
75014
- // console.log(`next in "${nextChar}"`)
75015
- content += nextChar;
75016
- }
75017
- scanner.skip();
75018
- }
75019
- steps++;
75020
- }
75021
- return content;
75022
- }
75023
- function parseWatermarks(watermarkConfigString, canvasSize, watermarkContext) {
75024
- var watermarks = [];
75025
- var configStringArray = watermarkConfigString.split("###");
75026
- for (var i = 0; i < configStringArray.length; i++) {
75027
- var configString = configStringArray[i];
75028
- //console.log('config string ' + configString);
75029
- var configParts = configString.split("*#*");
75030
- //console.log(JSON.stringify(configParts));
75031
- if (configParts.length === 2) {
75032
- var styleString = configParts[0];
75033
- var contentString = configParts[1];
75034
- var style = parseWatermarkStyle(styleString, canvasSize);
75035
- var content = buildContent(contentString, watermarkContext);
75036
- if (style && content) {
75037
- var watermark = new Watermark(content, style);
75038
- watermarks.push(watermark);
75039
- }
75040
- }
75041
- }
75042
- return watermarks;
75043
- }
75044
- /**
75045
- * 画水印默认使用黑体
75046
- * @see {@link https://www.zhihu.com/question/19911793|使用黑体}
75047
- */
75048
- function getHeitiFontFamily() {
75049
- if (checkIsAndroid()) {
75050
- return "'Roboto Black', 'Droid Sans'";
75051
- }
75052
- else if (checkIsIOS()) {
75053
- return "'PingFang SC Medium'";
75054
- }
75055
- else {
75056
- return '"PingFang SC Medium", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';
75057
- }
75058
- }
75059
- /**
75060
- * 可以渲染的内容
75061
- */
75062
- var Tile = /** @class */ (function () {
75063
- function Tile(origin, size, lineHeight, lineWidths, lines, style) {
75064
- this.origin = origin;
75065
- this.size = size;
75066
- this.lineHeight = lineHeight;
75067
- this.lineWidths = lineWidths;
75068
- this.lines = lines;
75069
- this.style = style;
75070
- }
75071
- return Tile;
75072
- }());
75073
- function buildTile(canvas, content, style) {
75074
- var origin = new Point(0, 0);
75075
- var size = new Size(0, 0);
75076
- var lines = [];
75077
- var ctx = canvas.getContext("2d");
75078
- if (!ctx) {
75079
- return null;
75080
- }
75081
- ctx.font = style.fontWeight + " " + style.fontSize + "px " + style.fontName;
75082
- var contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
75083
- var contentWidth = canvas.width - contentPadding * 2;
75084
- // @see {@link https://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas}
75085
- var lineHeight = ctx.measureText('M').width;
75086
- var lineWidths = [];
75087
- // content超过宽度就换行
75088
- var temp = "";
75089
- var lastWidth = 0;
75090
- for (var i = 0; i < content.length; i++) {
75091
- var lineWidth = ctx.measureText(temp).width;
75092
- if (lineWidth >= contentWidth) {
75093
- lines.push(temp);
75094
- lineWidths.push(lineWidth);
75095
- temp = "";
75096
- }
75097
- lastWidth = lineWidth;
75098
- temp += content[i];
75099
- }
75100
- lines.push(temp);
75101
- lineWidths.push(lastWidth);
75102
- size.width = contentWidth;
75103
- size.height = lines.length * lineHeight;
75104
- return new Tile(origin, size, lineHeight, lineWidths, lines, style);
75105
- }
75106
- /**
75107
- * 画文字,默认{@link https://stackoverflow.com/questions/43242709/how-can-i-draw-text-that-looks-embossed-using-kinetic-js-and-canvas|浮雕效果}
75108
- * @param canvas
75109
- * @param text
75110
- */
75111
- // function getEmbossTextImageData(text: string, size: Size): ImageData | null {
75112
- // // constants
75113
- // const canvas = document.createElement('canvas');
75114
- // document.body.appendChild(canvas);
75115
- // const ctx = canvas.getContext("2d");
75116
- // if (!ctx) {
75117
- // return null
75118
- // }
75119
- //
75120
- // canvas.width = size.width;
75121
- // canvas.height = size.height;
75122
- //
75123
- // // constants
75124
- // const blur = 2;
75125
- // const highLight = "rgba(100,190,256,0.75)";
75126
- // const shadow = "rgba(0,0,0,0.65)";
75127
- // const font = "84px arial black";
75128
- // const background = "linear-gradient(to right, #1e5799 0%,#3096e5 100%)";
75129
- // const border = "2px solid #6CF"
75130
- //
75131
- // // create canvas add styles and put on page
75132
- //
75133
- // const w = (canvas.width = innerWidth - 24) / 2; // set size and get centers
75134
- // const h = (canvas.height = innerHeight - 24) / 2;
75135
- // canvas.style.background = background;
75136
- // canvas.style.border = border;
75137
- //
75138
- //
75139
- // // set up font and font rendering alignment
75140
- // ctx.font = font;
75141
- // ctx.textAlign = "center";
75142
- // ctx.textBaseline = "middle";
75143
- //
75144
- // // draw dark shadow
75145
- // ctx.shadowBlur = blur; // shadow
75146
- // ctx.fillStyle = ctx.shadowColor = shadow;
75147
- // ctx.shadowOffsetY = ctx.shadowOffsetX = blur;
75148
- // ctx.fillText(text, w, h);
75149
- //
75150
- // // draw highLight
75151
- // ctx.fillStyle = ctx.shadowColor = highLight;
75152
- // ctx.shadowOffsetY = ctx.shadowOffsetX = -blur;
75153
- // ctx.fillText(text, w, h);
75154
- //
75155
- // // draw center text that removes pixels
75156
- // ctx.shadowColor = "rgba(0,0,0,0.0)"; // turn off shadow
75157
- // ctx.fillStyle = "black";
75158
- // ctx.globalCompositeOperation = "destination-out"; // New pixels will remove old pixels making them transparent
75159
- // ctx.fillText(text, w, h);
75160
- // ctx.globalCompositeOperation = "source-over"; // restore default composite operation.
75161
- //
75162
- // return ctx.getImageData(0, 0, size.width, size.height)
75163
- // }
75164
- function getAxisPoint(canvasWidth, origin, style) {
75165
- var padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
75166
- var axisPoint = new Point(padding, origin.y);
75167
- if (style.position.startsWith("center")) {
75168
- axisPoint = new Point(canvasWidth / 2, origin.y);
75169
- }
75170
- else if (style.position.startsWith("right")) {
75171
- axisPoint = new Point(canvasWidth - padding, origin.y);
75172
- }
75173
- return axisPoint;
75174
- }
75175
- function getTextAlign(style) {
75176
- var align = "left";
75177
- if (style.position.startsWith("center")) {
75178
- align = "center";
75179
- }
75180
- else if (style.position.startsWith("right")) {
75181
- align = "right";
75182
- }
75183
- return align;
75184
- }
75185
- function drawLine(canvas, line, origin, style) {
75186
- var ctx = canvas.getContext("2d");
75187
- if (!ctx) {
75188
- return;
75189
- }
75190
- /**
75191
- * The fillText's second argument is the Y coordinate for the baseline of the text (the default textBaseline is "alphabetic") ,
75192
- * so the text is being drawn above the visible canvas element when you use 0.
75193
- * @see {@link https://stackoverflow.com/questions/14289331/html5-canvas-doesnt-fill-text-at-coordinates-0-0}
75194
- */
75195
- ctx.textBaseline = "top";
75196
- ctx.font = style.fontWeight + " " + style.fontSize + "px " + style.fontName;
75197
- var axisPoint = getAxisPoint(canvas.width, origin, style);
75198
- ctx.textAlign = getTextAlign(style);
75199
- if (style.simplified) {
75200
- ctx.shadowBlur = 4; // shadow
75201
- // ctx.shadowColor = "rgba(220,220,220,0.75)";
75202
- ctx.shadowColor = "rgba(0, 0, 0, 0.5)";
75203
- var offset = clamp(style.fontSize / 40, 2, 4);
75204
- ctx.shadowOffsetY = offset;
75205
- ctx.shadowOffsetX = offset;
75206
- ctx.fillStyle = "rgba(255,255,255, 0.5)";
75207
- }
75208
- else {
75209
- ctx.fillStyle = style.fontColor;
75210
- }
75211
- ctx.fillText(line, Math.round(axisPoint.x), Math.round(axisPoint.y));
75212
- }
75213
- function hexToRGB(hex, alpha) {
75214
- var r = parseInt(hex.slice(1, 3), 16), g = parseInt(hex.slice(3, 5), 16), b = parseInt(hex.slice(5, 7), 16);
75215
- if (alpha) {
75216
- return "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")";
75217
- }
75218
- else {
75219
- return "rgb(" + r + ", " + g + ", " + b + ")";
75220
- }
75221
- }
75222
- function drawBackground(canvas, tile) {
75223
- var ctx = canvas.getContext("2d");
75224
- if (!ctx) {
75225
- return;
75226
- }
75227
- var backgroundColor = tile.style.backgroundColor;
75228
- var backgroundOpacity = parseDecimal(String(tile.style.backgroundOpacity), -1);
75229
- if (backgroundOpacity > 255) {
75230
- backgroundOpacity = 255;
75231
- }
75232
- var paddingTop = 2;
75233
- var paddingBottom = 10;
75234
- if (backgroundColor !== 'transparent') {
75235
- if (backgroundColor.startsWith("#") && backgroundOpacity >= 0) {
75236
- backgroundColor = hexToRGB(backgroundColor, backgroundOpacity / 255.0);
75237
- }
75238
- ctx.fillStyle = backgroundColor;
75239
- var style = tile.style;
75240
- var padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
75241
- var paddingScale = tile.style.fontSize / DEFAULT_FONT_SIZE;
75242
- for (var j = 0; j < tile.lineWidths.length; j++) {
75243
- var lineHeight = tile.lineHeight;
75244
- var lineWidth = tile.lineWidths[j];
75245
- var paddingRight = 30 * paddingScale;
75246
- var paddingLeft = 10 * paddingScale;
75247
- var axisPoint = new Point(padding - paddingLeft, tile.origin.y);
75248
- if (style.position.startsWith("center")) {
75249
- paddingLeft = 20 * paddingScale;
75250
- paddingRight = 20 * paddingScale;
75251
- axisPoint = new Point((canvas.width - lineWidth) / 2 - paddingLeft, tile.origin.y);
75252
- }
75253
- else if (style.position.startsWith("right")) {
75254
- paddingLeft = 30 * paddingScale;
75255
- paddingRight = 10 * paddingScale;
75256
- axisPoint = new Point(canvas.width - lineWidth - padding - paddingLeft, tile.origin.y);
75257
- }
75258
- // padding top
75259
- if (j === 0) {
75260
- ctx.fillRect(axisPoint.x, (axisPoint.y - paddingTop > 0) ? (axisPoint.y - paddingTop) : 0, paddingLeft + lineWidth + paddingRight, paddingTop);
75261
- }
75262
- ctx.fillRect(axisPoint.x, axisPoint.y + j * lineHeight, paddingLeft + lineWidth + paddingRight, lineHeight);
75263
- // padding bottom
75264
- if (j === tile.lineWidths.length - 1) {
75265
- ctx.fillRect(axisPoint.x, axisPoint.y + (j + 1) * lineHeight, paddingLeft + lineWidth + paddingRight, paddingBottom);
75266
- }
75267
- }
75268
- }
75269
- }
75270
- function drawTile(canvas, tile) {
75271
- if (!tile.style.simplified) { // 复杂配置绘制背景颜色
75272
- drawBackground(canvas, tile);
75273
- }
75274
- for (var i = 0; i < tile.lines.length; i++) {
75275
- var origin_1 = new Point(tile.origin.x, i * tile.lineHeight + tile.origin.y);
75276
- drawLine(canvas, tile.lines[i], origin_1, tile.style);
75277
- }
75278
- }
75279
- function getCanvasScale(canvas, len) {
75280
- var min = Math.min(canvas.width, canvas.height);
75281
- return min / DEFAULT_CANVAS_SIZE * len;
75282
- }
75283
- var GroupPosition;
75284
- (function (GroupPosition) {
75285
- GroupPosition["Top"] = "top";
75286
- GroupPosition["Center"] = "center";
75287
- GroupPosition["Bottom"] = "bottom";
75288
- })(GroupPosition || (GroupPosition = {}));
75289
- function drawGroupedWatermarks(canvas, watermarks, groupPosition) {
75290
- if (!watermarks || watermarks.length === 0) {
75291
- return;
75292
- }
75293
- var tiles = [];
75294
- //NOTE: 每个watermark 都占满整个宽度,一行只放一个watermark
75295
- var totalHeight = 0;
75296
- for (var i = 0; i < watermarks.length; i++) {
75297
- var watermark = watermarks[i];
75298
- var tile = buildTile(canvas, watermark.content, watermark.style);
75299
- if (tile) {
75300
- tiles.push(tile);
75301
- totalHeight += tile.size.height;
75302
- }
75303
- }
75304
- if (totalHeight <= 0) {
75305
- // no need draw
75306
- console.error('watermarks height ' + totalHeight);
75307
- console.error(JSON.stringify(watermarks));
75308
- return;
75309
- }
75310
- var contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
75311
- var baseOrigin = new Point(contentPadding, contentPadding);
75312
- if (groupPosition === GroupPosition.Center) {
75313
- baseOrigin = new Point(contentPadding, Math.round((canvas.height - totalHeight) / 2));
75314
- }
75315
- else if (groupPosition === GroupPosition.Bottom) {
75316
- baseOrigin = new Point(contentPadding, canvas.height - totalHeight - contentPadding);
75317
- }
75318
- else if (groupPosition === GroupPosition.Top) {
75319
- baseOrigin = new Point(contentPadding, contentPadding);
75320
- }
75321
- // update all the tiles' origin
75322
- var lastMarginTop = 0;
75323
- for (var i = 0; i < tiles.length; i++) {
75324
- var tile = tiles[i];
75325
- lastMarginTop += tile.style.paddingTop;
75326
- tile.origin = new Point(tile.origin.x + baseOrigin.x, lastMarginTop + baseOrigin.y);
75327
- lastMarginTop += tile.size.height;
75328
- lastMarginTop += tile.style.paddingBottom;
75329
- }
75330
- // draw all tiles
75331
- for (var i = 0; i < tiles.length; i++) {
75332
- var tile = tiles[i];
75333
- drawTile(canvas, tile);
75334
- }
75335
- }
75336
- /**
75337
- * 把watermark 分为 上、中、三组
75338
- * @param watermarks
75339
- */
75340
- function groupingWatermarks(watermarks) {
75341
- var _a;
75342
- var topList = [];
75343
- var centerList = [];
75344
- var bottomList = [];
75345
- for (var i = 0; i < watermarks.length; i++) {
75346
- var watermark = watermarks[i];
75347
- if (watermark.style.position.endsWith("top")) {
75348
- topList.push(watermark);
75349
- }
75350
- else if (watermark.style.position.endsWith("center")) {
75351
- centerList.push(watermark);
75352
- }
75353
- else if (watermark.style.position.endsWith("bottom")) {
75354
- bottomList.push(watermark);
75355
- }
75356
- }
75357
- return _a = {},
75358
- _a[GroupPosition.Top] = topList,
75359
- _a[GroupPosition.Center] = centerList,
75360
- _a[GroupPosition.Bottom] = bottomList,
75361
- _a;
75362
- }
75363
- function renderWatermark(canvas, options) {
75364
- // console.log("canvas width " + canvas.width);
75365
- // console.log("canvas height " + canvas.height);
75366
- if (!options.enabled || options.watermarkConfigString === "no") {
75367
- return Promise.resolve(canvas);
75368
- }
75369
- var watermarkConfigString = options.watermarkConfigString;
75370
- if (watermarkConfigString === "default") {
75371
- watermarkConfigString = "50$lefttop$50*#*time###25$lefttop*#*date";
75372
- }
75373
- var watermarks = parseWatermarks(watermarkConfigString, new Size(canvas.width, canvas.height), options.context);
75374
- var groupedWatermarks = groupingWatermarks(watermarks);
75375
- drawGroupedWatermarks(canvas, groupedWatermarks[GroupPosition.Top], GroupPosition.Top);
75376
- drawGroupedWatermarks(canvas, groupedWatermarks[GroupPosition.Center], GroupPosition.Center);
75377
- drawGroupedWatermarks(canvas, groupedWatermarks[GroupPosition.Bottom], GroupPosition.Bottom);
75378
- return Promise.resolve(canvas);
75379
- }
75380
- function checkWatermarkConfigSupported(watermarkConfigString) {
75381
- if (watermarkConfigString.indexOf("{logo}") > -1) {
75382
- console.error("水印不支持logo");
75383
- return false;
75384
- }
75385
- var configStringArray = watermarkConfigString.split("###");
75386
- for (var i = 0; i < configStringArray.length; i++) {
75387
- var configString = configStringArray[i];
75388
- //console.log('config string ' + configString);
75389
- var configParts = configString.split("*#*");
75390
- //console.log(JSON.stringify(configParts));
75391
- if (configParts.length === 2) {
75392
- var styleString = configParts[0];
75393
- var styleParts = styleString.split("$");
75394
- if (styleParts.length <= 0) {
75395
- console.error("水印配置不合法");
75396
- return false;
75397
- }
75398
- }
75399
- }
75400
- return true;
75401
- }
75402
- //# sourceMappingURL=watermark.js.map
75403
- // CONCATENATED MODULE: ./node_modules/@egova/media/lib/image-util.js
75404
- /**
75405
- * Convert File to data schema url
75406
- * @param file
75407
- */
75408
- function file2DataURL(file) {
75409
- return new Promise(function (resolve, reject) {
75410
- var a = new FileReader();
75411
- a.onload = function (res) {
75412
- if (res && res.target) {
75413
- resolve(res.target.result);
75414
- }
75415
- else {
75416
- reject(new Error('读取文件url失败'));
75417
- }
75418
- };
75419
- a.readAsDataURL(file);
75420
- });
75421
- }
75422
- /**
75423
- * Convert file to image
75424
- * @param file
75425
- */
75426
- function file2Image(file) {
75427
- return new Promise(function (resolve, reject) {
75428
- file2DataURL(file).then(function (url) {
75429
- var img = new Image();
75430
- img.src = url;
75431
- img.onload = function (e) {
75432
- if (img.complete) {
75433
- resolve(img);
75434
- }
75435
- else {
75436
- reject(new Error('文件加载失败'));
75437
- }
75438
- };
75439
- }).catch(reject);
75440
- });
75441
- }
75442
- function image2file(img, fileName, lastModified, type, quality) {
75443
- if (type === void 0) { type = "image/jpeg"; }
75444
- if (quality === void 0) { quality = 0.8; }
75445
- return image2Canvas(img, type).then(function (canvas) {
75446
- return canvas2File(canvas, fileName, lastModified, type, quality);
75447
- });
75448
- }
75449
- /**
75450
- * Draw image on canvas
75451
- * @param img
75452
- * @param width
75453
- * @param height
75454
- */
75455
- function image2Canvas(img, type, width, height) {
75456
- var canvas = document.createElement('canvas');
75457
- if (!width) {
75458
- width = img.width;
75459
- }
75460
- if (!height) {
75461
- height = img.height;
75462
- }
75463
- canvas.width = width;
75464
- canvas.height = height;
75465
- var ctx = canvas.getContext('2d');
75466
- if (ctx) {
75467
- // png经canvas.toDataURL转换后背景变成黑色,这里提前填充白色
75468
- ctx.fillStyle = 'transparent';
75469
- if (type === 'image/jpeg') {
75470
- ctx.fillStyle = '#fff';
75471
- }
75472
- ctx.drawImage(img, 0, 0, width, height);
75473
- return Promise.resolve(canvas);
75474
- }
75475
- else {
75476
- return Promise.reject(null);
75477
- }
75478
- }
75479
- /**
75480
- * Export Image from canvas
75481
- * @param canvas
75482
- * @param type
75483
- * @param quality
75484
- * @see {@link https://meshworld.in/convert-canvas-to-an-image-using-javascript/}
75485
- */
75486
- function canvas2Image(canvas, type, quality) {
75487
- if (type === void 0) { type = "image/jpeg"; }
75488
- if (quality === void 0) { quality = 0.8; }
75489
- var image = new Image();
75490
- image.src = canvas.toDataURL(type, quality);
75491
- return Promise.resolve(image);
75492
- }
75493
- /**
75494
- * Export File from canvas
75495
- * @param canvas
75496
- * @param fileName
75497
- * @param lastModified
75498
- * @param type
75499
- * @param quality
75500
- * @see {@link https://meshworld.in/convert-canvas-to-an-image-using-javascript/}
75501
- */
75502
- function canvas2File(canvas, fileName, lastModified, type, quality) {
75503
- if (type === void 0) { type = "image/jpeg"; }
75504
- if (quality === void 0) { quality = 0.8; }
75505
- return new Promise(function (resolve, reject) {
75506
- canvas.toBlob(function (blob) {
75507
- if (!blob) {
75508
- reject(new Error('canvas文件导出失败'));
75509
- }
75510
- else {
75511
- var file = new File([blob], fileName, { lastModified: lastModified, type: type });
75512
- // console.log("file size " + file.size / 1024 + "kb");
75513
- // console.log(file)
75514
- resolve(file);
75515
- }
75516
- }, type, quality);
75517
- });
75518
- }
75519
- /**
75520
- * 缩放图片
75521
- * @param img:HTMLImageElement 图片对象
75522
- * @param inputType 图片类型
75523
- * @param imageWidth 图片宽度
75524
- * @param imageHeight 图片高度
75525
- * @param equalProportion 是否等比例拉伸,默认是,目前只支持等比例拉伸
75526
- * @param sideLengthLimit 图片边长限制
75527
- * @param baseOnShortSide 是否以短边为限制
75528
- * @param resultType: ResizeResultType, "image" | "canvas"
75529
- */
75530
- function resize(img, _a) {
75531
- var _b = _a.inputType, inputType = _b === void 0 ? 'image/jpeg' : _b, _c = _a.imageWidth, imageWidth = _c === void 0 ? -1 : _c, _d = _a.imageHeight, imageHeight = _d === void 0 ? -1 : _d, _e = _a.equalProportion, equalProportion = _e === void 0 ? true : _e, //等比例拉伸
75532
- _f = _a.sideLengthLimit, //等比例拉伸
75533
- sideLengthLimit = _f === void 0 ? 640 : _f, _g = _a.baseOnShortSide, baseOnShortSide = _g === void 0 ? true : _g, // 是否以短边为基准缩放
75534
- _h = _a.resultType, // 是否以短边为基准缩放
75535
- resultType = _h === void 0 ? "image" : _h;
75536
- var scale = 1;
75537
- var scaleBaseFunc = baseOnShortSide ? Math.min : Math.max;
75538
- if (imageWidth > 0 && imageHeight > 0) {
75539
- scale = sideLengthLimit / scaleBaseFunc(imageWidth, imageHeight);
75540
- }
75541
- else if (img.width > 0 && img.height > 0) {
75542
- scale = sideLengthLimit / scaleBaseFunc(img.width, img.height);
75543
- imageWidth = img.width;
75544
- imageHeight = img.height;
75545
- }
75546
- else {
75547
- return Promise.reject(new Error('image width/height 无效'));
75548
- }
75549
- var targetWidth = scale > 1 ? imageWidth : imageWidth * scale;
75550
- var targetHeight = scale > 1 ? imageHeight : imageHeight * scale;
75551
- if (resultType === "image") {
75552
- return image2Canvas(img, inputType, targetWidth, targetHeight).then(function (canvas) {
75553
- return canvas2Image(canvas);
75554
- });
75555
- }
75556
- else {
75557
- return image2Canvas(img, inputType, targetWidth, targetHeight);
75558
- }
75559
- }
75560
- //# sourceMappingURL=image-util.js.map
74807
+ /**
74808
+ * 水印配置 {@link http://faq.egova.com.cn:7777/projects/redmine/wiki/%E6%8B%8D%E7%85%A7%E6%B0%B4%E5%8D%B0%E9%85%8D%E7%BD%AE|文档}
74809
+ * @description 水印渲染类
74810
+ * @author Jiaji Yin
74811
+ * @date 2021-11-05
74812
+ */
74813
+ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
74814
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
74815
+ return new (P || (P = Promise))(function (resolve, reject) {
74816
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
74817
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
74818
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
74819
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
74820
+ });
74821
+ };
74822
+ var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
74823
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
74824
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
74825
+ function verb(n) { return function (v) { return step([n, v]); }; }
74826
+ function step(op) {
74827
+ if (f) throw new TypeError("Generator is already executing.");
74828
+ while (_) try {
74829
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
74830
+ if (y = 0, t) op = [op[0] & 2, t.value];
74831
+ switch (op[0]) {
74832
+ case 0: case 1: t = op; break;
74833
+ case 4: _.label++; return { value: op[1], done: false };
74834
+ case 5: _.label++; y = op[1]; op = [0]; continue;
74835
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
74836
+ default:
74837
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
74838
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
74839
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
74840
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
74841
+ if (t[2]) _.ops.pop();
74842
+ _.trys.pop(); continue;
74843
+ }
74844
+ op = body.call(thisArg, _);
74845
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
74846
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
74847
+ }
74848
+ };
74849
+
74850
+ var WatermarkImageEnum;
74851
+ (function (WatermarkImageEnum) {
74852
+ WatermarkImageEnum[WatermarkImageEnum["POSITION_LEFT"] = 0] = "POSITION_LEFT";
74853
+ WatermarkImageEnum[WatermarkImageEnum["POSITION_RIGHT"] = 1] = "POSITION_RIGHT";
74854
+ })(WatermarkImageEnum || (WatermarkImageEnum = {}));
74855
+ var Point = /** @class */ (function () {
74856
+ function Point(x, y) {
74857
+ this.x = x;
74858
+ this.y = y;
74859
+ }
74860
+ return Point;
74861
+ }());
74862
+ var Size = /** @class */ (function () {
74863
+ function Size(width, height) {
74864
+ this.width = width;
74865
+ this.height = height;
74866
+ }
74867
+ return Size;
74868
+ }());
74869
+ var clamp = function (value, min, max) {
74870
+ return Math.min(Math.max(value, min), max);
74871
+ };
74872
+ var subString = function (str, startIndex, length) {
74873
+ if (checkIsUndefinedOrNull(length)) {
74874
+ return str.substring(startIndex);
74875
+ }
74876
+ else {
74877
+ return str.substring(startIndex, startIndex + length);
74878
+ }
74879
+ };
74880
+ /**
74881
+ * {@link http://faq.egova.com.cn:7777/files/ueditor/image/20180621/1529574697677847.png|水印位置图}
74882
+ */
74883
+ var WatermarkPosition;
74884
+ (function (WatermarkPosition) {
74885
+ WatermarkPosition["LeftTop"] = "lefttop";
74886
+ WatermarkPosition["CenterTop"] = "centertop";
74887
+ WatermarkPosition["RightTop"] = "righttop";
74888
+ WatermarkPosition["LeftCenter"] = "leftcenter";
74889
+ WatermarkPosition["Center"] = "center";
74890
+ WatermarkPosition["RightCenter"] = "rightcenter";
74891
+ WatermarkPosition["LeftBottom"] = "leftbottom";
74892
+ WatermarkPosition["CenterBottom"] = "centerbottom";
74893
+ WatermarkPosition["RightBottom"] = "rightbottom";
74894
+ })(WatermarkPosition || (WatermarkPosition = {}));
74895
+ var WatermarkFontWeight;
74896
+ (function (WatermarkFontWeight) {
74897
+ WatermarkFontWeight["Normal"] = "normal";
74898
+ WatermarkFontWeight["Bold"] = "bold";
74899
+ })(WatermarkFontWeight || (WatermarkFontWeight = {}));
74900
+ var DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
74901
+ var DEFAULT_TIME_FORMAT = "HH:mm";
74902
+ var WatermarkContent;
74903
+ (function (WatermarkContent) {
74904
+ WatermarkContent["Raw"] = "";
74905
+ WatermarkContent["Date"] = "date{(.*?)}|date";
74906
+ WatermarkContent["Time"] = "time";
74907
+ WatermarkContent["Address"] = "address";
74908
+ WatermarkContent["HumanName"] = "humanname";
74909
+ WatermarkContent["ProjectName"] = "projectName";
74910
+ WatermarkContent["ApplicationName"] = "applicationName";
74911
+ })(WatermarkContent || (WatermarkContent = {}));
74912
+ var ColorMap = {
74913
+ transparent: "#00000000",
74914
+ white: "#FFFFFF",
74915
+ black: "#000000",
74916
+ darkgray: "#444444",
74917
+ gray: "#888888",
74918
+ lightgray: "#CCCCCC",
74919
+ darkgrey: "#444444",
74920
+ grey: "#888888",
74921
+ lightgrey: "#CCCCCC",
74922
+ red: "#FF0000",
74923
+ green: "#00FF00",
74924
+ blue: "#0000FF",
74925
+ yellow: "#FFFF00",
74926
+ cyan: "#00FFFF",
74927
+ magenta: "#FF00FF",
74928
+ aqua: "#00FFFF",
74929
+ fuchsia: "#FF00FF",
74930
+ lime: "#00FF00",
74931
+ maroon: "#800000",
74932
+ navy: "#000080",
74933
+ olive: "#808000",
74934
+ purple: "#800080",
74935
+ silver: "#C0C0C0",
74936
+ teal: "#008080",
74937
+ orange: "#FF9933",
74938
+ };
74939
+ function getColorValue(key) {
74940
+ for (var _i = 0, _a = Object.getOwnPropertyNames(ColorMap); _i < _a.length; _i++) {
74941
+ var k = _a[_i];
74942
+ if (k === key) {
74943
+ return ColorMap[k];
74944
+ }
74945
+ }
74946
+ return null;
74947
+ }
74948
+ var CONTENT_PADDING = 10;
74949
+ var DEFAULT_PADDING = 2;
74950
+ var DEFAULT_FONT_SIZE = 25.0;
74951
+ var DEFAULT_CANVAS_SIZE = 480.0;
74952
+ var DEFAULT_BACKGROUND_OPACITY = 128;
74953
+ var WatermarkStyle = /** @class */ (function () {
74954
+ /**
74955
+ * Watermark Style
74956
+ * @param fontName
74957
+ * @param fontWeight
74958
+ * @param fontColor
74959
+ * @param fontSize
74960
+ * @param backgroundColor
74961
+ * @param backgroundOpacity
74962
+ * @param paddingTop
74963
+ * @param paddingBottom
74964
+ * @param position
74965
+ * @param scale
74966
+ * @param simplified
74967
+ */
74968
+ function WatermarkStyle(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, simplified) {
74969
+ this.fontName = fontName;
74970
+ this.fontWeight = fontWeight;
74971
+ this.fontColor = fontColor;
74972
+ this.fontSize = fontSize;
74973
+ this.backgroundColor = backgroundColor;
74974
+ this.backgroundOpacity = backgroundOpacity;
74975
+ this.paddingTop = paddingTop;
74976
+ this.paddingBottom = paddingBottom;
74977
+ this.position = position;
74978
+ this.scale = scale;
74979
+ this.simplified = simplified;
74980
+ }
74981
+ return WatermarkStyle;
74982
+ }());
74983
+ var WatermarkImage = /** @class */ (function () {
74984
+ function WatermarkImage(image, width, height, position) {
74985
+ if (image === void 0) { image = ""; }
74986
+ if (width === void 0) { width = 20; }
74987
+ if (height === void 0) { height = 20; }
74988
+ if (position === void 0) { position = WatermarkImageEnum.POSITION_LEFT; }
74989
+ this.image = image;
74990
+ this.width = width;
74991
+ this.height = height;
74992
+ this.position = position;
74993
+ }
74994
+ return WatermarkImage;
74995
+ }());
74996
+ var Watermark = /** @class */ (function () {
74997
+ /**
74998
+ * 水印对象,包含需要渲染的文本、图像,以及相应的style
74999
+ * @param content
75000
+ * @param watermarkStyle
75001
+ */
75002
+ function Watermark(content, watermarkStyle, watermarkImage) {
75003
+ this.content = content;
75004
+ this.style = watermarkStyle;
75005
+ this.watermarkImage = watermarkImage;
75006
+ }
75007
+ return Watermark;
75008
+ }());
75009
+ var WatermarkContext = /** @class */ (function () {
75010
+ /**
75011
+ * 打水印需要的环境信息
75012
+ * @param address
75013
+ * @param watermarkTime
75014
+ * @param humanName
75015
+ * @param projectName
75016
+ * @param logo
75017
+ */
75018
+ function WatermarkContext(params) {
75019
+ this.address = params.address;
75020
+ this.watermarkTime = params.watermarkTime;
75021
+ this.humanName = params.humanName;
75022
+ this.projectName = params.projectName;
75023
+ this.logo = params.logo;
75024
+ this.applicationName = params.applicationName;
75025
+ }
75026
+ return WatermarkContext;
75027
+ }());
75028
+
75029
+ var WatermarkOptions = /** @class */ (function () {
75030
+ /**
75031
+ * 水印配置项
75032
+ * @param enabled, 是否开启水印
75033
+ * @param watermarkConfigString,水印配置的字符串
75034
+ * @param context,打水印需要的环境信息
75035
+ */
75036
+ function WatermarkOptions(params) {
75037
+ this.enabled = params.enabled;
75038
+ this.watermarkConfigString = params.watermarkConfigString;
75039
+ this.context = params.context;
75040
+ }
75041
+ return WatermarkOptions;
75042
+ }());
75043
+
75044
+ /**
75045
+ * 画水印默认使用黑体
75046
+ * @see {@link https://www.zhihu.com/question/19911793|使用黑体}
75047
+ */
75048
+ function getHeitiFontFamily() {
75049
+ if (checkIsAndroid()) {
75050
+ return "'Roboto Black', 'Droid Sans'";
75051
+ }
75052
+ else if (checkIsIOS()) {
75053
+ return "'PingFang SC Medium'";
75054
+ }
75055
+ else {
75056
+ return '"PingFang SC Medium", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';
75057
+ }
75058
+ }
75059
+ function parseWatermarkStyle(styleString, canvasSize) {
75060
+ if (!checkIsStringValid(styleString)) {
75061
+ return null;
75062
+ }
75063
+ var styleParts = styleString.split("$");
75064
+ if (styleParts.length <= 0) {
75065
+ return null;
75066
+ }
75067
+ var scale = Math.min(canvasSize.width, canvasSize.height) / DEFAULT_CANVAS_SIZE;
75068
+ /**
75069
+ 1. 20190314版本开始可以使用简化版配置,格式为[文字大小]$[水印位置]$[上下padding]*#*[水印内容] 其中[上下padding]一般不设置,如需设置,格式为"上padding_下padding",下padding可省略
75070
+ 2. 简化版配置使用条件:字体(黑体)、字体样式(normal)、文字颜色(transparent)、背景颜色(transparent)、背景不透明度(128)全部使用默认值(括号中的值)
75071
+ */
75072
+ if (parseInteger(styleParts[0], -1) !== -1) {
75073
+ // 第一项为数字,则为新的简化配置
75074
+ var fontSize = Math.round(parseDecimal(styleParts[0], DEFAULT_FONT_SIZE) * scale);
75075
+ var position = WatermarkPosition.LeftTop;
75076
+ if (styleParts[1]) {
75077
+ position = styleParts[1];
75078
+ }
75079
+ var paddingTop = DEFAULT_PADDING * scale;
75080
+ var paddingBottom = DEFAULT_PADDING * scale;
75081
+ if (styleParts[2]) {
75082
+ var paddingParts = styleParts[2].split("_");
75083
+ paddingTop = parseInteger(paddingParts[0], DEFAULT_PADDING) * scale;
75084
+ if (paddingParts[1]) {
75085
+ paddingBottom = parseInteger(paddingParts[1], DEFAULT_PADDING) * scale;
75086
+ }
75087
+ }
75088
+ var fontName = getHeitiFontFamily();
75089
+ var fontWeight = WatermarkFontWeight.Normal;
75090
+ var fontColor = ColorMap.transparent;
75091
+ var backgroundColor = ColorMap.transparent;
75092
+ var backgroundOpacity = 128;
75093
+ return new WatermarkStyle(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, true);
75094
+ }
75095
+ else {
75096
+ // [字体]$[文字样式]$[文字颜色]$[文字大小]$[背景颜色]$[水印位置]$[背景不透明度]$[上下padding]*#*[水印内容]
75097
+ var fontName = styleParts[0] + ", " + getHeitiFontFamily();
75098
+ var fontWeight = WatermarkFontWeight.Normal;
75099
+ if (styleParts[1]) {
75100
+ fontWeight = styleParts[1];
75101
+ }
75102
+ var fontColor = ColorMap.white;
75103
+ if (styleParts[2]) {
75104
+ var color = getColorValue(styleParts[2]);
75105
+ if (color) {
75106
+ fontColor = color;
75107
+ }
75108
+ }
75109
+ var fontSize = Math.round(DEFAULT_FONT_SIZE * scale);
75110
+ if (styleParts[3]) {
75111
+ fontSize = Math.round(parseDecimal(styleParts[3], DEFAULT_FONT_SIZE) * scale);
75112
+ }
75113
+ var backgroundColor = ColorMap.blue;
75114
+ if (styleParts[4]) {
75115
+ var color = getColorValue(styleParts[4]);
75116
+ if (color) {
75117
+ backgroundColor = color;
75118
+ }
75119
+ }
75120
+ var position = WatermarkPosition.LeftTop;
75121
+ if (styleParts[5]) {
75122
+ position = styleParts[5];
75123
+ }
75124
+ var backgroundOpacity = 255;
75125
+ if (styleParts[6]) {
75126
+ var opacity = parseInteger(styleParts[6], DEFAULT_BACKGROUND_OPACITY);
75127
+ opacity = clamp(opacity, 0, 255);
75128
+ backgroundOpacity = opacity;
75129
+ }
75130
+ var paddingTop = DEFAULT_PADDING * scale;
75131
+ var paddingBottom = DEFAULT_PADDING * scale;
75132
+ if (styleParts[7]) {
75133
+ var paddingParts = styleParts[7].split("_");
75134
+ paddingTop = parseInteger(paddingParts[0], DEFAULT_PADDING) * scale;
75135
+ if (paddingParts[1]) {
75136
+ paddingBottom = parseInteger(paddingParts[1], DEFAULT_PADDING) * scale;
75137
+ }
75138
+ }
75139
+ return new WatermarkStyle(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, false);
75140
+ }
75141
+ }
75142
+ /**
75143
+ * A JavaScript Scanner like Java's
75144
+ * @see java.util.Scanner
75145
+ */
75146
+ var watermark_TextScanner = /** @class */ (function () {
75147
+ /**
75148
+ * The content to scan
75149
+ * @param text
75150
+ */
75151
+ function TextScanner(text) {
75152
+ this.text = text;
75153
+ this.cursor = 0;
75154
+ }
75155
+ TextScanner.prototype.hasNext = function (obj) {
75156
+ if (checkIsUndefinedOrNull(obj)) {
75157
+ return this.cursor < this.text.length;
75158
+ }
75159
+ else if (checkIsString(obj)) {
75160
+ var str = obj;
75161
+ var current = subString(this.text, this.cursor, str.length);
75162
+ if (current === str) {
75163
+ return true;
75164
+ }
75165
+ }
75166
+ else if (checkIsRegExp(obj)) {
75167
+ var regex = obj;
75168
+ var subText = subString(this.text, this.cursor);
75169
+ var matchResults = subText.match(regex);
75170
+ if (matchResults) {
75171
+ if (matchResults.index === 0) {
75172
+ return true;
75173
+ }
75174
+ }
75175
+ }
75176
+ return false;
75177
+ };
75178
+ TextScanner.prototype.next = function (obj) {
75179
+ if (checkIsUndefinedOrNull(obj)) {
75180
+ return subString(this.text, this.cursor, 1);
75181
+ }
75182
+ else if (checkIsString(obj)) {
75183
+ var str = obj;
75184
+ if (subString(this.text, this.cursor, str.length) === str) {
75185
+ return str;
75186
+ }
75187
+ }
75188
+ else if (checkIsRegExp(obj)) {
75189
+ var regex = obj;
75190
+ var subText = subString(this.text, this.cursor);
75191
+ var matchResults = subText.match(regex);
75192
+ if (matchResults) {
75193
+ if (matchResults.index === 0) {
75194
+ return matchResults;
75195
+ }
75196
+ }
75197
+ }
75198
+ return null;
75199
+ };
75200
+ TextScanner.prototype.skip = function (obj) {
75201
+ if (checkIsUndefinedOrNull(obj)) {
75202
+ this.cursor += 1;
75203
+ }
75204
+ else if (checkIsStringValid(obj)) {
75205
+ var str = obj;
75206
+ this.cursor += str.length;
75207
+ }
75208
+ return this;
75209
+ };
75210
+ return TextScanner;
75211
+ }());
75212
+
75213
+ function buildContent(contentConfigString, watermarkContext, style) {
75214
+ var content = "";
75215
+ var watermarkImage = new WatermarkImage();
75216
+ if (contentConfigString.includes("{logo")) {
75217
+ var start = contentConfigString.indexOf("{logo");
75218
+ var end = contentConfigString.indexOf("}", start);
75219
+ if (end != -1) {
75220
+ var logoConfigWithBrace = contentConfigString.substring(start, end + 1);
75221
+ if (contentConfigString.startsWith(logoConfigWithBrace) ||
75222
+ contentConfigString.endsWith(logoConfigWithBrace)) {
75223
+ if (contentConfigString.startsWith(logoConfigWithBrace)) {
75224
+ watermarkImage.position = WatermarkImageEnum.POSITION_LEFT;
75225
+ }
75226
+ else {
75227
+ watermarkImage.position = WatermarkImageEnum.POSITION_RIGHT;
75228
+ }
75229
+ var imgWidthHeight = (style === null || style === void 0 ? void 0 : style.fontSize) || 20;
75230
+ watermarkImage.image = watermarkContext.logo;
75231
+ watermarkImage.height = imgWidthHeight;
75232
+ watermarkImage.width = imgWidthHeight;
75233
+ }
75234
+ var applicationName = contentConfigString.replace(logoConfigWithBrace, "");
75235
+ if (applicationName) {
75236
+ content = watermarkContext.applicationName;
75237
+ }
75238
+ }
75239
+ }
75240
+ else {
75241
+ var scanner = new watermark_TextScanner(contentConfigString);
75242
+ var steps = 0;
75243
+ while (scanner.hasNext() &&
75244
+ /* 防止scanner代码错误产生无限循环,设置一个最大scan步数*/
75245
+ steps < contentConfigString.length) {
75246
+ var dateRegex = new RegExp(WatermarkContent.Date);
75247
+ if (scanner.hasNext(dateRegex)) {
75248
+ var regexResult = scanner.next(dateRegex);
75249
+ if (regexResult) {
75250
+ var matchResults = regexResult;
75251
+ var format = date_FORMAT.FORMAT_YMD;
75252
+ if (matchResults && matchResults.length >= 2) {
75253
+ if (checkIsStringValid(matchResults[1])) {
75254
+ format = matchResults[1];
75255
+ }
75256
+ }
75257
+ content += date_formatDate(watermarkContext.watermarkTime, format);
75258
+ scanner.skip(matchResults.input);
75259
+ }
75260
+ }
75261
+ else if (scanner.hasNext(WatermarkContent.Time)) {
75262
+ var value = date_formatDate(watermarkContext.watermarkTime, date_FORMAT.FORMAT_HM);
75263
+ content += value;
75264
+ scanner.skip(WatermarkContent.Time);
75265
+ }
75266
+ else if (scanner.hasNext(WatermarkContent.Address)) {
75267
+ content += watermarkContext.address;
75268
+ scanner.skip(WatermarkContent.Address);
75269
+ }
75270
+ else if (scanner.hasNext(WatermarkContent.HumanName)) {
75271
+ content += watermarkContext.humanName;
75272
+ scanner.skip(WatermarkContent.HumanName);
75273
+ }
75274
+ else if (scanner.hasNext(WatermarkContent.ProjectName)) {
75275
+ content += watermarkContext.projectName;
75276
+ scanner.skip(WatermarkContent.ProjectName);
75277
+ }
75278
+ else if (scanner.hasNext(WatermarkContent.ApplicationName)) {
75279
+ content += watermarkContext.applicationName;
75280
+ scanner.skip(WatermarkContent.ApplicationName);
75281
+ }
75282
+ else {
75283
+ var nextChar = scanner.next();
75284
+ // console.log(`next out "${nextChar}"`)
75285
+ if (checkIsString(nextChar)) {
75286
+ // console.log(`next in "${nextChar}"`)
75287
+ content += nextChar;
75288
+ }
75289
+ scanner.skip();
75290
+ }
75291
+ steps++;
75292
+ }
75293
+ }
75294
+ return { content: content, watermarkImage: watermarkImage };
75295
+ }
75296
+ function parseWatermarks(watermarkConfigString, canvasSize, watermarkContext) {
75297
+ var watermarks = [];
75298
+ var configStringArray = watermarkConfigString.split("###");
75299
+ for (var i = 0; i < configStringArray.length; i++) {
75300
+ var configString = configStringArray[i];
75301
+ //console.log('config string ' + configString);
75302
+ var configParts = configString.split("*#*");
75303
+ //console.log(JSON.stringify(configParts));
75304
+ if (configParts.length === 2) {
75305
+ var styleString = configParts[0];
75306
+ var contentString = configParts[1];
75307
+ var style = parseWatermarkStyle(styleString, canvasSize);
75308
+ var data = buildContent(contentString, watermarkContext, style);
75309
+ if (style && (data.content || data.watermarkImage.image)) {
75310
+ var watermark = new Watermark(data.content, style, data.watermarkImage);
75311
+ watermarks.push(watermark);
75312
+ }
75313
+ }
75314
+ }
75315
+ return watermarks;
75316
+ }
75317
+ /**
75318
+ * 可以渲染的内容
75319
+ */
75320
+ var Tile = /** @class */ (function () {
75321
+ function Tile(origin, size, lineHeight, lineWidths, lines, style, watermarkImage) {
75322
+ this.origin = origin;
75323
+ this.size = size;
75324
+ this.lineHeight = lineHeight;
75325
+ this.lineWidths = lineWidths;
75326
+ this.lines = lines;
75327
+ this.style = style;
75328
+ this.watermarkImage = watermarkImage;
75329
+ }
75330
+ return Tile;
75331
+ }());
75332
+ function getCanvasScale(canvas, len) {
75333
+ var min = Math.min(canvas.width, canvas.height);
75334
+ return (min / DEFAULT_CANVAS_SIZE) * len;
75335
+ }
75336
+ function buildTile(canvas, watermark) {
75337
+ var content = watermark.content, style = watermark.style, watermarkImage = watermark.watermarkImage;
75338
+ var origin = new Point(0, 0);
75339
+ var size = new Size(0, 0);
75340
+ var lines = [];
75341
+ var ctx = canvas.getContext("2d");
75342
+ if (!ctx) {
75343
+ return null;
75344
+ }
75345
+ ctx.font = style.fontWeight + " " + style.fontSize + "px " + style.fontName;
75346
+ var contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
75347
+ var contentWidth = canvas.width - contentPadding * 2;
75348
+ // @see {@link https://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas}
75349
+ var lineHeight = ctx.measureText("M").width;
75350
+ var lineWidths = [];
75351
+ // content超过宽度就换行
75352
+ var temp = "";
75353
+ var lastWidth = 0;
75354
+ for (var i = 0; i < content.length; i++) {
75355
+ var lineWidth = ctx.measureText(temp).width;
75356
+ if (lineWidth >= contentWidth) {
75357
+ lines.push(temp);
75358
+ lineWidths.push(lineWidth);
75359
+ temp = "";
75360
+ }
75361
+ lastWidth = lineWidth;
75362
+ temp += content[i];
75363
+ }
75364
+ lines.push(temp);
75365
+ lineWidths.push(lastWidth);
75366
+ size.width = contentWidth;
75367
+ size.height = lines.length * lineHeight;
75368
+ return new Tile(origin, size, lineHeight, lineWidths, lines, style, watermarkImage);
75369
+ }
75370
+ /**
75371
+ * 画文字,默认{@link https://stackoverflow.com/questions/43242709/how-can-i-draw-text-that-looks-embossed-using-kinetic-js-and-canvas|浮雕效果}
75372
+ * @param canvas
75373
+ * @param text
75374
+ */
75375
+ // function getEmbossTextImageData(text: string, size: Size): ImageData | null {
75376
+ // // constants
75377
+ // const canvas = document.createElement('canvas');
75378
+ // document.body.appendChild(canvas);
75379
+ // const ctx = canvas.getContext("2d");
75380
+ // if (!ctx) {
75381
+ // return null
75382
+ // }
75383
+ //
75384
+ // canvas.width = size.width;
75385
+ // canvas.height = size.height;
75386
+ //
75387
+ // // constants
75388
+ // const blur = 2;
75389
+ // const highLight = "rgba(100,190,256,0.75)";
75390
+ // const shadow = "rgba(0,0,0,0.65)";
75391
+ // const font = "84px arial black";
75392
+ // const background = "linear-gradient(to right, #1e5799 0%,#3096e5 100%)";
75393
+ // const border = "2px solid #6CF"
75394
+ //
75395
+ // // create canvas add styles and put on page
75396
+ //
75397
+ // const w = (canvas.width = innerWidth - 24) / 2; // set size and get centers
75398
+ // const h = (canvas.height = innerHeight - 24) / 2;
75399
+ // canvas.style.background = background;
75400
+ // canvas.style.border = border;
75401
+ //
75402
+ //
75403
+ // // set up font and font rendering alignment
75404
+ // ctx.font = font;
75405
+ // ctx.textAlign = "center";
75406
+ // ctx.textBaseline = "middle";
75407
+ //
75408
+ // // draw dark shadow
75409
+ // ctx.shadowBlur = blur; // shadow
75410
+ // ctx.fillStyle = ctx.shadowColor = shadow;
75411
+ // ctx.shadowOffsetY = ctx.shadowOffsetX = blur;
75412
+ // ctx.fillText(text, w, h);
75413
+ //
75414
+ // // draw highLight
75415
+ // ctx.fillStyle = ctx.shadowColor = highLight;
75416
+ // ctx.shadowOffsetY = ctx.shadowOffsetX = -blur;
75417
+ // ctx.fillText(text, w, h);
75418
+ //
75419
+ // // draw center text that removes pixels
75420
+ // ctx.shadowColor = "rgba(0,0,0,0.0)"; // turn off shadow
75421
+ // ctx.fillStyle = "black";
75422
+ // ctx.globalCompositeOperation = "destination-out"; // New pixels will remove old pixels making them transparent
75423
+ // ctx.fillText(text, w, h);
75424
+ // ctx.globalCompositeOperation = "source-over"; // restore default composite operation.
75425
+ //
75426
+ // return ctx.getImageData(0, 0, size.width, size.height)
75427
+ // }
75428
+ function getAxisPoint(canvasWidth, width, origin, style, watermarkImage) {
75429
+ var padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
75430
+ var axisPoint = new Point(padding, origin.y);
75431
+ if (style.position.startsWith("center")) {
75432
+ axisPoint = new Point(canvasWidth / 2, origin.y);
75433
+ }
75434
+ else if (style.position.startsWith("right")) {
75435
+ axisPoint = new Point(canvasWidth - padding, origin.y);
75436
+ }
75437
+ var imagePoint = new Point(axisPoint.x, axisPoint.y);
75438
+ if (watermarkImage.image) {
75439
+ if (watermarkImage.position === WatermarkImageEnum.POSITION_LEFT) {
75440
+ if (style.position.startsWith("left")) {
75441
+ axisPoint.x = axisPoint.x + watermarkImage.width;
75442
+ }
75443
+ else if (style.position.startsWith("center")) {
75444
+ axisPoint.x = axisPoint.x + watermarkImage.width / 2;
75445
+ imagePoint.x = imagePoint.x - width / 2 - watermarkImage.width;
75446
+ }
75447
+ else {
75448
+ imagePoint.x = imagePoint.x - width - 2 * watermarkImage.width;
75449
+ }
75450
+ }
75451
+ else {
75452
+ if (style.position.startsWith("left")) {
75453
+ imagePoint.x = axisPoint.x + width + watermarkImage.width;
75454
+ }
75455
+ else if (style.position.startsWith("center")) {
75456
+ axisPoint.x = axisPoint.x - watermarkImage.width / 2;
75457
+ imagePoint.x = imagePoint.x + width / 2;
75458
+ }
75459
+ else {
75460
+ axisPoint.x = axisPoint.x - watermarkImage.width;
75461
+ imagePoint.x = imagePoint.x - watermarkImage.width;
75462
+ }
75463
+ }
75464
+ }
75465
+ return {
75466
+ text: axisPoint,
75467
+ image: imagePoint,
75468
+ };
75469
+ }
75470
+ function getTextAlign(style) {
75471
+ var align = "left";
75472
+ if (style.position.startsWith("center")) {
75473
+ align = "center";
75474
+ }
75475
+ else if (style.position.startsWith("right")) {
75476
+ align = "right";
75477
+ }
75478
+ return align;
75479
+ }
75480
+ function loadImage(url) {
75481
+ return new Promise(function (resolve, reject) {
75482
+ var img = new Image();
75483
+ img.src = url;
75484
+ img.crossOrigin = "anonymous";
75485
+ img.onload = function (e) {
75486
+ if (img.complete) {
75487
+ resolve(img);
75488
+ }
75489
+ else {
75490
+ console.error(e);
75491
+ reject(new Error("文件加载失败"));
75492
+ }
75493
+ };
75494
+ });
75495
+ }
75496
+ function drawLine(canvas, line, width, origin, tile) {
75497
+ return __awaiter(this, void 0, void 0, function () {
75498
+ var ctx, style, watermarkImage, point, image, offset;
75499
+ return __generator(this, function (_a) {
75500
+ switch (_a.label) {
75501
+ case 0:
75502
+ ctx = canvas.getContext("2d");
75503
+ if (!ctx) {
75504
+ return [2 /*return*/];
75505
+ }
75506
+ style = tile.style, watermarkImage = tile.watermarkImage;
75507
+ /**
75508
+ * The fillText's second argument is the Y coordinate for the baseline of the text (the default textBaseline is "alphabetic") ,
75509
+ * so the text is being drawn above the visible canvas element when you use 0.
75510
+ * @see {@link https://stackoverflow.com/questions/14289331/html5-canvas-doesnt-fill-text-at-coordinates-0-0}
75511
+ */
75512
+ ctx.textBaseline = "top";
75513
+ ctx.font = style.fontWeight + " " + style.fontSize + "px " + style.fontName;
75514
+ point = getAxisPoint(canvas.width, width, origin, style, watermarkImage);
75515
+ ctx.textAlign = getTextAlign(style);
75516
+ if (!watermarkImage.image) return [3 /*break*/, 2];
75517
+ return [4 /*yield*/, loadImage(watermarkImage.image)];
75518
+ case 1:
75519
+ image = _a.sent();
75520
+ ctx.drawImage(image, Math.round(point.image.x), Math.round(point.image.y), watermarkImage.width, watermarkImage.height);
75521
+ _a.label = 2;
75522
+ case 2:
75523
+ if (style.simplified) {
75524
+ ctx.shadowBlur = 4; // shadow
75525
+ // ctx.shadowColor = "rgba(220,220,220,0.75)";
75526
+ ctx.shadowColor = "rgba(0, 0, 0, 0.5)";
75527
+ offset = clamp(style.fontSize / 40, 2, 4);
75528
+ ctx.shadowOffsetY = offset;
75529
+ ctx.shadowOffsetX = offset;
75530
+ ctx.fillStyle = "rgba(255,255,255, 0.5)";
75531
+ }
75532
+ else {
75533
+ ctx.fillStyle = style.fontColor;
75534
+ }
75535
+ ctx.fillText(line, Math.round(point.text.x), Math.round(point.text.y));
75536
+ return [2 /*return*/];
75537
+ }
75538
+ });
75539
+ });
75540
+ }
75541
+ function hexToRGB(hex, alpha) {
75542
+ var r = parseInt(hex.slice(1, 3), 16), g = parseInt(hex.slice(3, 5), 16), b = parseInt(hex.slice(5, 7), 16);
75543
+ if (alpha) {
75544
+ return "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")";
75545
+ }
75546
+ else {
75547
+ return "rgb(" + r + ", " + g + ", " + b + ")";
75548
+ }
75549
+ }
75550
+ function drawBackground(canvas, tile) {
75551
+ var ctx = canvas.getContext("2d");
75552
+ if (!ctx) {
75553
+ return;
75554
+ }
75555
+ var backgroundColor = tile.style.backgroundColor;
75556
+ var backgroundOpacity = parseDecimal(String(tile.style.backgroundOpacity), -1);
75557
+ if (backgroundOpacity > 255) {
75558
+ backgroundOpacity = 255;
75559
+ }
75560
+ var paddingTop = 2;
75561
+ var paddingBottom = 10;
75562
+ if (backgroundColor !== "transparent") {
75563
+ if (backgroundColor.startsWith("#") && backgroundOpacity >= 0) {
75564
+ backgroundColor = hexToRGB(backgroundColor, backgroundOpacity / 255.0);
75565
+ }
75566
+ ctx.fillStyle = backgroundColor;
75567
+ var style = tile.style;
75568
+ var padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
75569
+ var paddingScale = tile.style.fontSize / DEFAULT_FONT_SIZE;
75570
+ for (var j = 0; j < tile.lineWidths.length; j++) {
75571
+ var lineHeight = tile.lineHeight;
75572
+ var lineWidth = tile.lineWidths[j];
75573
+ var paddingRight = 30 * paddingScale;
75574
+ var paddingLeft = 10 * paddingScale;
75575
+ var axisPoint = new Point(padding - paddingLeft, tile.origin.y);
75576
+ if (style.position.startsWith("center")) {
75577
+ paddingLeft = 20 * paddingScale;
75578
+ paddingRight = 20 * paddingScale;
75579
+ axisPoint = new Point((canvas.width - lineWidth) / 2 - paddingLeft, tile.origin.y);
75580
+ }
75581
+ else if (style.position.startsWith("right")) {
75582
+ paddingLeft = 30 * paddingScale;
75583
+ paddingRight = 10 * paddingScale;
75584
+ axisPoint = new Point(canvas.width - lineWidth - padding - paddingLeft, tile.origin.y);
75585
+ }
75586
+ // padding top
75587
+ if (j === 0) {
75588
+ ctx.fillRect(axisPoint.x, axisPoint.y - paddingTop > 0 ? axisPoint.y - paddingTop : 0, paddingLeft + lineWidth + paddingRight, paddingTop);
75589
+ }
75590
+ ctx.fillRect(axisPoint.x, axisPoint.y + j * lineHeight, paddingLeft + lineWidth + paddingRight, lineHeight);
75591
+ // padding bottom
75592
+ if (j === tile.lineWidths.length - 1) {
75593
+ ctx.fillRect(axisPoint.x, axisPoint.y + (j + 1) * lineHeight, paddingLeft + lineWidth + paddingRight, paddingBottom);
75594
+ }
75595
+ }
75596
+ }
75597
+ }
75598
+ function drawTile(canvas, tile) {
75599
+ return __awaiter(this, void 0, void 0, function () {
75600
+ var i, origin_1;
75601
+ return __generator(this, function (_a) {
75602
+ switch (_a.label) {
75603
+ case 0:
75604
+ if (!tile.style.simplified) {
75605
+ // 复杂配置绘制背景颜色
75606
+ drawBackground(canvas, tile);
75607
+ }
75608
+ i = 0;
75609
+ _a.label = 1;
75610
+ case 1:
75611
+ if (!(i < tile.lines.length)) return [3 /*break*/, 4];
75612
+ origin_1 = new Point(tile.origin.x, i * tile.lineHeight + tile.origin.y);
75613
+ return [4 /*yield*/, drawLine(canvas, tile.lines[i], tile.lineWidths[i], origin_1, tile)];
75614
+ case 2:
75615
+ _a.sent();
75616
+ _a.label = 3;
75617
+ case 3:
75618
+ i++;
75619
+ return [3 /*break*/, 1];
75620
+ case 4: return [2 /*return*/];
75621
+ }
75622
+ });
75623
+ });
75624
+ }
75625
+ var GroupPosition;
75626
+ (function (GroupPosition) {
75627
+ GroupPosition["Top"] = "top";
75628
+ GroupPosition["Center"] = "center";
75629
+ GroupPosition["Bottom"] = "bottom";
75630
+ })(GroupPosition || (GroupPosition = {}));
75631
+ function drawGroupedWatermarks(canvas, watermarks, groupPosition) {
75632
+ return __awaiter(this, void 0, void 0, function () {
75633
+ var tiles, totalHeight, i, watermark, tile, contentPadding, baseOrigin, lastMarginTop, i, tile, i, tile;
75634
+ return __generator(this, function (_a) {
75635
+ switch (_a.label) {
75636
+ case 0:
75637
+ if (!watermarks || watermarks.length === 0) {
75638
+ return [2 /*return*/];
75639
+ }
75640
+ tiles = [];
75641
+ totalHeight = 0;
75642
+ for (i = 0; i < watermarks.length; i++) {
75643
+ watermark = watermarks[i];
75644
+ tile = buildTile(canvas, watermark);
75645
+ if (tile) {
75646
+ tiles.push(tile);
75647
+ totalHeight += tile.size.height + CONTENT_PADDING;
75648
+ }
75649
+ }
75650
+ if (totalHeight <= 0) {
75651
+ // no need draw
75652
+ console.error("watermarks height " + totalHeight);
75653
+ console.error(JSON.stringify(watermarks));
75654
+ return [2 /*return*/];
75655
+ }
75656
+ contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
75657
+ baseOrigin = new Point(contentPadding, contentPadding);
75658
+ if (groupPosition === GroupPosition.Center) {
75659
+ baseOrigin = new Point(contentPadding, Math.round((canvas.height - totalHeight) / 2));
75660
+ }
75661
+ else if (groupPosition === GroupPosition.Bottom) {
75662
+ baseOrigin = new Point(contentPadding, canvas.height - totalHeight - contentPadding);
75663
+ }
75664
+ else if (groupPosition === GroupPosition.Top) {
75665
+ baseOrigin = new Point(contentPadding, contentPadding);
75666
+ }
75667
+ lastMarginTop = 0;
75668
+ for (i = 0; i < tiles.length; i++) {
75669
+ tile = tiles[i];
75670
+ lastMarginTop += tile.style.paddingTop;
75671
+ tile.origin = new Point(tile.origin.x + baseOrigin.x, lastMarginTop + baseOrigin.y);
75672
+ lastMarginTop += tile.size.height;
75673
+ lastMarginTop += tile.style.paddingBottom;
75674
+ }
75675
+ i = 0;
75676
+ _a.label = 1;
75677
+ case 1:
75678
+ if (!(i < tiles.length)) return [3 /*break*/, 4];
75679
+ tile = tiles[i];
75680
+ return [4 /*yield*/, drawTile(canvas, tile)];
75681
+ case 2:
75682
+ _a.sent();
75683
+ _a.label = 3;
75684
+ case 3:
75685
+ i++;
75686
+ return [3 /*break*/, 1];
75687
+ case 4: return [2 /*return*/];
75688
+ }
75689
+ });
75690
+ });
75691
+ }
75692
+ /**
75693
+ * 把watermark 分为 上、中、三组
75694
+ * @param watermarks
75695
+ */
75696
+ function groupingWatermarks(watermarks) {
75697
+ var _a;
75698
+ var topList = [];
75699
+ var centerList = [];
75700
+ var bottomList = [];
75701
+ for (var i = 0; i < watermarks.length; i++) {
75702
+ var watermark = watermarks[i];
75703
+ if (watermark.style.position.endsWith("top")) {
75704
+ topList.push(watermark);
75705
+ }
75706
+ else if (watermark.style.position.endsWith("center")) {
75707
+ centerList.push(watermark);
75708
+ }
75709
+ else if (watermark.style.position.endsWith("bottom")) {
75710
+ bottomList.push(watermark);
75711
+ }
75712
+ }
75713
+ return _a = {},
75714
+ _a[GroupPosition.Top] = topList,
75715
+ _a[GroupPosition.Center] = centerList,
75716
+ _a[GroupPosition.Bottom] = bottomList,
75717
+ _a;
75718
+ }
75719
+ function renderWatermark(canvas, options) {
75720
+ return __awaiter(this, void 0, void 0, function () {
75721
+ var watermarkConfigString, watermarks, groupedWatermarks;
75722
+ return __generator(this, function (_a) {
75723
+ switch (_a.label) {
75724
+ case 0:
75725
+ // console.log("canvas width " + canvas.width);
75726
+ // console.log("canvas height " + canvas.height);
75727
+ if (!options.enabled || options.watermarkConfigString === "no") {
75728
+ return [2 /*return*/, Promise.resolve(canvas)];
75729
+ }
75730
+ watermarkConfigString = options.watermarkConfigString;
75731
+ if (watermarkConfigString === "default") {
75732
+ watermarkConfigString = "50$lefttop$50*#*time###25$lefttop*#*date";
75733
+ }
75734
+ watermarks = parseWatermarks(watermarkConfigString, new Size(canvas.width, canvas.height), options.context);
75735
+ groupedWatermarks = groupingWatermarks(watermarks);
75736
+ return [4 /*yield*/, drawGroupedWatermarks(canvas, groupedWatermarks[GroupPosition.Top], GroupPosition.Top)];
75737
+ case 1:
75738
+ _a.sent();
75739
+ return [4 /*yield*/, drawGroupedWatermarks(canvas, groupedWatermarks[GroupPosition.Center], GroupPosition.Center)];
75740
+ case 2:
75741
+ _a.sent();
75742
+ return [4 /*yield*/, drawGroupedWatermarks(canvas, groupedWatermarks[GroupPosition.Bottom], GroupPosition.Bottom)];
75743
+ case 3:
75744
+ _a.sent();
75745
+ return [2 /*return*/, Promise.resolve(canvas)];
75746
+ }
75747
+ });
75748
+ });
75749
+ }
75750
+ function checkWatermarkConfigSupported(watermarkConfigString) {
75751
+ var configStringArray = watermarkConfigString.split("###");
75752
+ for (var i = 0; i < configStringArray.length; i++) {
75753
+ var configString = configStringArray[i];
75754
+ //console.log('config string ' + configString);
75755
+ var configParts = configString.split("*#*");
75756
+ //console.log(JSON.stringify(configParts));
75757
+ if (configParts.length === 2) {
75758
+ var styleString = configParts[0];
75759
+ var styleParts = styleString.split("$");
75760
+ if (styleParts.length <= 0) {
75761
+ console.error("水印配置不合法");
75762
+ return false;
75763
+ }
75764
+ }
75765
+ }
75766
+ return true;
75767
+ }
75768
+ //# sourceMappingURL=watermark.js.map
75769
+ // CONCATENATED MODULE: ./node_modules/@egova/media/lib/image-util.js
75770
+ /**
75771
+ * Convert File to data schema url
75772
+ * @param file
75773
+ */
75774
+ function file2DataURL(file) {
75775
+ return new Promise(function (resolve, reject) {
75776
+ var a = new FileReader();
75777
+ a.onload = function (res) {
75778
+ if (res && res.target) {
75779
+ resolve(res.target.result);
75780
+ }
75781
+ else {
75782
+ reject(new Error('读取文件url失败'));
75783
+ }
75784
+ };
75785
+ a.readAsDataURL(file);
75786
+ });
75787
+ }
75788
+ /**
75789
+ * Convert file to image
75790
+ * @param file
75791
+ */
75792
+ function file2Image(file) {
75793
+ return new Promise(function (resolve, reject) {
75794
+ file2DataURL(file).then(function (url) {
75795
+ var img = new Image();
75796
+ img.src = url;
75797
+ img.onload = function (e) {
75798
+ if (img.complete) {
75799
+ resolve(img);
75800
+ }
75801
+ else {
75802
+ reject(new Error('文件加载失败'));
75803
+ }
75804
+ };
75805
+ }).catch(reject);
75806
+ });
75807
+ }
75808
+ function image2file(img, fileName, lastModified, type, quality) {
75809
+ if (type === void 0) { type = "image/jpeg"; }
75810
+ if (quality === void 0) { quality = 0.8; }
75811
+ return image2Canvas(img, type).then(function (canvas) {
75812
+ return canvas2File(canvas, fileName, lastModified, type, quality);
75813
+ });
75814
+ }
75815
+ /**
75816
+ * Draw image on canvas
75817
+ * @param img
75818
+ * @param width
75819
+ * @param height
75820
+ */
75821
+ function image2Canvas(img, type, width, height) {
75822
+ var canvas = document.createElement('canvas');
75823
+ if (!width) {
75824
+ width = img.width;
75825
+ }
75826
+ if (!height) {
75827
+ height = img.height;
75828
+ }
75829
+ canvas.width = width;
75830
+ canvas.height = height;
75831
+ var ctx = canvas.getContext('2d');
75832
+ if (ctx) {
75833
+ // png经canvas.toDataURL转换后背景变成黑色,这里提前填充白色
75834
+ ctx.fillStyle = 'transparent';
75835
+ if (type === 'image/jpeg') {
75836
+ ctx.fillStyle = '#fff';
75837
+ }
75838
+ ctx.drawImage(img, 0, 0, width, height);
75839
+ return Promise.resolve(canvas);
75840
+ }
75841
+ else {
75842
+ return Promise.reject(null);
75843
+ }
75844
+ }
75845
+ /**
75846
+ * Export Image from canvas
75847
+ * @param canvas
75848
+ * @param type
75849
+ * @param quality
75850
+ * @see {@link https://meshworld.in/convert-canvas-to-an-image-using-javascript/}
75851
+ */
75852
+ function canvas2Image(canvas, type, quality) {
75853
+ if (type === void 0) { type = "image/jpeg"; }
75854
+ if (quality === void 0) { quality = 0.8; }
75855
+ var image = new Image();
75856
+ image.src = canvas.toDataURL(type, quality);
75857
+ return Promise.resolve(image);
75858
+ }
75859
+ /**
75860
+ * Export File from canvas
75861
+ * @param canvas
75862
+ * @param fileName
75863
+ * @param lastModified
75864
+ * @param type
75865
+ * @param quality
75866
+ * @see {@link https://meshworld.in/convert-canvas-to-an-image-using-javascript/}
75867
+ */
75868
+ function canvas2File(canvas, fileName, lastModified, type, quality) {
75869
+ if (type === void 0) { type = "image/jpeg"; }
75870
+ if (quality === void 0) { quality = 0.8; }
75871
+ return new Promise(function (resolve, reject) {
75872
+ canvas.toBlob(function (blob) {
75873
+ if (!blob) {
75874
+ reject(new Error('canvas文件导出失败'));
75875
+ }
75876
+ else {
75877
+ var file = new File([blob], fileName, { lastModified: lastModified, type: type });
75878
+ // console.log("file size " + file.size / 1024 + "kb");
75879
+ // console.log(file)
75880
+ resolve(file);
75881
+ }
75882
+ }, type, quality);
75883
+ });
75884
+ }
75885
+ /**
75886
+ * 缩放图片
75887
+ * @param img:HTMLImageElement 图片对象
75888
+ * @param inputType 图片类型
75889
+ * @param imageWidth 图片宽度
75890
+ * @param imageHeight 图片高度
75891
+ * @param equalProportion 是否等比例拉伸,默认是,目前只支持等比例拉伸
75892
+ * @param sideLengthLimit 图片边长限制
75893
+ * @param baseOnShortSide 是否以短边为限制
75894
+ * @param resultType: ResizeResultType, "image" | "canvas"
75895
+ */
75896
+ function resize(img, _a) {
75897
+ var _b = _a.inputType, inputType = _b === void 0 ? 'image/jpeg' : _b, _c = _a.imageWidth, imageWidth = _c === void 0 ? -1 : _c, _d = _a.imageHeight, imageHeight = _d === void 0 ? -1 : _d, _e = _a.equalProportion, equalProportion = _e === void 0 ? true : _e, //等比例拉伸
75898
+ _f = _a.sideLengthLimit, //等比例拉伸
75899
+ sideLengthLimit = _f === void 0 ? 640 : _f, _g = _a.baseOnShortSide, baseOnShortSide = _g === void 0 ? true : _g, // 是否以短边为基准缩放
75900
+ _h = _a.resultType, // 是否以短边为基准缩放
75901
+ resultType = _h === void 0 ? "image" : _h;
75902
+ var scale = 1;
75903
+ var scaleBaseFunc = baseOnShortSide ? Math.min : Math.max;
75904
+ if (imageWidth > 0 && imageHeight > 0) {
75905
+ scale = sideLengthLimit / scaleBaseFunc(imageWidth, imageHeight);
75906
+ }
75907
+ else if (img.width > 0 && img.height > 0) {
75908
+ scale = sideLengthLimit / scaleBaseFunc(img.width, img.height);
75909
+ imageWidth = img.width;
75910
+ imageHeight = img.height;
75911
+ }
75912
+ else {
75913
+ return Promise.reject(new Error('image width/height 无效'));
75914
+ }
75915
+ var targetWidth = scale > 1 ? imageWidth : imageWidth * scale;
75916
+ var targetHeight = scale > 1 ? imageHeight : imageHeight * scale;
75917
+ if (resultType === "image") {
75918
+ return image2Canvas(img, inputType, targetWidth, targetHeight).then(function (canvas) {
75919
+ return canvas2Image(canvas);
75920
+ });
75921
+ }
75922
+ else {
75923
+ return image2Canvas(img, inputType, targetWidth, targetHeight);
75924
+ }
75925
+ }
75926
+ //# sourceMappingURL=image-util.js.map
75561
75927
  // CONCATENATED MODULE: ./node_modules/@egova/media/lib/image-processor.js
75562
-
75563
-
75564
-
75565
- var MAX_SIDE_LENGTH = 1920;
75566
- var MIN_SIDE_LEnGTH = 480;
75567
- var PHOTO_FILE_SIZE_LIMIT = 1000; // 1000kb
75568
- var DEFAULT_JPEG_QUALITY = 0.8;
75569
- var MIN_JPEG_QUALITY = 0.1;
75570
- var JPEG_QUALITY_STEP = 0.05;
75571
- var image_processor_ResizeOptions = /** @class */ (function () {
75572
- function ResizeOptions(maxSideLength) {
75573
- if (checkIsUndefinedOrNull(maxSideLength)) {
75574
- this.maxSideLength = MAX_SIDE_LENGTH;
75575
- }
75576
- else {
75577
- this.maxSideLength = maxSideLength;
75578
- if (this.maxSideLength > MAX_SIDE_LENGTH) {
75579
- this.maxSideLength = MAX_SIDE_LENGTH;
75580
- }
75581
- else if (this.maxSideLength < MIN_SIDE_LEnGTH) {
75582
- this.maxSideLength = MIN_SIDE_LEnGTH;
75583
- }
75584
- }
75585
- }
75586
- return ResizeOptions;
75587
- }());
75588
-
75589
- var image_processor_CompressOptions = /** @class */ (function () {
75590
- function CompressOptions(photoFileSizeLimit) {
75591
- if (checkIsUndefinedOrNull(photoFileSizeLimit)) {
75592
- this.photoFileSizeLimit = PHOTO_FILE_SIZE_LIMIT;
75593
- }
75594
- else {
75595
- this.photoFileSizeLimit = photoFileSizeLimit;
75596
- }
75597
- }
75598
- return CompressOptions;
75599
- }());
75600
-
75601
- var image_processor_ImageProcessor = /** @class */ (function () {
75602
- function ImageProcessor(file, resizeOptions, watermarkOptions, compressOptions) {
75603
- this.file = file;
75604
- this.resizeOptions = resizeOptions;
75605
- this.watermarkOptions = watermarkOptions;
75606
- this.compressOptions = compressOptions;
75607
- }
75608
- ImageProcessor.prototype.process = function () {
75609
- var _this = this;
75610
- var filename = this.file.name;
75611
- var lastModified = this.file.lastModified;
75612
- var fileType = this.file.type;
75613
- if (this.file.size > this.compressOptions.photoFileSizeLimit * 1024) {
75614
- fileType = 'image/jpeg';
75615
- }
75616
- if (fileType === 'image/gif') {
75617
- fileType = 'image/png';
75618
- }
75619
- return file2Image(this.file).then(function (img) {
75620
- //第一步 resize image
75621
- return resize(img, {
75622
- inputType: fileType,
75623
- sideLengthLimit: _this.resizeOptions.maxSideLength,
75624
- resultType: "canvas"
75625
- });
75626
- }).then(function (result) {
75627
- var canvas = result;
75628
- //第二步 打水印
75629
- return renderWatermark(canvas, _this.watermarkOptions);
75630
- }).then(function (canvas) {
75631
- var exportFilename = filename.replace(/\./g, "-") + '.jpg';
75632
- return _this.compress(canvas, exportFilename, lastModified, fileType, DEFAULT_JPEG_QUALITY);
75633
- });
75634
- };
75635
- ImageProcessor.prototype.compress = function (canvas, filename, lastModified, type, quality) {
75636
- var _this = this;
75637
- return canvas2File(canvas, filename, lastModified, type, quality).then(function (file) {
75638
- if (file.size > _this.compressOptions.photoFileSizeLimit * 1024 &&
75639
- quality - JPEG_QUALITY_STEP > MIN_JPEG_QUALITY) {
75640
- return _this.compress(canvas, filename, lastModified, type, quality - JPEG_QUALITY_STEP);
75641
- }
75642
- else {
75643
- return Promise.resolve(file);
75644
- }
75645
- });
75646
- };
75647
- return ImageProcessor;
75648
- }());
75649
-
75928
+ var image_processor_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
75929
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
75930
+ return new (P || (P = Promise))(function (resolve, reject) {
75931
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
75932
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
75933
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
75934
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
75935
+ });
75936
+ };
75937
+ var image_processor_generator = (undefined && undefined.__generator) || function (thisArg, body) {
75938
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
75939
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
75940
+ function verb(n) { return function (v) { return step([n, v]); }; }
75941
+ function step(op) {
75942
+ if (f) throw new TypeError("Generator is already executing.");
75943
+ while (_) try {
75944
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
75945
+ if (y = 0, t) op = [op[0] & 2, t.value];
75946
+ switch (op[0]) {
75947
+ case 0: case 1: t = op; break;
75948
+ case 4: _.label++; return { value: op[1], done: false };
75949
+ case 5: _.label++; y = op[1]; op = [0]; continue;
75950
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
75951
+ default:
75952
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
75953
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
75954
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
75955
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
75956
+ if (t[2]) _.ops.pop();
75957
+ _.trys.pop(); continue;
75958
+ }
75959
+ op = body.call(thisArg, _);
75960
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
75961
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
75962
+ }
75963
+ };
75964
+
75965
+
75966
+
75967
+ var MAX_SIDE_LENGTH = 1920;
75968
+ var MIN_SIDE_LENGTH = 480;
75969
+ var PHOTO_FILE_SIZE_LIMIT = 1000; // 1000kb
75970
+ var DEFAULT_JPEG_QUALITY = 0.8;
75971
+ var MIN_JPEG_QUALITY = 0.1;
75972
+ var JPEG_QUALITY_STEP = 0.05;
75973
+ var image_processor_ResizeOptions = /** @class */ (function () {
75974
+ function ResizeOptions(maxSideLength) {
75975
+ if (checkIsUndefinedOrNull(maxSideLength)) {
75976
+ this.maxSideLength = MAX_SIDE_LENGTH;
75977
+ }
75978
+ else {
75979
+ this.maxSideLength = maxSideLength;
75980
+ if (this.maxSideLength > MAX_SIDE_LENGTH) {
75981
+ this.maxSideLength = MAX_SIDE_LENGTH;
75982
+ }
75983
+ else if (this.maxSideLength < MIN_SIDE_LENGTH) {
75984
+ this.maxSideLength = MIN_SIDE_LENGTH;
75985
+ }
75986
+ }
75987
+ }
75988
+ return ResizeOptions;
75989
+ }());
75990
+
75991
+ var image_processor_CompressOptions = /** @class */ (function () {
75992
+ function CompressOptions(photoFileSizeLimit) {
75993
+ if (checkIsUndefinedOrNull(photoFileSizeLimit)) {
75994
+ this.photoFileSizeLimit = PHOTO_FILE_SIZE_LIMIT;
75995
+ }
75996
+ else {
75997
+ this.photoFileSizeLimit = photoFileSizeLimit;
75998
+ }
75999
+ }
76000
+ return CompressOptions;
76001
+ }());
76002
+
76003
+ var image_processor_ImageProcessor = /** @class */ (function () {
76004
+ function ImageProcessor(file, resizeOptions, watermarkOptions, compressOptions) {
76005
+ this.file = file;
76006
+ this.resizeOptions = resizeOptions;
76007
+ this.watermarkOptions = watermarkOptions;
76008
+ this.compressOptions = compressOptions;
76009
+ }
76010
+ ImageProcessor.prototype.process = function () {
76011
+ var _this = this;
76012
+ var filename = this.file.name;
76013
+ var lastModified = this.file.lastModified;
76014
+ var fileType = this.file.type;
76015
+ if (this.file.size > this.compressOptions.photoFileSizeLimit * 1024) {
76016
+ fileType = "image/jpeg";
76017
+ }
76018
+ if (fileType === "image/gif") {
76019
+ fileType = "image/png";
76020
+ }
76021
+ return file2Image(this.file)
76022
+ .then(function (img) {
76023
+ //第一步 resize image
76024
+ return resize(img, {
76025
+ inputType: fileType,
76026
+ sideLengthLimit: _this.resizeOptions.maxSideLength,
76027
+ resultType: "canvas",
76028
+ });
76029
+ })
76030
+ .then(function (result) { return image_processor_awaiter(_this, void 0, void 0, function () {
76031
+ var canvas;
76032
+ return image_processor_generator(this, function (_a) {
76033
+ switch (_a.label) {
76034
+ case 0:
76035
+ canvas = result;
76036
+ return [4 /*yield*/, renderWatermark(canvas, this.watermarkOptions)];
76037
+ case 1:
76038
+ //第二步 打水印
76039
+ return [2 /*return*/, _a.sent()];
76040
+ }
76041
+ });
76042
+ }); })
76043
+ .then(function (canvas) {
76044
+ var exportFilename = filename.replace(/\./g, "-") + ".jpg";
76045
+ return _this.compress(canvas, exportFilename, lastModified, fileType, DEFAULT_JPEG_QUALITY);
76046
+ });
76047
+ };
76048
+ ImageProcessor.prototype.compress = function (canvas, filename, lastModified, type, quality) {
76049
+ var _this = this;
76050
+ return canvas2File(canvas, filename, lastModified, type, quality).then(function (file) {
76051
+ if (file.size > _this.compressOptions.photoFileSizeLimit * 1024 &&
76052
+ quality - JPEG_QUALITY_STEP > MIN_JPEG_QUALITY) {
76053
+ return _this.compress(canvas, filename, lastModified, type, quality - JPEG_QUALITY_STEP);
76054
+ }
76055
+ else {
76056
+ return Promise.resolve(file);
76057
+ }
76058
+ });
76059
+ };
76060
+ return ImageProcessor;
76061
+ }());
76062
+
75650
76063
  //# sourceMappingURL=image-processor.js.map
75651
76064
  // CONCATENATED MODULE: ./node_modules/@egova/media/lib/index.js
75652
- /**
75653
- * @description 水印渲染类
75654
- * @author Jiaji Yin
75655
- * @date 2021-11-05
75656
- */
75657
-
75658
-
75659
-
76065
+ /**
76066
+ * @description 水印渲染类
76067
+ * @author Jiaji Yin
76068
+ * @date 2021-11-05
76069
+ */
76070
+
76071
+
76072
+
75660
76073
  //# sourceMappingURL=index.js.map
75661
76074
  // CONCATENATED MODULE: ./es/media-picker/image/TakePhotoIcon.js
75662
76075
  /* harmony default export */ var TakePhotoIcon = ({
@@ -76847,6 +77260,8 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
76847
77260
  address: _this4.watermarkOptions.address || "",
76848
77261
  humanName: _this4.watermarkOptions.humanName || "",
76849
77262
  projectName: _this4.watermarkOptions.projectName || "",
77263
+ logo: _this4.watermarkOptions.logo || "",
77264
+ applicationName: _this4.watermarkOptions.applicationName || "",
76850
77265
  watermarkTime: new Date()
76851
77266
  }
76852
77267
  });
@@ -79605,6 +80020,7 @@ var pdf_viewer_v2_createNamespace = Object(utils["b" /* createNamespace */])('pd
79605
80020
 
79606
80021
 
79607
80022
 
80023
+
79608
80024
  var pdf_viewer_v2_ = __webpack_require__(19);
79609
80025
 
79610
80026
  var pdf_viewer_v2_defaultData = function defaultData() {
@@ -79615,7 +80031,11 @@ var pdf_viewer_v2_defaultData = function defaultData() {
79615
80031
  loading: false,
79616
80032
  PDFJS: null,
79617
80033
  pageChangeByButton: false,
79618
- showPicker: false
80034
+ showPicker: false,
80035
+ // 进度范围:0~100
80036
+ progress: 0,
80037
+ // circle绑定值
80038
+ circleProgress: 0
79619
80039
  };
79620
80040
  };
79621
80041
 
@@ -79645,7 +80065,8 @@ var pdf_viewer_v2_defaultData = function defaultData() {
79645
80065
  default: function _default() {
79646
80066
  return {};
79647
80067
  }
79648
- }
80068
+ },
80069
+ showProgress: Boolean
79649
80070
  },
79650
80071
  data: function data() {
79651
80072
  return pdf_viewer_v2_defaultData();
@@ -79821,6 +80242,14 @@ var pdf_viewer_v2_defaultData = function defaultData() {
79821
80242
  cMapUrl: this.cMapUrl,
79822
80243
  cMapPacked: true
79823
80244
  });
80245
+
80246
+ pdfLoadingTask.onProgress = function (progressData) {
80247
+ // 返回的进度可能会超过100
80248
+ _this4.progress = Math.min(100, Math.floor(progressData.loaded * 100 / progressData.total));
80249
+
80250
+ _this4.$emit('progress', _this4.progress);
80251
+ };
80252
+
79824
80253
  pdfLoadingTask.promise.then(function (pdfDoc) {
79825
80254
  if (pdfDoc && pdfViewerDom) {
79826
80255
  // 缓存pdf内容
@@ -79881,6 +80310,8 @@ var pdf_viewer_v2_defaultData = function defaultData() {
79881
80310
  }
79882
80311
  },
79883
80312
  render: function render(h) {
80313
+ var _this5 = this;
80314
+
79884
80315
  return h("div", {
79885
80316
  "class": pdf_viewer_v2_bem(),
79886
80317
  "ref": "pdfContainer"
@@ -79894,7 +80325,7 @@ var pdf_viewer_v2_defaultData = function defaultData() {
79894
80325
  }, [h(es_loading, {
79895
80326
  "directives": [{
79896
80327
  name: "show",
79897
- value: this.loading
80328
+ value: !this.showProgress && this.loading
79898
80329
  }],
79899
80330
  "class": pdf_viewer_v2_bem('loading-icon')
79900
80331
  }), h("div", {
@@ -79904,7 +80335,21 @@ var pdf_viewer_v2_defaultData = function defaultData() {
79904
80335
  }],
79905
80336
  "ref": "pdfViewerContainer",
79906
80337
  "class": pdf_viewer_v2_bem("container")
79907
- })])]), this.totalPage ? h("div", {
80338
+ })])]), this.showProgress && this.progress < 100 ? h("div", {
80339
+ "class": pdf_viewer_v2_bem("loadding-circle")
80340
+ }, [h(circle, {
80341
+ "attrs": {
80342
+ "rate": this.progress,
80343
+ "speed": "100",
80344
+ "text": this.progress + '%'
80345
+ },
80346
+ "model": {
80347
+ value: _this5.circleProgress,
80348
+ callback: function callback($$v) {
80349
+ _this5.circleProgress = $$v;
80350
+ }
80351
+ }
80352
+ })]) : "", this.totalPage ? h("div", {
79908
80353
  "class": pdf_viewer_v2_bem("page-box")
79909
80354
  }, [h("span", {
79910
80355
  "class": pdf_viewer_v2_bem("pre"),
@@ -80231,10 +80676,10 @@ var right = 'right';
80231
80676
  var esm_left = 'left';
80232
80677
  var auto = 'auto';
80233
80678
  var basePlacements = [esm_top, esm_bottom, right, esm_left];
80234
- var start = 'start';
80235
- var end = 'end';
80679
+ var esm_start = 'start';
80680
+ var esm_end = 'end';
80236
80681
  var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
80237
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
80682
+ return acc.concat([placement, placement + "-" + esm_start, placement + "-" + esm_end]);
80238
80683
  }, []); // modifiers that need to read the DOM
80239
80684
 
80240
80685
  var beforeRead = 'beforeRead';
@@ -80487,11 +80932,11 @@ function computeOffsets(_ref) {
80487
80932
  var len = mainAxis === 'y' ? 'height' : 'width';
80488
80933
 
80489
80934
  switch (variation) {
80490
- case start:
80935
+ case esm_start:
80491
80936
  offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
80492
80937
  break;
80493
80938
 
80494
- case end:
80939
+ case esm_end:
80495
80940
  offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
80496
80941
  break;
80497
80942
  }
@@ -81582,7 +82027,7 @@ function getRateStatus(value, index, allowHalf) {
81582
82027
  return 'void';
81583
82028
  }
81584
82029
 
81585
- /* harmony default export */ var rate = (rate_createComponent({
82030
+ /* harmony default export */ var es_rate = (rate_createComponent({
81586
82031
  mixins: [TouchMixin, FieldMixin],
81587
82032
  props: {
81588
82033
  size: [Number, String],
@@ -84757,7 +85202,9 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
84757
85202
  address: _this.watermarkOptions.address || "",
84758
85203
  watermarkTime: new Date(),
84759
85204
  humanName: _this.watermarkOptions.humanName || "",
84760
- projectName: _this.watermarkOptions.projectName || ""
85205
+ projectName: _this.watermarkOptions.projectName || "",
85206
+ logo: _this.watermarkOptions.logo || "",
85207
+ applicationName: _this.watermarkOptions.applicationName || ""
84761
85208
  });
84762
85209
  var watermarkOptions = new WatermarkOptions({
84763
85210
  enabled: true,
@@ -85243,10 +85690,11 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
85243
85690
 
85244
85691
 
85245
85692
 
85246
- var version = '1.0.19';
85693
+
85694
+ var version = '1.0.21';
85247
85695
 
85248
85696
  function install(Vue) {
85249
- var components = [action_sheet, es_area, avatar, back_top, badge, es_button, calendar, cascader, cell, cell_group, es_checkbox, checkbox_group, col, collapse, collapse_item, count_down, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, fold_dialog, es_form, grid, grid_item, hierarchy_select, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, lazyload, es_list, es_loading, locale["a" /* default */], media_picker, media_player, multiple_picker, nav_bar, notice_bar, number_keyboard, es_overlay, password_input, pdf_viewer, pdf_viewer_v2, es_picker, popover, popup, pull_refresh, es_radio, radio_group, rate, row, search, signature, skeleton, slider, es_step, stepper, es_steps, es_sticky, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, table, tabs, es_tag, timeline, es_toast, uploader];
85697
+ var components = [action_sheet, es_area, avatar, back_top, badge, es_button, calendar, cascader, cell, cell_group, es_checkbox, checkbox_group, circle, col, collapse, collapse_item, count_down, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, fold_dialog, es_form, grid, grid_item, hierarchy_select, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, lazyload, es_list, es_loading, locale["a" /* default */], media_picker, media_player, multiple_picker, nav_bar, notice_bar, number_keyboard, es_overlay, password_input, pdf_viewer, pdf_viewer_v2, es_picker, popover, popup, pull_refresh, es_radio, radio_group, es_rate, row, search, signature, skeleton, slider, es_step, stepper, es_steps, es_sticky, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, table, tabs, es_tag, timeline, es_toast, uploader];
85250
85698
  components.forEach(function (item) {
85251
85699
  if (item.install) {
85252
85700
  Vue.use(item);