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/es/circle/index.css +1 -0
- package/es/circle/index.js +175 -0
- package/es/circle/index.less +41 -0
- package/es/circle/style/index.js +2 -0
- package/es/circle/style/less.js +2 -0
- package/es/index.js +4 -3
- package/es/media-picker/index.js +2 -0
- package/es/pdf-viewer-v2/index.css +1 -1
- package/es/pdf-viewer-v2/index.js +34 -4
- package/es/pdf-viewer-v2/index.less +9 -0
- package/es/pdf-viewer-v2/style/index.js +1 -0
- package/es/pdf-viewer-v2/style/less.js +1 -0
- package/es/uploader/index.js +3 -1
- package/lib/circle/index.css +1 -0
- package/lib/circle/index.js +183 -0
- package/lib/circle/index.less +41 -0
- package/lib/circle/style/index.js +2 -0
- package/lib/circle/style/less.js +2 -0
- package/lib/index.css +1 -1
- package/lib/index.js +6 -2
- package/lib/index.less +2 -1
- package/lib/media-picker/index.js +2 -0
- package/lib/pdf-viewer-v2/index.css +1 -1
- package/lib/pdf-viewer-v2/index.js +35 -4
- package/lib/pdf-viewer-v2/index.less +9 -0
- package/lib/pdf-viewer-v2/style/index.js +1 -0
- package/lib/pdf-viewer-v2/style/less.js +1 -0
- package/lib/uploader/index.js +3 -1
- package/lib/zart.js +1489 -1041
- package/lib/zart.min.js +4 -4
- package/package.json +2 -2
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 */
|
|
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
|
-
|
|
74638
|
-
function
|
|
74639
|
-
|
|
74640
|
-
|
|
74641
|
-
|
|
74642
|
-
|
|
74643
|
-
}
|
|
74644
|
-
|
|
74645
|
-
|
|
74646
|
-
|
|
74647
|
-
|
|
74648
|
-
}
|
|
74649
|
-
|
|
74650
|
-
|
|
74651
|
-
|
|
74652
|
-
|
|
74653
|
-
|
|
74654
|
-
|
|
74655
|
-
|
|
74656
|
-
|
|
74657
|
-
|
|
74658
|
-
|
|
74659
|
-
|
|
74660
|
-
|
|
74661
|
-
|
|
74662
|
-
|
|
74663
|
-
|
|
74664
|
-
(
|
|
74665
|
-
|
|
74666
|
-
|
|
74667
|
-
|
|
74668
|
-
|
|
74669
|
-
|
|
74670
|
-
|
|
74671
|
-
|
|
74672
|
-
|
|
74673
|
-
|
|
74674
|
-
|
|
74675
|
-
|
|
74676
|
-
|
|
74677
|
-
|
|
74678
|
-
|
|
74679
|
-
|
|
74680
|
-
|
|
74681
|
-
|
|
74682
|
-
|
|
74683
|
-
|
|
74684
|
-
|
|
74685
|
-
|
|
74686
|
-
|
|
74687
|
-
|
|
74688
|
-
|
|
74689
|
-
|
|
74690
|
-
|
|
74691
|
-
}
|
|
74692
|
-
var
|
|
74693
|
-
|
|
74694
|
-
|
|
74695
|
-
|
|
74696
|
-
|
|
74697
|
-
|
|
74698
|
-
|
|
74699
|
-
|
|
74700
|
-
|
|
74701
|
-
|
|
74702
|
-
|
|
74703
|
-
|
|
74704
|
-
|
|
74705
|
-
|
|
74706
|
-
|
|
74707
|
-
|
|
74708
|
-
"
|
|
74709
|
-
"
|
|
74710
|
-
"
|
|
74711
|
-
"
|
|
74712
|
-
"
|
|
74713
|
-
"
|
|
74714
|
-
"
|
|
74715
|
-
"
|
|
74716
|
-
"
|
|
74717
|
-
|
|
74718
|
-
|
|
74719
|
-
function
|
|
74720
|
-
|
|
74721
|
-
|
|
74722
|
-
|
|
74723
|
-
|
|
74724
|
-
|
|
74725
|
-
|
|
74726
|
-
|
|
74727
|
-
|
|
74728
|
-
|
|
74729
|
-
|
|
74730
|
-
|
|
74731
|
-
|
|
74732
|
-
|
|
74733
|
-
|
|
74734
|
-
|
|
74735
|
-
|
|
74736
|
-
|
|
74737
|
-
|
|
74738
|
-
|
|
74739
|
-
|
|
74740
|
-
|
|
74741
|
-
|
|
74742
|
-
|
|
74743
|
-
|
|
74744
|
-
|
|
74745
|
-
|
|
74746
|
-
|
|
74747
|
-
|
|
74748
|
-
|
|
74749
|
-
|
|
74750
|
-
|
|
74751
|
-
|
|
74752
|
-
|
|
74753
|
-
|
|
74754
|
-
|
|
74755
|
-
|
|
74756
|
-
|
|
74757
|
-
|
|
74758
|
-
|
|
74759
|
-
|
|
74760
|
-
|
|
74761
|
-
|
|
74762
|
-
|
|
74763
|
-
var
|
|
74764
|
-
|
|
74765
|
-
|
|
74766
|
-
|
|
74767
|
-
|
|
74768
|
-
}
|
|
74769
|
-
|
|
74770
|
-
|
|
74771
|
-
|
|
74772
|
-
|
|
74773
|
-
|
|
74774
|
-
|
|
74775
|
-
|
|
74776
|
-
|
|
74777
|
-
|
|
74778
|
-
|
|
74779
|
-
|
|
74780
|
-
|
|
74781
|
-
|
|
74782
|
-
|
|
74783
|
-
*
|
|
74784
|
-
* @param
|
|
74785
|
-
* @param
|
|
74786
|
-
* @param
|
|
74787
|
-
* @param
|
|
74788
|
-
* @param
|
|
74789
|
-
|
|
74790
|
-
|
|
74791
|
-
|
|
74792
|
-
this.
|
|
74793
|
-
this.
|
|
74794
|
-
this.
|
|
74795
|
-
this.
|
|
74796
|
-
|
|
74797
|
-
|
|
74798
|
-
|
|
74799
|
-
|
|
74800
|
-
|
|
74801
|
-
|
|
74802
|
-
|
|
74803
|
-
|
|
74804
|
-
|
|
74805
|
-
|
|
74806
|
-
|
|
74807
|
-
function
|
|
74808
|
-
|
|
74809
|
-
|
|
74810
|
-
|
|
74811
|
-
|
|
74812
|
-
|
|
74813
|
-
|
|
74814
|
-
|
|
74815
|
-
|
|
74816
|
-
|
|
74817
|
-
|
|
74818
|
-
|
|
74819
|
-
|
|
74820
|
-
|
|
74821
|
-
|
|
74822
|
-
|
|
74823
|
-
|
|
74824
|
-
|
|
74825
|
-
|
|
74826
|
-
|
|
74827
|
-
|
|
74828
|
-
|
|
74829
|
-
|
|
74830
|
-
|
|
74831
|
-
|
|
74832
|
-
|
|
74833
|
-
|
|
74834
|
-
|
|
74835
|
-
|
|
74836
|
-
|
|
74837
|
-
|
|
74838
|
-
|
|
74839
|
-
|
|
74840
|
-
|
|
74841
|
-
|
|
74842
|
-
|
|
74843
|
-
|
|
74844
|
-
|
|
74845
|
-
|
|
74846
|
-
|
|
74847
|
-
|
|
74848
|
-
|
|
74849
|
-
|
|
74850
|
-
|
|
74851
|
-
|
|
74852
|
-
|
|
74853
|
-
|
|
74854
|
-
|
|
74855
|
-
|
|
74856
|
-
|
|
74857
|
-
|
|
74858
|
-
|
|
74859
|
-
|
|
74860
|
-
|
|
74861
|
-
|
|
74862
|
-
|
|
74863
|
-
|
|
74864
|
-
|
|
74865
|
-
|
|
74866
|
-
|
|
74867
|
-
|
|
74868
|
-
|
|
74869
|
-
|
|
74870
|
-
|
|
74871
|
-
|
|
74872
|
-
|
|
74873
|
-
|
|
74874
|
-
|
|
74875
|
-
|
|
74876
|
-
|
|
74877
|
-
|
|
74878
|
-
|
|
74879
|
-
|
|
74880
|
-
|
|
74881
|
-
|
|
74882
|
-
|
|
74883
|
-
|
|
74884
|
-
|
|
74885
|
-
|
|
74886
|
-
|
|
74887
|
-
|
|
74888
|
-
|
|
74889
|
-
|
|
74890
|
-
|
|
74891
|
-
|
|
74892
|
-
|
|
74893
|
-
|
|
74894
|
-
|
|
74895
|
-
|
|
74896
|
-
|
|
74897
|
-
|
|
74898
|
-
|
|
74899
|
-
|
|
74900
|
-
|
|
74901
|
-
|
|
74902
|
-
|
|
74903
|
-
|
|
74904
|
-
|
|
74905
|
-
|
|
74906
|
-
|
|
74907
|
-
|
|
74908
|
-
|
|
74909
|
-
|
|
74910
|
-
|
|
74911
|
-
|
|
74912
|
-
|
|
74913
|
-
|
|
74914
|
-
|
|
74915
|
-
|
|
74916
|
-
|
|
74917
|
-
|
|
74918
|
-
|
|
74919
|
-
|
|
74920
|
-
|
|
74921
|
-
|
|
74922
|
-
|
|
74923
|
-
|
|
74924
|
-
|
|
74925
|
-
|
|
74926
|
-
|
|
74927
|
-
|
|
74928
|
-
|
|
74929
|
-
|
|
74930
|
-
|
|
74931
|
-
|
|
74932
|
-
|
|
74933
|
-
if (
|
|
74934
|
-
|
|
74935
|
-
}
|
|
74936
|
-
|
|
74937
|
-
|
|
74938
|
-
|
|
74939
|
-
|
|
74940
|
-
|
|
74941
|
-
|
|
74942
|
-
|
|
74943
|
-
|
|
74944
|
-
|
|
74945
|
-
|
|
74946
|
-
|
|
74947
|
-
|
|
74948
|
-
|
|
74949
|
-
|
|
74950
|
-
|
|
74951
|
-
|
|
74952
|
-
|
|
74953
|
-
|
|
74954
|
-
|
|
74955
|
-
if (
|
|
74956
|
-
|
|
74957
|
-
|
|
74958
|
-
|
|
74959
|
-
|
|
74960
|
-
|
|
74961
|
-
}
|
|
74962
|
-
return
|
|
74963
|
-
}
|
|
74964
|
-
|
|
74965
|
-
|
|
74966
|
-
|
|
74967
|
-
|
|
74968
|
-
|
|
74969
|
-
|
|
74970
|
-
|
|
74971
|
-
|
|
74972
|
-
|
|
74973
|
-
|
|
74974
|
-
|
|
74975
|
-
|
|
74976
|
-
|
|
74977
|
-
|
|
74978
|
-
|
|
74979
|
-
|
|
74980
|
-
|
|
74981
|
-
|
|
74982
|
-
|
|
74983
|
-
|
|
74984
|
-
|
|
74985
|
-
|
|
74986
|
-
|
|
74987
|
-
}
|
|
74988
|
-
}
|
|
74989
|
-
else if (
|
|
74990
|
-
var
|
|
74991
|
-
|
|
74992
|
-
|
|
74993
|
-
|
|
74994
|
-
|
|
74995
|
-
|
|
74996
|
-
|
|
74997
|
-
|
|
74998
|
-
|
|
74999
|
-
|
|
75000
|
-
|
|
75001
|
-
|
|
75002
|
-
|
|
75003
|
-
|
|
75004
|
-
|
|
75005
|
-
|
|
75006
|
-
|
|
75007
|
-
|
|
75008
|
-
|
|
75009
|
-
|
|
75010
|
-
|
|
75011
|
-
|
|
75012
|
-
|
|
75013
|
-
|
|
75014
|
-
|
|
75015
|
-
|
|
75016
|
-
|
|
75017
|
-
|
|
75018
|
-
|
|
75019
|
-
|
|
75020
|
-
|
|
75021
|
-
|
|
75022
|
-
}
|
|
75023
|
-
function
|
|
75024
|
-
|
|
75025
|
-
|
|
75026
|
-
|
|
75027
|
-
|
|
75028
|
-
|
|
75029
|
-
|
|
75030
|
-
|
|
75031
|
-
|
|
75032
|
-
|
|
75033
|
-
|
|
75034
|
-
|
|
75035
|
-
|
|
75036
|
-
|
|
75037
|
-
|
|
75038
|
-
|
|
75039
|
-
|
|
75040
|
-
|
|
75041
|
-
|
|
75042
|
-
|
|
75043
|
-
|
|
75044
|
-
|
|
75045
|
-
|
|
75046
|
-
|
|
75047
|
-
|
|
75048
|
-
|
|
75049
|
-
|
|
75050
|
-
|
|
75051
|
-
|
|
75052
|
-
|
|
75053
|
-
|
|
75054
|
-
|
|
75055
|
-
|
|
75056
|
-
|
|
75057
|
-
|
|
75058
|
-
|
|
75059
|
-
|
|
75060
|
-
|
|
75061
|
-
|
|
75062
|
-
|
|
75063
|
-
|
|
75064
|
-
|
|
75065
|
-
|
|
75066
|
-
|
|
75067
|
-
|
|
75068
|
-
|
|
75069
|
-
|
|
75070
|
-
|
|
75071
|
-
|
|
75072
|
-
|
|
75073
|
-
|
|
75074
|
-
|
|
75075
|
-
|
|
75076
|
-
|
|
75077
|
-
|
|
75078
|
-
|
|
75079
|
-
|
|
75080
|
-
|
|
75081
|
-
|
|
75082
|
-
|
|
75083
|
-
|
|
75084
|
-
|
|
75085
|
-
|
|
75086
|
-
|
|
75087
|
-
|
|
75088
|
-
|
|
75089
|
-
|
|
75090
|
-
|
|
75091
|
-
|
|
75092
|
-
|
|
75093
|
-
|
|
75094
|
-
|
|
75095
|
-
|
|
75096
|
-
|
|
75097
|
-
|
|
75098
|
-
|
|
75099
|
-
|
|
75100
|
-
|
|
75101
|
-
|
|
75102
|
-
|
|
75103
|
-
|
|
75104
|
-
|
|
75105
|
-
|
|
75106
|
-
|
|
75107
|
-
|
|
75108
|
-
|
|
75109
|
-
|
|
75110
|
-
|
|
75111
|
-
|
|
75112
|
-
|
|
75113
|
-
|
|
75114
|
-
|
|
75115
|
-
|
|
75116
|
-
|
|
75117
|
-
|
|
75118
|
-
|
|
75119
|
-
|
|
75120
|
-
|
|
75121
|
-
|
|
75122
|
-
|
|
75123
|
-
|
|
75124
|
-
//
|
|
75125
|
-
|
|
75126
|
-
//
|
|
75127
|
-
|
|
75128
|
-
|
|
75129
|
-
|
|
75130
|
-
|
|
75131
|
-
|
|
75132
|
-
|
|
75133
|
-
|
|
75134
|
-
|
|
75135
|
-
|
|
75136
|
-
|
|
75137
|
-
|
|
75138
|
-
|
|
75139
|
-
|
|
75140
|
-
|
|
75141
|
-
|
|
75142
|
-
|
|
75143
|
-
|
|
75144
|
-
|
|
75145
|
-
|
|
75146
|
-
|
|
75147
|
-
|
|
75148
|
-
|
|
75149
|
-
|
|
75150
|
-
|
|
75151
|
-
|
|
75152
|
-
|
|
75153
|
-
|
|
75154
|
-
|
|
75155
|
-
|
|
75156
|
-
|
|
75157
|
-
|
|
75158
|
-
|
|
75159
|
-
|
|
75160
|
-
|
|
75161
|
-
|
|
75162
|
-
|
|
75163
|
-
|
|
75164
|
-
|
|
75165
|
-
|
|
75166
|
-
|
|
75167
|
-
|
|
75168
|
-
|
|
75169
|
-
|
|
75170
|
-
|
|
75171
|
-
|
|
75172
|
-
|
|
75173
|
-
|
|
75174
|
-
|
|
75175
|
-
|
|
75176
|
-
var
|
|
75177
|
-
|
|
75178
|
-
|
|
75179
|
-
|
|
75180
|
-
|
|
75181
|
-
|
|
75182
|
-
|
|
75183
|
-
|
|
75184
|
-
|
|
75185
|
-
|
|
75186
|
-
|
|
75187
|
-
|
|
75188
|
-
|
|
75189
|
-
|
|
75190
|
-
|
|
75191
|
-
|
|
75192
|
-
|
|
75193
|
-
|
|
75194
|
-
|
|
75195
|
-
|
|
75196
|
-
|
|
75197
|
-
|
|
75198
|
-
|
|
75199
|
-
|
|
75200
|
-
|
|
75201
|
-
|
|
75202
|
-
|
|
75203
|
-
|
|
75204
|
-
|
|
75205
|
-
|
|
75206
|
-
|
|
75207
|
-
|
|
75208
|
-
|
|
75209
|
-
|
|
75210
|
-
|
|
75211
|
-
|
|
75212
|
-
|
|
75213
|
-
|
|
75214
|
-
|
|
75215
|
-
|
|
75216
|
-
|
|
75217
|
-
|
|
75218
|
-
|
|
75219
|
-
|
|
75220
|
-
|
|
75221
|
-
|
|
75222
|
-
|
|
75223
|
-
|
|
75224
|
-
|
|
75225
|
-
|
|
75226
|
-
|
|
75227
|
-
|
|
75228
|
-
|
|
75229
|
-
|
|
75230
|
-
|
|
75231
|
-
|
|
75232
|
-
|
|
75233
|
-
|
|
75234
|
-
|
|
75235
|
-
|
|
75236
|
-
|
|
75237
|
-
|
|
75238
|
-
|
|
75239
|
-
|
|
75240
|
-
|
|
75241
|
-
|
|
75242
|
-
|
|
75243
|
-
|
|
75244
|
-
|
|
75245
|
-
|
|
75246
|
-
|
|
75247
|
-
|
|
75248
|
-
|
|
75249
|
-
|
|
75250
|
-
|
|
75251
|
-
|
|
75252
|
-
|
|
75253
|
-
|
|
75254
|
-
|
|
75255
|
-
|
|
75256
|
-
|
|
75257
|
-
|
|
75258
|
-
|
|
75259
|
-
|
|
75260
|
-
|
|
75261
|
-
|
|
75262
|
-
|
|
75263
|
-
|
|
75264
|
-
|
|
75265
|
-
|
|
75266
|
-
|
|
75267
|
-
|
|
75268
|
-
|
|
75269
|
-
}
|
|
75270
|
-
|
|
75271
|
-
|
|
75272
|
-
|
|
75273
|
-
|
|
75274
|
-
|
|
75275
|
-
|
|
75276
|
-
|
|
75277
|
-
|
|
75278
|
-
|
|
75279
|
-
|
|
75280
|
-
|
|
75281
|
-
|
|
75282
|
-
|
|
75283
|
-
|
|
75284
|
-
|
|
75285
|
-
|
|
75286
|
-
|
|
75287
|
-
|
|
75288
|
-
|
|
75289
|
-
|
|
75290
|
-
|
|
75291
|
-
|
|
75292
|
-
|
|
75293
|
-
|
|
75294
|
-
|
|
75295
|
-
|
|
75296
|
-
|
|
75297
|
-
|
|
75298
|
-
|
|
75299
|
-
|
|
75300
|
-
|
|
75301
|
-
|
|
75302
|
-
|
|
75303
|
-
|
|
75304
|
-
|
|
75305
|
-
|
|
75306
|
-
|
|
75307
|
-
|
|
75308
|
-
|
|
75309
|
-
|
|
75310
|
-
|
|
75311
|
-
|
|
75312
|
-
|
|
75313
|
-
|
|
75314
|
-
|
|
75315
|
-
|
|
75316
|
-
|
|
75317
|
-
}
|
|
75318
|
-
|
|
75319
|
-
|
|
75320
|
-
|
|
75321
|
-
|
|
75322
|
-
|
|
75323
|
-
|
|
75324
|
-
|
|
75325
|
-
|
|
75326
|
-
|
|
75327
|
-
|
|
75328
|
-
|
|
75329
|
-
|
|
75330
|
-
|
|
75331
|
-
|
|
75332
|
-
|
|
75333
|
-
|
|
75334
|
-
|
|
75335
|
-
|
|
75336
|
-
|
|
75337
|
-
|
|
75338
|
-
|
|
75339
|
-
|
|
75340
|
-
|
|
75341
|
-
|
|
75342
|
-
|
|
75343
|
-
|
|
75344
|
-
|
|
75345
|
-
|
|
75346
|
-
|
|
75347
|
-
|
|
75348
|
-
|
|
75349
|
-
|
|
75350
|
-
|
|
75351
|
-
|
|
75352
|
-
|
|
75353
|
-
|
|
75354
|
-
|
|
75355
|
-
|
|
75356
|
-
|
|
75357
|
-
|
|
75358
|
-
|
|
75359
|
-
|
|
75360
|
-
|
|
75361
|
-
|
|
75362
|
-
}
|
|
75363
|
-
|
|
75364
|
-
|
|
75365
|
-
|
|
75366
|
-
if (
|
|
75367
|
-
return
|
|
75368
|
-
}
|
|
75369
|
-
|
|
75370
|
-
|
|
75371
|
-
|
|
75372
|
-
|
|
75373
|
-
|
|
75374
|
-
var
|
|
75375
|
-
|
|
75376
|
-
|
|
75377
|
-
|
|
75378
|
-
|
|
75379
|
-
|
|
75380
|
-
|
|
75381
|
-
|
|
75382
|
-
|
|
75383
|
-
|
|
75384
|
-
|
|
75385
|
-
|
|
75386
|
-
|
|
75387
|
-
|
|
75388
|
-
|
|
75389
|
-
|
|
75390
|
-
|
|
75391
|
-
|
|
75392
|
-
|
|
75393
|
-
|
|
75394
|
-
|
|
75395
|
-
|
|
75396
|
-
|
|
75397
|
-
|
|
75398
|
-
|
|
75399
|
-
|
|
75400
|
-
|
|
75401
|
-
|
|
75402
|
-
|
|
75403
|
-
|
|
75404
|
-
|
|
75405
|
-
|
|
75406
|
-
*
|
|
75407
|
-
|
|
75408
|
-
|
|
75409
|
-
|
|
75410
|
-
|
|
75411
|
-
|
|
75412
|
-
|
|
75413
|
-
|
|
75414
|
-
|
|
75415
|
-
|
|
75416
|
-
|
|
75417
|
-
}
|
|
75418
|
-
}
|
|
75419
|
-
|
|
75420
|
-
|
|
75421
|
-
|
|
75422
|
-
|
|
75423
|
-
|
|
75424
|
-
|
|
75425
|
-
|
|
75426
|
-
|
|
75427
|
-
|
|
75428
|
-
|
|
75429
|
-
|
|
75430
|
-
|
|
75431
|
-
|
|
75432
|
-
|
|
75433
|
-
|
|
75434
|
-
|
|
75435
|
-
|
|
75436
|
-
|
|
75437
|
-
|
|
75438
|
-
|
|
75439
|
-
|
|
75440
|
-
|
|
75441
|
-
|
|
75442
|
-
|
|
75443
|
-
|
|
75444
|
-
|
|
75445
|
-
|
|
75446
|
-
|
|
75447
|
-
|
|
75448
|
-
|
|
75449
|
-
|
|
75450
|
-
|
|
75451
|
-
|
|
75452
|
-
|
|
75453
|
-
|
|
75454
|
-
|
|
75455
|
-
|
|
75456
|
-
|
|
75457
|
-
|
|
75458
|
-
|
|
75459
|
-
|
|
75460
|
-
|
|
75461
|
-
|
|
75462
|
-
|
|
75463
|
-
|
|
75464
|
-
|
|
75465
|
-
|
|
75466
|
-
|
|
75467
|
-
|
|
75468
|
-
|
|
75469
|
-
|
|
75470
|
-
|
|
75471
|
-
|
|
75472
|
-
|
|
75473
|
-
|
|
75474
|
-
|
|
75475
|
-
|
|
75476
|
-
|
|
75477
|
-
|
|
75478
|
-
}
|
|
75479
|
-
|
|
75480
|
-
|
|
75481
|
-
|
|
75482
|
-
|
|
75483
|
-
|
|
75484
|
-
|
|
75485
|
-
|
|
75486
|
-
|
|
75487
|
-
|
|
75488
|
-
|
|
75489
|
-
|
|
75490
|
-
|
|
75491
|
-
|
|
75492
|
-
|
|
75493
|
-
|
|
75494
|
-
|
|
75495
|
-
|
|
75496
|
-
|
|
75497
|
-
|
|
75498
|
-
|
|
75499
|
-
|
|
75500
|
-
|
|
75501
|
-
|
|
75502
|
-
|
|
75503
|
-
|
|
75504
|
-
|
|
75505
|
-
|
|
75506
|
-
|
|
75507
|
-
|
|
75508
|
-
|
|
75509
|
-
|
|
75510
|
-
|
|
75511
|
-
|
|
75512
|
-
|
|
75513
|
-
|
|
75514
|
-
|
|
75515
|
-
|
|
75516
|
-
|
|
75517
|
-
|
|
75518
|
-
|
|
75519
|
-
|
|
75520
|
-
|
|
75521
|
-
|
|
75522
|
-
|
|
75523
|
-
|
|
75524
|
-
|
|
75525
|
-
|
|
75526
|
-
|
|
75527
|
-
|
|
75528
|
-
|
|
75529
|
-
|
|
75530
|
-
|
|
75531
|
-
|
|
75532
|
-
|
|
75533
|
-
|
|
75534
|
-
|
|
75535
|
-
|
|
75536
|
-
|
|
75537
|
-
|
|
75538
|
-
|
|
75539
|
-
|
|
75540
|
-
|
|
75541
|
-
|
|
75542
|
-
|
|
75543
|
-
|
|
75544
|
-
|
|
75545
|
-
|
|
75546
|
-
|
|
75547
|
-
|
|
75548
|
-
|
|
75549
|
-
|
|
75550
|
-
|
|
75551
|
-
|
|
75552
|
-
|
|
75553
|
-
|
|
75554
|
-
|
|
75555
|
-
|
|
75556
|
-
|
|
75557
|
-
|
|
75558
|
-
|
|
75559
|
-
|
|
75560
|
-
|
|
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
|
-
|
|
75566
|
-
|
|
75567
|
-
|
|
75568
|
-
|
|
75569
|
-
|
|
75570
|
-
|
|
75571
|
-
var
|
|
75572
|
-
function
|
|
75573
|
-
|
|
75574
|
-
|
|
75575
|
-
|
|
75576
|
-
|
|
75577
|
-
|
|
75578
|
-
if (
|
|
75579
|
-
|
|
75580
|
-
|
|
75581
|
-
|
|
75582
|
-
|
|
75583
|
-
|
|
75584
|
-
|
|
75585
|
-
|
|
75586
|
-
|
|
75587
|
-
|
|
75588
|
-
|
|
75589
|
-
|
|
75590
|
-
|
|
75591
|
-
|
|
75592
|
-
|
|
75593
|
-
|
|
75594
|
-
|
|
75595
|
-
|
|
75596
|
-
|
|
75597
|
-
|
|
75598
|
-
|
|
75599
|
-
|
|
75600
|
-
|
|
75601
|
-
var
|
|
75602
|
-
|
|
75603
|
-
|
|
75604
|
-
|
|
75605
|
-
|
|
75606
|
-
|
|
75607
|
-
|
|
75608
|
-
|
|
75609
|
-
|
|
75610
|
-
|
|
75611
|
-
|
|
75612
|
-
|
|
75613
|
-
|
|
75614
|
-
|
|
75615
|
-
|
|
75616
|
-
|
|
75617
|
-
|
|
75618
|
-
|
|
75619
|
-
|
|
75620
|
-
|
|
75621
|
-
|
|
75622
|
-
|
|
75623
|
-
|
|
75624
|
-
|
|
75625
|
-
|
|
75626
|
-
|
|
75627
|
-
|
|
75628
|
-
|
|
75629
|
-
|
|
75630
|
-
|
|
75631
|
-
|
|
75632
|
-
|
|
75633
|
-
|
|
75634
|
-
|
|
75635
|
-
|
|
75636
|
-
|
|
75637
|
-
|
|
75638
|
-
|
|
75639
|
-
|
|
75640
|
-
|
|
75641
|
-
|
|
75642
|
-
|
|
75643
|
-
|
|
75644
|
-
|
|
75645
|
-
|
|
75646
|
-
|
|
75647
|
-
|
|
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.
|
|
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
|
|
80235
|
-
var
|
|
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 + "-" +
|
|
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
|
|
80935
|
+
case esm_start:
|
|
80491
80936
|
offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
|
|
80492
80937
|
break;
|
|
80493
80938
|
|
|
80494
|
-
case
|
|
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
|
|
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
|
-
|
|
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,
|
|
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);
|