xydata-tools 1.1.34 → 1.1.36
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/dist/components/sms/conf/service.js +2 -2
- package/dist/components/sms/gateway/service.js +10 -10
- package/dist/components/sms/log/service.js +2 -2
- package/dist/components/sms/template/service.js +6 -6
- package/dist/components/uploadFile/index.js +169 -49
- package/dist/types/components/uploadFile/index.d.ts +2 -0
- package/dist/types/utils/watermark.d.ts +5 -0
- package/dist/utils/watermark.js +582 -0
- package/package.json +69 -69
|
@@ -24,7 +24,7 @@ function _querySmsProperty() {
|
|
|
24
24
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
25
25
|
while (1) switch (_context.prev = _context.next) {
|
|
26
26
|
case 0:
|
|
27
|
-
return _context.abrupt("return", doRequest('/api/smsProperty/querySmsProperty', 'POST', params));
|
|
27
|
+
return _context.abrupt("return", doRequest('/api/xydata/smsProperty/querySmsProperty', 'POST', params));
|
|
28
28
|
case 1:
|
|
29
29
|
case "end":
|
|
30
30
|
return _context.stop();
|
|
@@ -41,7 +41,7 @@ function _saveSmsProperty() {
|
|
|
41
41
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
42
42
|
while (1) switch (_context2.prev = _context2.next) {
|
|
43
43
|
case 0:
|
|
44
|
-
return _context2.abrupt("return", doRequest('/api/smsProperty/saveSmsProperty', 'POST', params));
|
|
44
|
+
return _context2.abrupt("return", doRequest('/api/xydata/smsProperty/saveSmsProperty', 'POST', params));
|
|
45
45
|
case 1:
|
|
46
46
|
case "end":
|
|
47
47
|
return _context2.stop();
|
|
@@ -30,7 +30,7 @@ function _createSmsMachine() {
|
|
|
30
30
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
31
31
|
while (1) switch (_context.prev = _context.next) {
|
|
32
32
|
case 0:
|
|
33
|
-
return _context.abrupt("return", doRequest('/api/smsMachine/createSmsMachine', 'POST', params));
|
|
33
|
+
return _context.abrupt("return", doRequest('/api/xydata/smsMachine/createSmsMachine', 'POST', params));
|
|
34
34
|
case 1:
|
|
35
35
|
case "end":
|
|
36
36
|
return _context.stop();
|
|
@@ -61,7 +61,7 @@ function _querySmsProvider() {
|
|
|
61
61
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
62
62
|
while (1) switch (_context2.prev = _context2.next) {
|
|
63
63
|
case 0:
|
|
64
|
-
return _context2.abrupt("return", doRequest('/api/smsMachine/querySmsProvider', 'POST', params));
|
|
64
|
+
return _context2.abrupt("return", doRequest('/api/xydata/smsMachine/querySmsProvider', 'POST', params));
|
|
65
65
|
case 1:
|
|
66
66
|
case "end":
|
|
67
67
|
return _context2.stop();
|
|
@@ -84,7 +84,7 @@ function _updateSmsMachine() {
|
|
|
84
84
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
85
85
|
while (1) switch (_context3.prev = _context3.next) {
|
|
86
86
|
case 0:
|
|
87
|
-
return _context3.abrupt("return", doRequest('/api/smsMachine/updateSmsMachine', 'POST', params));
|
|
87
|
+
return _context3.abrupt("return", doRequest('/api/xydata/smsMachine/updateSmsMachine', 'POST', params));
|
|
88
88
|
case 1:
|
|
89
89
|
case "end":
|
|
90
90
|
return _context3.stop();
|
|
@@ -111,7 +111,7 @@ function _querySmsMachineById() {
|
|
|
111
111
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
112
112
|
while (1) switch (_context4.prev = _context4.next) {
|
|
113
113
|
case 0:
|
|
114
|
-
return _context4.abrupt("return", doRequest('/api/smsMachine/querySmsMachineById', 'POST', params));
|
|
114
|
+
return _context4.abrupt("return", doRequest('/api/xydata/smsMachine/querySmsMachineById', 'POST', params));
|
|
115
115
|
case 1:
|
|
116
116
|
case "end":
|
|
117
117
|
return _context4.stop();
|
|
@@ -134,7 +134,7 @@ function _querySmsMachinePage() {
|
|
|
134
134
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
135
135
|
while (1) switch (_context5.prev = _context5.next) {
|
|
136
136
|
case 0:
|
|
137
|
-
return _context5.abrupt("return", doRequest('/api/smsMachine/querySmsMachinePage', 'POST', params));
|
|
137
|
+
return _context5.abrupt("return", doRequest('/api/xydata/smsMachine/querySmsMachinePage', 'POST', params));
|
|
138
138
|
case 1:
|
|
139
139
|
case "end":
|
|
140
140
|
return _context5.stop();
|
|
@@ -157,7 +157,7 @@ function _deleteSmsMachine() {
|
|
|
157
157
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
158
158
|
while (1) switch (_context6.prev = _context6.next) {
|
|
159
159
|
case 0:
|
|
160
|
-
return _context6.abrupt("return", doRequest('/api/smsMachine/deleteSmsMachine', 'POST', params));
|
|
160
|
+
return _context6.abrupt("return", doRequest('/api/xydata/smsMachine/deleteSmsMachine', 'POST', params));
|
|
161
161
|
case 1:
|
|
162
162
|
case "end":
|
|
163
163
|
return _context6.stop();
|
|
@@ -180,7 +180,7 @@ function _enableSmsMachine() {
|
|
|
180
180
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
181
181
|
while (1) switch (_context7.prev = _context7.next) {
|
|
182
182
|
case 0:
|
|
183
|
-
return _context7.abrupt("return", doRequest('/api/smsMachine/enableSmsMachine', 'POST', params));
|
|
183
|
+
return _context7.abrupt("return", doRequest('/api/xydata/smsMachine/enableSmsMachine', 'POST', params));
|
|
184
184
|
case 1:
|
|
185
185
|
case "end":
|
|
186
186
|
return _context7.stop();
|
|
@@ -203,7 +203,7 @@ function _disableSmsMachine() {
|
|
|
203
203
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
204
204
|
while (1) switch (_context8.prev = _context8.next) {
|
|
205
205
|
case 0:
|
|
206
|
-
return _context8.abrupt("return", doRequest('/api/smsMachine/disableSmsMachine', 'POST', params));
|
|
206
|
+
return _context8.abrupt("return", doRequest('/api/xydata/smsMachine/disableSmsMachine', 'POST', params));
|
|
207
207
|
case 1:
|
|
208
208
|
case "end":
|
|
209
209
|
return _context8.stop();
|
|
@@ -226,7 +226,7 @@ function _querySmsMachineList() {
|
|
|
226
226
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
227
227
|
while (1) switch (_context9.prev = _context9.next) {
|
|
228
228
|
case 0:
|
|
229
|
-
return _context9.abrupt("return", doRequest('/api/smsMachine/querySmsMachineList', 'POST', params));
|
|
229
|
+
return _context9.abrupt("return", doRequest('/api/xydata/smsMachine/querySmsMachineList', 'POST', params));
|
|
230
230
|
case 1:
|
|
231
231
|
case "end":
|
|
232
232
|
return _context9.stop();
|
|
@@ -243,7 +243,7 @@ function _markDefaultMachine() {
|
|
|
243
243
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
244
244
|
while (1) switch (_context10.prev = _context10.next) {
|
|
245
245
|
case 0:
|
|
246
|
-
return _context10.abrupt("return", doRequest('/api/smsMachine/markDefaultMachine', 'POST', params));
|
|
246
|
+
return _context10.abrupt("return", doRequest('/api/xydata/smsMachine/markDefaultMachine', 'POST', params));
|
|
247
247
|
case 1:
|
|
248
248
|
case "end":
|
|
249
249
|
return _context10.stop();
|
|
@@ -29,7 +29,7 @@ function _querySmsSendLogPage() {
|
|
|
29
29
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
30
30
|
while (1) switch (_context.prev = _context.next) {
|
|
31
31
|
case 0:
|
|
32
|
-
return _context.abrupt("return", doRequest('/api/smsSendLog/querySmsSendLogPage', 'POST', params));
|
|
32
|
+
return _context.abrupt("return", doRequest('/api/xydata/smsSendLog/querySmsSendLogPage', 'POST', params));
|
|
33
33
|
case 1:
|
|
34
34
|
case "end":
|
|
35
35
|
return _context.stop();
|
|
@@ -46,7 +46,7 @@ function _querySmsSendLogById() {
|
|
|
46
46
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
47
47
|
while (1) switch (_context2.prev = _context2.next) {
|
|
48
48
|
case 0:
|
|
49
|
-
return _context2.abrupt("return", doRequest('/api/smsSendLog/querySmsSendLogById', 'POST', params));
|
|
49
|
+
return _context2.abrupt("return", doRequest('/api/xydata/smsSendLog/querySmsSendLogById', 'POST', params));
|
|
50
50
|
case 1:
|
|
51
51
|
case "end":
|
|
52
52
|
return _context2.stop();
|
|
@@ -34,7 +34,7 @@ function _querySmsTemplatePage() {
|
|
|
34
34
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
35
35
|
while (1) switch (_context.prev = _context.next) {
|
|
36
36
|
case 0:
|
|
37
|
-
return _context.abrupt("return", doRequest('/api/smsTemplate/querySmsTemplatePage', 'POST', params));
|
|
37
|
+
return _context.abrupt("return", doRequest('/api/xydata/smsTemplate/querySmsTemplatePage', 'POST', params));
|
|
38
38
|
case 1:
|
|
39
39
|
case "end":
|
|
40
40
|
return _context.stop();
|
|
@@ -65,7 +65,7 @@ function _createSmsTemplate() {
|
|
|
65
65
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
66
66
|
while (1) switch (_context2.prev = _context2.next) {
|
|
67
67
|
case 0:
|
|
68
|
-
return _context2.abrupt("return", doRequest('/api/smsTemplate/createSmsTemplate', 'POST', params));
|
|
68
|
+
return _context2.abrupt("return", doRequest('/api/xydata/smsTemplate/createSmsTemplate', 'POST', params));
|
|
69
69
|
case 1:
|
|
70
70
|
case "end":
|
|
71
71
|
return _context2.stop();
|
|
@@ -88,7 +88,7 @@ function _updateSmsTemplate() {
|
|
|
88
88
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
89
89
|
while (1) switch (_context3.prev = _context3.next) {
|
|
90
90
|
case 0:
|
|
91
|
-
return _context3.abrupt("return", doRequest('/api/smsTemplate/updateSmsTemplate', 'POST', params));
|
|
91
|
+
return _context3.abrupt("return", doRequest('/api/xydata/smsTemplate/updateSmsTemplate', 'POST', params));
|
|
92
92
|
case 1:
|
|
93
93
|
case "end":
|
|
94
94
|
return _context3.stop();
|
|
@@ -111,7 +111,7 @@ function _deleteSmsTemplate() {
|
|
|
111
111
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
112
112
|
while (1) switch (_context4.prev = _context4.next) {
|
|
113
113
|
case 0:
|
|
114
|
-
return _context4.abrupt("return", doRequest('/api/smsTemplate/deleteSmsTemplate', 'POST', params));
|
|
114
|
+
return _context4.abrupt("return", doRequest('/api/xydata/smsTemplate/deleteSmsTemplate', 'POST', params));
|
|
115
115
|
case 1:
|
|
116
116
|
case "end":
|
|
117
117
|
return _context4.stop();
|
|
@@ -134,7 +134,7 @@ function _querySmsTemplateById() {
|
|
|
134
134
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
135
135
|
while (1) switch (_context5.prev = _context5.next) {
|
|
136
136
|
case 0:
|
|
137
|
-
return _context5.abrupt("return", doRequest('/api/smsTemplate/querySmsTemplateById', 'POST', params));
|
|
137
|
+
return _context5.abrupt("return", doRequest('/api/xydata/smsTemplate/querySmsTemplateById', 'POST', params));
|
|
138
138
|
case 1:
|
|
139
139
|
case "end":
|
|
140
140
|
return _context5.stop();
|
|
@@ -151,7 +151,7 @@ function _markDefaultTemplate() {
|
|
|
151
151
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
152
152
|
while (1) switch (_context6.prev = _context6.next) {
|
|
153
153
|
case 0:
|
|
154
|
-
return _context6.abrupt("return", doRequest('/api/smsTemplate/markDefaultTemplate', 'POST', params));
|
|
154
|
+
return _context6.abrupt("return", doRequest('/api/xydata/smsTemplate/markDefaultTemplate', 'POST', params));
|
|
155
155
|
case 1:
|
|
156
156
|
case "end":
|
|
157
157
|
return _context6.stop();
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["beforeUpload"];
|
|
2
3
|
var _templateObject;
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
9
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
11
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
13
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
15
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
16
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -18,35 +24,37 @@ import { ConfigProvider, message, Upload, Image, FormItemProps, FormProps, Uploa
|
|
|
18
24
|
import { useState } from 'react';
|
|
19
25
|
import zhCN from 'antd/es/locale/zh_CN';
|
|
20
26
|
import styled from 'styled-components';
|
|
27
|
+
import { applyImageWatermark, isImageFile, normalizeWatermarkConfig, resolveWatermarkError, toUploadFile } from "../../utils/watermark.js";
|
|
21
28
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
29
|
var StyleBox = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\t.readonly {\n\t\t.ant-upload {\n\t\t\tdisplay: none;\n\t\t}\n\t}\n"])));
|
|
23
30
|
|
|
24
|
-
/**
|
|
25
|
-
* 附件上传组件
|
|
26
|
-
* @preserve
|
|
27
|
-
* @param {Object} props 组件的属性
|
|
28
|
-
* @param {FormProps} props.form 表单实例
|
|
29
|
-
* @param {string} props.label 表单标签
|
|
30
|
-
* @param {string} props.name 表单字段
|
|
31
|
-
* @param {Array<Object>} props.rules 表单校验规则
|
|
32
|
-
* @param {string} props.accept 接受上传的文件类型
|
|
33
|
-
* @param {string} props.action 上传的地址, 默认为:"/api/file/upload?type=openFile"
|
|
34
|
-
* @param {number} props.max 最大上传数量, 超过最大数量就会隐藏上传按钮
|
|
35
|
-
* @param {boolean} props.multiple 是否支持多选文件,开启后按住 ctrl 可选择多个文件
|
|
36
|
-
* @param {React.ReactNode} props.icon Button 或 Dragger 的图标
|
|
37
|
-
* @param {React.ReactNode} props.title Button 或 Dragger 的标题
|
|
38
|
-
* @param {React.ReactNode} props.description 当 listType 为 dragger 时的描述
|
|
39
|
-
* @param {string} props.listType 上传列表的内建样式, 可选值: text, picture, picture-card, dragger
|
|
40
|
-
* @param {Object|boolean} props.showUploadList 是否展示文件列表, 可设为一个对象,用于单独设定 showPreviewIcon, showRemoveIcon 等
|
|
41
|
-
* @param {boolean} props.readonly 是否只读
|
|
42
|
-
* @param {boolean} props.disabled 是否禁用
|
|
43
|
-
* @param {Object} props.checkFile 文件校验配置
|
|
44
|
-
* @param {Array<string>} [props.checkFile.suffixs] 限制的文件格式, 示例:["png", "jpg"]
|
|
45
|
-
* @param {number} [props.checkFile.maxSize] 限制的文件大小 (单位: KB), 示例:1024 表示限制 1MB
|
|
46
|
-
* @param {Function} props.onChange 上传文件改变时的回调
|
|
47
|
-
* @param {
|
|
48
|
-
* @param {
|
|
49
|
-
* @param {
|
|
31
|
+
/**
|
|
32
|
+
* 附件上传组件
|
|
33
|
+
* @preserve
|
|
34
|
+
* @param {Object} props 组件的属性
|
|
35
|
+
* @param {FormProps} props.form 表单实例
|
|
36
|
+
* @param {string} props.label 表单标签
|
|
37
|
+
* @param {string} props.name 表单字段
|
|
38
|
+
* @param {Array<Object>} props.rules 表单校验规则
|
|
39
|
+
* @param {string} props.accept 接受上传的文件类型
|
|
40
|
+
* @param {string} props.action 上传的地址, 默认为:"/api/file/upload?type=openFile"
|
|
41
|
+
* @param {number} props.max 最大上传数量, 超过最大数量就会隐藏上传按钮
|
|
42
|
+
* @param {boolean} props.multiple 是否支持多选文件,开启后按住 ctrl 可选择多个文件
|
|
43
|
+
* @param {React.ReactNode} props.icon Button 或 Dragger 的图标
|
|
44
|
+
* @param {React.ReactNode} props.title Button 或 Dragger 的标题
|
|
45
|
+
* @param {React.ReactNode} props.description 当 listType 为 dragger 时的描述
|
|
46
|
+
* @param {string} props.listType 上传列表的内建样式, 可选值: text, picture, picture-card, dragger
|
|
47
|
+
* @param {Object|boolean} props.showUploadList 是否展示文件列表, 可设为一个对象,用于单独设定 showPreviewIcon, showRemoveIcon 等
|
|
48
|
+
* @param {boolean} props.readonly 是否只读
|
|
49
|
+
* @param {boolean} props.disabled 是否禁用
|
|
50
|
+
* @param {Object} props.checkFile 文件校验配置
|
|
51
|
+
* @param {Array<string>} [props.checkFile.suffixs] 限制的文件格式, 示例:["png", "jpg"]
|
|
52
|
+
* @param {number} [props.checkFile.maxSize] 限制的文件大小 (单位: KB), 示例:1024 表示限制 1MB
|
|
53
|
+
* @param {Function} props.onChange 上传文件改变时的回调
|
|
54
|
+
* @param {Object} props.watermark 图片/视频上传前水印配置
|
|
55
|
+
* @param {FormItemProps} props.formItemOptions 表单项配置
|
|
56
|
+
* @param {UploadProps} props.uploadOptions 上传配置
|
|
57
|
+
* @param {ButtonProps} props.buttonOptions 上传按钮的配置
|
|
50
58
|
*/
|
|
51
59
|
var UploadFile = function UploadFile(props) {
|
|
52
60
|
var _useState = useState(false),
|
|
@@ -68,8 +76,11 @@ var UploadFile = function UploadFile(props) {
|
|
|
68
76
|
_props$buttonOptions = props.buttonOptions,
|
|
69
77
|
buttonOptions = _props$buttonOptions === void 0 ? {} : _props$buttonOptions,
|
|
70
78
|
checkFile = props.checkFile,
|
|
79
|
+
watermark = props.watermark,
|
|
71
80
|
onFileChange = props.onChange,
|
|
72
81
|
form = props.form;
|
|
82
|
+
var userBeforeUpload = uploadOptions.beforeUpload,
|
|
83
|
+
restUploadOptions = _objectWithoutProperties(uploadOptions, _excluded);
|
|
73
84
|
var formItemProps = _objectSpread({
|
|
74
85
|
label: props.label || '',
|
|
75
86
|
name: props.name || 'file',
|
|
@@ -91,8 +102,8 @@ var UploadFile = function UploadFile(props) {
|
|
|
91
102
|
SID: SID,
|
|
92
103
|
service: SERVICE_NAME || 'unknow'
|
|
93
104
|
},
|
|
94
|
-
beforeUpload: function beforeUpload(
|
|
95
|
-
return beforeUploadHandle(
|
|
105
|
+
beforeUpload: function beforeUpload(file, fileList) {
|
|
106
|
+
return beforeUploadHandle(file, fileList);
|
|
96
107
|
},
|
|
97
108
|
onPreview: function onPreview(file) {
|
|
98
109
|
return handlePreview(file, props.name);
|
|
@@ -108,7 +119,7 @@ var UploadFile = function UploadFile(props) {
|
|
|
108
119
|
}
|
|
109
120
|
},
|
|
110
121
|
maxCount: props.max
|
|
111
|
-
},
|
|
122
|
+
}, restUploadOptions);
|
|
112
123
|
|
|
113
124
|
// 上传的组件类型
|
|
114
125
|
var listType = uploadProps.listType ? uploadProps.listType : props.listType || 'text';
|
|
@@ -136,26 +147,135 @@ var UploadFile = function UploadFile(props) {
|
|
|
136
147
|
};
|
|
137
148
|
|
|
138
149
|
// 上传前校验
|
|
139
|
-
var beforeUploadHandle = function
|
|
140
|
-
var _ref =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
var beforeUploadHandle = /*#__PURE__*/function () {
|
|
151
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file, fileList) {
|
|
152
|
+
var _ref2, suffixs, maxSize, _file$name, name, targetFile, beforeUploadResult, normalizedWatermark, _targetFile, _targetFile2, _targetFile3, resultFile, processorResult, fallbackResult;
|
|
153
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
154
|
+
while (1) switch (_context.prev = _context.next) {
|
|
155
|
+
case 0:
|
|
156
|
+
_ref2 = checkFile || {}, suffixs = _ref2.suffixs, maxSize = _ref2.maxSize;
|
|
157
|
+
if (!suffixs) {
|
|
158
|
+
_context.next = 6;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
name = (_file$name = file.name) === null || _file$name === void 0 || (_file$name = _file$name.split('.')) === null || _file$name === void 0 ? void 0 : _file$name.splice(-1)[0];
|
|
162
|
+
if (suffixs.includes(name.toLocaleLowerCase())) {
|
|
163
|
+
_context.next = 6;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
message.error("\u4E0D\u652F\u6301".concat(file.name, "\u8BE5\u79CD\u683C\u5F0F\u6587\u4EF6"));
|
|
167
|
+
return _context.abrupt("return", Upload.LIST_IGNORE);
|
|
168
|
+
case 6:
|
|
169
|
+
if (!(maxSize > 0)) {
|
|
170
|
+
_context.next = 10;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (!(file.size / 1024 > maxSize)) {
|
|
174
|
+
_context.next = 10;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
message.error("\u8BF7\u9009\u62E9\u5C0F\u4E8E".concat(maxSize / 1024, "MB\u7684\u6587\u4EF6!"));
|
|
178
|
+
return _context.abrupt("return", Upload.LIST_IGNORE);
|
|
179
|
+
case 10:
|
|
180
|
+
targetFile = file;
|
|
181
|
+
if (!(typeof userBeforeUpload === 'function')) {
|
|
182
|
+
_context.next = 18;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
_context.next = 14;
|
|
186
|
+
return userBeforeUpload(targetFile, fileList);
|
|
187
|
+
case 14:
|
|
188
|
+
beforeUploadResult = _context.sent;
|
|
189
|
+
if (!(beforeUploadResult === false || beforeUploadResult === Upload.LIST_IGNORE)) {
|
|
190
|
+
_context.next = 17;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
return _context.abrupt("return", beforeUploadResult);
|
|
194
|
+
case 17:
|
|
195
|
+
if (beforeUploadResult instanceof Blob) {
|
|
196
|
+
targetFile = toUploadFile(beforeUploadResult, targetFile);
|
|
197
|
+
}
|
|
198
|
+
case 18:
|
|
199
|
+
normalizedWatermark = normalizeWatermarkConfig(watermark);
|
|
200
|
+
if (watermark !== null && watermark !== void 0 && watermark.debug) {
|
|
201
|
+
console.log('[UploadFile watermark beforeUpload]', {
|
|
202
|
+
rawItems: watermark === null || watermark === void 0 ? void 0 : watermark.items,
|
|
203
|
+
normalizedItems: normalizedWatermark === null || normalizedWatermark === void 0 ? void 0 : normalizedWatermark.items,
|
|
204
|
+
file: {
|
|
205
|
+
name: (_targetFile = targetFile) === null || _targetFile === void 0 ? void 0 : _targetFile.name,
|
|
206
|
+
type: (_targetFile2 = targetFile) === null || _targetFile2 === void 0 ? void 0 : _targetFile2.type,
|
|
207
|
+
size: (_targetFile3 = targetFile) === null || _targetFile3 === void 0 ? void 0 : _targetFile3.size
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (!(!normalizedWatermark || !isImageFile(targetFile))) {
|
|
212
|
+
_context.next = 22;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
return _context.abrupt("return", targetFile);
|
|
216
|
+
case 22:
|
|
217
|
+
setLoading(true);
|
|
218
|
+
_context.prev = 23;
|
|
219
|
+
if (!(typeof normalizedWatermark.processor === 'function')) {
|
|
220
|
+
_context.next = 31;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
_context.next = 27;
|
|
224
|
+
return normalizedWatermark.processor(targetFile, {
|
|
225
|
+
file: targetFile,
|
|
226
|
+
originFile: file,
|
|
227
|
+
fileList: fileList,
|
|
228
|
+
watermark: normalizedWatermark
|
|
229
|
+
});
|
|
230
|
+
case 27:
|
|
231
|
+
processorResult = _context.sent;
|
|
232
|
+
resultFile = processorResult instanceof Blob ? toUploadFile(processorResult, targetFile) : processorResult || targetFile;
|
|
233
|
+
_context.next = 34;
|
|
234
|
+
break;
|
|
235
|
+
case 31:
|
|
236
|
+
_context.next = 33;
|
|
237
|
+
return applyImageWatermark(targetFile, normalizedWatermark);
|
|
238
|
+
case 33:
|
|
239
|
+
resultFile = _context.sent;
|
|
240
|
+
case 34:
|
|
241
|
+
setLoading(false);
|
|
242
|
+
return _context.abrupt("return", resultFile);
|
|
243
|
+
case 38:
|
|
244
|
+
_context.prev = 38;
|
|
245
|
+
_context.t0 = _context["catch"](23);
|
|
246
|
+
setLoading(false);
|
|
247
|
+
_context.next = 43;
|
|
248
|
+
return resolveWatermarkError(_context.t0, {
|
|
249
|
+
file: targetFile,
|
|
250
|
+
originFile: file,
|
|
251
|
+
fileList: fileList,
|
|
252
|
+
watermark: normalizedWatermark
|
|
253
|
+
});
|
|
254
|
+
case 43:
|
|
255
|
+
fallbackResult = _context.sent;
|
|
256
|
+
if (!(fallbackResult === false)) {
|
|
257
|
+
_context.next = 46;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
return _context.abrupt("return", Upload.LIST_IGNORE);
|
|
261
|
+
case 46:
|
|
262
|
+
if (!(fallbackResult instanceof Blob)) {
|
|
263
|
+
_context.next = 48;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
return _context.abrupt("return", toUploadFile(fallbackResult, targetFile));
|
|
267
|
+
case 48:
|
|
268
|
+
return _context.abrupt("return", targetFile);
|
|
269
|
+
case 49:
|
|
270
|
+
case "end":
|
|
271
|
+
return _context.stop();
|
|
272
|
+
}
|
|
273
|
+
}, _callee, null, [[23, 38]]);
|
|
274
|
+
}));
|
|
275
|
+
return function beforeUploadHandle(_x, _x2) {
|
|
276
|
+
return _ref.apply(this, arguments);
|
|
277
|
+
};
|
|
278
|
+
}();
|
|
159
279
|
|
|
160
280
|
// 获取当前预览下标
|
|
161
281
|
var getCurrent = function getCurrent() {
|
|
@@ -22,6 +22,7 @@ export default UploadFile;
|
|
|
22
22
|
* @param {Array<string>} [props.checkFile.suffixs] 限制的文件格式, 示例:["png", "jpg"]
|
|
23
23
|
* @param {number} [props.checkFile.maxSize] 限制的文件大小 (单位: KB), 示例:1024 表示限制 1MB
|
|
24
24
|
* @param {Function} props.onChange 上传文件改变时的回调
|
|
25
|
+
* @param {Object} props.watermark 图片/视频上传前水印配置
|
|
25
26
|
* @param {FormItemProps} props.formItemOptions 表单项配置
|
|
26
27
|
* @param {UploadProps} props.uploadOptions 上传配置
|
|
27
28
|
* @param {ButtonProps} props.buttonOptions 上传按钮的配置
|
|
@@ -47,6 +48,7 @@ declare function UploadFile(props: {
|
|
|
47
48
|
maxSize?: number;
|
|
48
49
|
};
|
|
49
50
|
onChange: Function;
|
|
51
|
+
watermark: any;
|
|
50
52
|
formItemOptions: FormItemProps;
|
|
51
53
|
uploadOptions: UploadProps;
|
|
52
54
|
buttonOptions: ButtonProps;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function toUploadFile(blob: any, sourceFile: any, fileName: any): any;
|
|
2
|
+
export function isImageFile(file: any): any;
|
|
3
|
+
export function normalizeWatermarkConfig(watermark: any): any;
|
|
4
|
+
export function applyImageWatermark(file: any, watermark: any): Promise<any>;
|
|
5
|
+
export function resolveWatermarkError(error: any, context: any): Promise<any>;
|
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
var DEFAULT_WATERMARK = {
|
|
14
|
+
enabled: true,
|
|
15
|
+
margin: 24,
|
|
16
|
+
items: []
|
|
17
|
+
};
|
|
18
|
+
var DEFAULT_WATERMARK_ITEM = {
|
|
19
|
+
type: 'text',
|
|
20
|
+
position: 'bottom-right',
|
|
21
|
+
mode: undefined,
|
|
22
|
+
fontSize: 24,
|
|
23
|
+
fontScale: undefined,
|
|
24
|
+
minFontSize: undefined,
|
|
25
|
+
maxFontSize: undefined,
|
|
26
|
+
spacing: undefined,
|
|
27
|
+
width: undefined,
|
|
28
|
+
height: undefined,
|
|
29
|
+
aspectRatio: undefined,
|
|
30
|
+
lockAspectRatio: true,
|
|
31
|
+
color: 'rgba(255,255,255,0.8)',
|
|
32
|
+
fontFamily: 'sans-serif',
|
|
33
|
+
opacity: 1,
|
|
34
|
+
rotate: 0
|
|
35
|
+
};
|
|
36
|
+
var IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'bmp', 'gif'];
|
|
37
|
+
var getFileExtension = function getFileExtension(file) {
|
|
38
|
+
var name = (file === null || file === void 0 ? void 0 : file.name) || '';
|
|
39
|
+
var ext = name.split('.').pop();
|
|
40
|
+
return ext ? ext.toLowerCase() : '';
|
|
41
|
+
};
|
|
42
|
+
var createObjectUrl = function createObjectUrl(file) {
|
|
43
|
+
if (!window.URL || !window.URL.createObjectURL) {
|
|
44
|
+
throw new Error('当前浏览器不支持读取本地文件');
|
|
45
|
+
}
|
|
46
|
+
return window.URL.createObjectURL(file);
|
|
47
|
+
};
|
|
48
|
+
var revokeObjectUrl = function revokeObjectUrl(url) {
|
|
49
|
+
var _window$URL;
|
|
50
|
+
if (url && (_window$URL = window.URL) !== null && _window$URL !== void 0 && _window$URL.revokeObjectURL) {
|
|
51
|
+
window.URL.revokeObjectURL(url);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var blobToFile = function blobToFile(blob, sourceFile, fileName) {
|
|
55
|
+
var name = fileName || (blob === null || blob === void 0 ? void 0 : blob.name) || (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.name) || "watermark_".concat(Date.now());
|
|
56
|
+
var options = {
|
|
57
|
+
type: blob.type || (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.type) || '',
|
|
58
|
+
lastModified: Date.now()
|
|
59
|
+
};
|
|
60
|
+
if (typeof File === 'function') {
|
|
61
|
+
return new File([blob], name, options);
|
|
62
|
+
}
|
|
63
|
+
blob.name = name;
|
|
64
|
+
blob.lastModified = options.lastModified;
|
|
65
|
+
return blob;
|
|
66
|
+
};
|
|
67
|
+
export var toUploadFile = function toUploadFile(blob, sourceFile, fileName) {
|
|
68
|
+
return blobToFile(blob, sourceFile, fileName);
|
|
69
|
+
};
|
|
70
|
+
export var isImageFile = function isImageFile(file) {
|
|
71
|
+
var type = (file === null || file === void 0 ? void 0 : file.type) || '';
|
|
72
|
+
var ext = getFileExtension(file);
|
|
73
|
+
return type.startsWith('image/') || IMAGE_EXTENSIONS.includes(ext);
|
|
74
|
+
};
|
|
75
|
+
export var normalizeWatermarkConfig = function normalizeWatermarkConfig(watermark) {
|
|
76
|
+
if (!watermark || watermark.enabled === false) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
var items = Array.isArray(watermark.items) ? watermark.items : [];
|
|
80
|
+
var normalizedItems = items.filter(function (item) {
|
|
81
|
+
if (!item) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (item.type === 'image') {
|
|
85
|
+
return !!(item.src || item.url || item.imageUrl);
|
|
86
|
+
}
|
|
87
|
+
return typeof item.text !== 'undefined' && "".concat(item.text).trim();
|
|
88
|
+
}).map(function (item) {
|
|
89
|
+
return _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_WATERMARK_ITEM), item), {}, {
|
|
90
|
+
text: typeof item.text === 'undefined' ? '' : "".concat(item.text)
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
if (!normalizedItems.length) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_WATERMARK), watermark), {}, {
|
|
97
|
+
items: normalizedItems
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var parseInsetCoordinate = function parseInsetCoordinate(value, base) {
|
|
101
|
+
var scale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
102
|
+
var isAdaptive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
103
|
+
if (value === undefined || value === null) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
if (typeof value === 'number') {
|
|
107
|
+
if (value > 0 && value < 1) {
|
|
108
|
+
return base * value;
|
|
109
|
+
}
|
|
110
|
+
if (isAdaptive) {
|
|
111
|
+
return value * scale;
|
|
112
|
+
}
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
if (typeof value === 'string') {
|
|
116
|
+
var cleanVal = value.trim();
|
|
117
|
+
if (!cleanVal) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
if (cleanVal.endsWith('!')) {
|
|
121
|
+
var numStr = cleanVal.slice(0, -1).trim();
|
|
122
|
+
if (numStr.endsWith('px')) {
|
|
123
|
+
numStr = numStr.slice(0, -2).trim();
|
|
124
|
+
}
|
|
125
|
+
var _num = parseFloat(numStr);
|
|
126
|
+
return Number.isFinite(_num) ? _num : undefined;
|
|
127
|
+
}
|
|
128
|
+
if (cleanVal.endsWith('%')) {
|
|
129
|
+
var _num2 = parseFloat(cleanVal.slice(0, -1));
|
|
130
|
+
return Number.isFinite(_num2) ? base * (_num2 / 100) : undefined;
|
|
131
|
+
}
|
|
132
|
+
if (cleanVal.endsWith('px')) {
|
|
133
|
+
var _num3 = parseFloat(cleanVal.slice(0, -2));
|
|
134
|
+
if (Number.isFinite(_num3)) {
|
|
135
|
+
return isAdaptive ? _num3 * scale : _num3;
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
var num = parseFloat(cleanVal);
|
|
140
|
+
if (Number.isFinite(num)) {
|
|
141
|
+
if (num > 0 && num < 1) {
|
|
142
|
+
return base * num;
|
|
143
|
+
}
|
|
144
|
+
return isAdaptive ? num * scale : num;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
};
|
|
149
|
+
var isFullscreenWatermarkItem = function isFullscreenWatermarkItem(item) {
|
|
150
|
+
return (item === null || item === void 0 ? void 0 : item.mode) === 'fullscreen' || (item === null || item === void 0 ? void 0 : item.fullscreen) === true;
|
|
151
|
+
};
|
|
152
|
+
var isImageWatermarkItem = function isImageWatermarkItem(item) {
|
|
153
|
+
return (item === null || item === void 0 ? void 0 : item.type) === 'image';
|
|
154
|
+
};
|
|
155
|
+
var resolveSpacing = function resolveSpacing(canvas, item) {
|
|
156
|
+
var _ref, _item$spacing;
|
|
157
|
+
var shortSide = Math.min(canvas.width, canvas.height);
|
|
158
|
+
var scale = shortSide / 1000;
|
|
159
|
+
var rawSpacing = (_ref = (_item$spacing = item.spacing) !== null && _item$spacing !== void 0 ? _item$spacing : item.gap) !== null && _ref !== void 0 ? _ref : 160;
|
|
160
|
+
var spacing = parseInsetCoordinate(rawSpacing, shortSide, scale, item.adaptive === true);
|
|
161
|
+
return typeof spacing === 'number' && spacing >= 0 ? spacing : 160;
|
|
162
|
+
};
|
|
163
|
+
var resolveTextPosition = function resolveTextPosition(canvas, item, margin) {
|
|
164
|
+
var position = item.position || 'bottom-right';
|
|
165
|
+
var isAdaptive = item.adaptive === true;
|
|
166
|
+
var shortSide = Math.min(canvas.width, canvas.height);
|
|
167
|
+
var scale = shortSide / 1000;
|
|
168
|
+
if (_typeof(position) === 'object' && position !== null) {
|
|
169
|
+
var hasInsetPosition = ['left', 'right', 'top', 'bottom'].some(function (key) {
|
|
170
|
+
return position[key] !== undefined && position[key] !== null && "".concat(position[key]).trim() !== '';
|
|
171
|
+
});
|
|
172
|
+
if (hasInsetPosition) {
|
|
173
|
+
var right = parseInsetCoordinate(position.right, canvas.width, scale, isAdaptive);
|
|
174
|
+
var left = parseInsetCoordinate(position.left, canvas.width, scale, isAdaptive);
|
|
175
|
+
var bottom = parseInsetCoordinate(position.bottom, canvas.height, scale, isAdaptive);
|
|
176
|
+
var top = parseInsetCoordinate(position.top, canvas.height, scale, isAdaptive);
|
|
177
|
+
var _resolvedMargin = isAdaptive ? margin * scale : margin;
|
|
178
|
+
var x = typeof right === 'number' ? canvas.width - right : typeof left === 'number' ? left : _resolvedMargin;
|
|
179
|
+
var y = typeof bottom === 'number' ? canvas.height - bottom : typeof top === 'number' ? top : _resolvedMargin;
|
|
180
|
+
return {
|
|
181
|
+
x: x,
|
|
182
|
+
y: y,
|
|
183
|
+
textAlign: item.textAlign || (position.right !== undefined && position.right !== null && "".concat(position.right).trim() !== '' ? 'right' : 'left'),
|
|
184
|
+
textBaseline: item.textBaseline || (position.bottom !== undefined && position.bottom !== null && "".concat(position.bottom).trim() !== '' ? 'bottom' : 'top')
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
x: parseInsetCoordinate(position.x, canvas.width, scale, isAdaptive) || 0,
|
|
189
|
+
y: parseInsetCoordinate(position.y, canvas.height, scale, isAdaptive) || 0,
|
|
190
|
+
textAlign: item.textAlign || 'left',
|
|
191
|
+
textBaseline: item.textBaseline || 'top'
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
var resolvedMargin = isAdaptive ? margin * scale : margin;
|
|
195
|
+
var positions = {
|
|
196
|
+
'top-left': {
|
|
197
|
+
x: resolvedMargin,
|
|
198
|
+
y: resolvedMargin,
|
|
199
|
+
textAlign: 'left',
|
|
200
|
+
textBaseline: 'top'
|
|
201
|
+
},
|
|
202
|
+
'top-right': {
|
|
203
|
+
x: canvas.width - resolvedMargin,
|
|
204
|
+
y: resolvedMargin,
|
|
205
|
+
textAlign: 'right',
|
|
206
|
+
textBaseline: 'top'
|
|
207
|
+
},
|
|
208
|
+
'bottom-left': {
|
|
209
|
+
x: resolvedMargin,
|
|
210
|
+
y: canvas.height - resolvedMargin,
|
|
211
|
+
textAlign: 'left',
|
|
212
|
+
textBaseline: 'bottom'
|
|
213
|
+
},
|
|
214
|
+
'bottom-right': {
|
|
215
|
+
x: canvas.width - resolvedMargin,
|
|
216
|
+
y: canvas.height - resolvedMargin,
|
|
217
|
+
textAlign: 'right',
|
|
218
|
+
textBaseline: 'bottom'
|
|
219
|
+
},
|
|
220
|
+
center: {
|
|
221
|
+
x: canvas.width / 2,
|
|
222
|
+
y: canvas.height / 2,
|
|
223
|
+
textAlign: 'center',
|
|
224
|
+
textBaseline: 'middle'
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
return positions[position] || positions['bottom-right'];
|
|
228
|
+
};
|
|
229
|
+
var loadWatermarkImage = function loadWatermarkImage(src) {
|
|
230
|
+
return new Promise(function (resolve, reject) {
|
|
231
|
+
var img = new window.Image();
|
|
232
|
+
if (!src.startsWith('blob:') && !src.startsWith('data:')) {
|
|
233
|
+
img.crossOrigin = 'anonymous';
|
|
234
|
+
}
|
|
235
|
+
img.onload = function () {
|
|
236
|
+
return resolve(img);
|
|
237
|
+
};
|
|
238
|
+
img.onerror = function () {
|
|
239
|
+
return reject(new Error('图片水印资源加载失败'));
|
|
240
|
+
};
|
|
241
|
+
img.src = src;
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
var resolveImageSize = function resolveImageSize(canvas, item, image) {
|
|
245
|
+
var shortSide = Math.min(canvas.width, canvas.height);
|
|
246
|
+
var scale = shortSide / 1000;
|
|
247
|
+
var naturalWidth = image.naturalWidth || image.width || 1;
|
|
248
|
+
var naturalHeight = image.naturalHeight || image.height || 1;
|
|
249
|
+
var configuredAspectRatio = Number(item.aspectRatio);
|
|
250
|
+
var aspectRatio = Number.isFinite(configuredAspectRatio) && configuredAspectRatio > 0 ? configuredAspectRatio : naturalWidth / naturalHeight;
|
|
251
|
+
var heightRatio = 1 / aspectRatio;
|
|
252
|
+
var width = parseInsetCoordinate(item.width, canvas.width, scale, item.adaptive === true);
|
|
253
|
+
var height = parseInsetCoordinate(item.height, canvas.height, scale, item.adaptive === true);
|
|
254
|
+
if (item.lockAspectRatio !== false) {
|
|
255
|
+
if (typeof width === 'number' && width > 0) {
|
|
256
|
+
return {
|
|
257
|
+
width: width,
|
|
258
|
+
height: width * heightRatio
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
if (typeof height === 'number' && height > 0) {
|
|
262
|
+
return {
|
|
263
|
+
width: height / heightRatio,
|
|
264
|
+
height: height
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (typeof width === 'number' && width > 0 && typeof height === 'number' && height > 0) {
|
|
269
|
+
return {
|
|
270
|
+
width: width,
|
|
271
|
+
height: height
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
if (typeof width === 'number' && width > 0) {
|
|
275
|
+
return {
|
|
276
|
+
width: width,
|
|
277
|
+
height: width * heightRatio
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
if (typeof height === 'number' && height > 0) {
|
|
281
|
+
return {
|
|
282
|
+
width: height / heightRatio,
|
|
283
|
+
height: height
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
var fallbackWidth = item.adaptive === true ? 160 * scale : 160;
|
|
287
|
+
return {
|
|
288
|
+
width: fallbackWidth,
|
|
289
|
+
height: fallbackWidth * heightRatio
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
var resolveBoxPosition = function resolveBoxPosition(canvas, item, margin, boxWidth, boxHeight) {
|
|
293
|
+
var position = item.position || 'bottom-right';
|
|
294
|
+
var isAdaptive = item.adaptive === true;
|
|
295
|
+
var shortSide = Math.min(canvas.width, canvas.height);
|
|
296
|
+
var scale = shortSide / 1000;
|
|
297
|
+
var resolvedMargin = isAdaptive ? margin * scale : margin;
|
|
298
|
+
if (_typeof(position) === 'object' && position !== null) {
|
|
299
|
+
var right = parseInsetCoordinate(position.right, canvas.width, scale, isAdaptive);
|
|
300
|
+
var left = parseInsetCoordinate(position.left, canvas.width, scale, isAdaptive);
|
|
301
|
+
var bottom = parseInsetCoordinate(position.bottom, canvas.height, scale, isAdaptive);
|
|
302
|
+
var top = parseInsetCoordinate(position.top, canvas.height, scale, isAdaptive);
|
|
303
|
+
var x = typeof right === 'number' ? canvas.width - right - boxWidth : typeof left === 'number' ? left : resolvedMargin;
|
|
304
|
+
var y = typeof bottom === 'number' ? canvas.height - bottom - boxHeight : typeof top === 'number' ? top : resolvedMargin;
|
|
305
|
+
return {
|
|
306
|
+
x: x,
|
|
307
|
+
y: y
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
var positions = {
|
|
311
|
+
'top-left': {
|
|
312
|
+
x: resolvedMargin,
|
|
313
|
+
y: resolvedMargin
|
|
314
|
+
},
|
|
315
|
+
'top-right': {
|
|
316
|
+
x: canvas.width - resolvedMargin - boxWidth,
|
|
317
|
+
y: resolvedMargin
|
|
318
|
+
},
|
|
319
|
+
'bottom-left': {
|
|
320
|
+
x: resolvedMargin,
|
|
321
|
+
y: canvas.height - resolvedMargin - boxHeight
|
|
322
|
+
},
|
|
323
|
+
'bottom-right': {
|
|
324
|
+
x: canvas.width - resolvedMargin - boxWidth,
|
|
325
|
+
y: canvas.height - resolvedMargin - boxHeight
|
|
326
|
+
},
|
|
327
|
+
center: {
|
|
328
|
+
x: (canvas.width - boxWidth) / 2,
|
|
329
|
+
y: (canvas.height - boxHeight) / 2
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
return positions[position] || positions['bottom-right'];
|
|
333
|
+
};
|
|
334
|
+
var clampNumber = function clampNumber(value, min, max) {
|
|
335
|
+
var result = value;
|
|
336
|
+
if (typeof min === 'number') {
|
|
337
|
+
result = Math.max(min, result);
|
|
338
|
+
}
|
|
339
|
+
if (typeof max === 'number') {
|
|
340
|
+
result = Math.min(max, result);
|
|
341
|
+
}
|
|
342
|
+
return result;
|
|
343
|
+
};
|
|
344
|
+
var resolveFontSize = function resolveFontSize(canvas, item) {
|
|
345
|
+
if (typeof item.fontScale === 'number' && item.fontScale > 0) {
|
|
346
|
+
var shortSide = Math.min(canvas.width, canvas.height);
|
|
347
|
+
var scaledSize = shortSide * item.fontScale;
|
|
348
|
+
var fallbackMin = typeof item.fontSize === 'number' ? item.fontSize : undefined;
|
|
349
|
+
return clampNumber(scaledSize, typeof item.minFontSize === 'number' ? item.minFontSize : fallbackMin, typeof item.maxFontSize === 'number' ? item.maxFontSize : undefined);
|
|
350
|
+
}
|
|
351
|
+
var baseFontSize = 24;
|
|
352
|
+
var isFixed = false;
|
|
353
|
+
if (typeof item.fontSize === 'number') {
|
|
354
|
+
baseFontSize = item.fontSize;
|
|
355
|
+
} else if (typeof item.fontSize === 'string') {
|
|
356
|
+
var cleanVal = item.fontSize.trim();
|
|
357
|
+
if (cleanVal.endsWith('!')) {
|
|
358
|
+
isFixed = true;
|
|
359
|
+
cleanVal = cleanVal.slice(0, -1).trim();
|
|
360
|
+
}
|
|
361
|
+
if (cleanVal.endsWith('px')) {
|
|
362
|
+
cleanVal = cleanVal.slice(0, -2).trim();
|
|
363
|
+
}
|
|
364
|
+
var parsed = parseFloat(cleanVal);
|
|
365
|
+
if (Number.isFinite(parsed)) {
|
|
366
|
+
baseFontSize = parsed;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (item.adaptive === true && !isFixed) {
|
|
370
|
+
var _shortSide = Math.min(canvas.width, canvas.height);
|
|
371
|
+
var resolvedSize = baseFontSize * (_shortSide / 1000);
|
|
372
|
+
return resolvedSize > 0 ? resolvedSize : baseFontSize;
|
|
373
|
+
}
|
|
374
|
+
return baseFontSize;
|
|
375
|
+
};
|
|
376
|
+
var drawWatermarkItems = /*#__PURE__*/function () {
|
|
377
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ctx, canvas, watermark) {
|
|
378
|
+
var _iterator, _step, item, margin, fontSize, point, src, watermarkImage, size, box, spacing, textWidth, stepX, stepY, overflow, y, x;
|
|
379
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
380
|
+
while (1) switch (_context.prev = _context.next) {
|
|
381
|
+
case 0:
|
|
382
|
+
_iterator = _createForOfIteratorHelper(watermark.items);
|
|
383
|
+
_context.prev = 1;
|
|
384
|
+
_iterator.s();
|
|
385
|
+
case 3:
|
|
386
|
+
if ((_step = _iterator.n()).done) {
|
|
387
|
+
_context.next = 29;
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
item = _step.value;
|
|
391
|
+
margin = typeof item.margin === 'number' ? item.margin : watermark.margin;
|
|
392
|
+
fontSize = resolveFontSize(canvas, item);
|
|
393
|
+
point = resolveTextPosition(canvas, item, margin);
|
|
394
|
+
if (watermark.debug) {
|
|
395
|
+
console.log('[UploadFile watermark]', {
|
|
396
|
+
text: item.text,
|
|
397
|
+
type: item.type,
|
|
398
|
+
src: item.src || item.url || item.imageUrl,
|
|
399
|
+
mode: item.mode,
|
|
400
|
+
position: item.position,
|
|
401
|
+
margin: margin,
|
|
402
|
+
spacing: item.spacing,
|
|
403
|
+
width: item.width,
|
|
404
|
+
height: item.height,
|
|
405
|
+
fontSize: fontSize,
|
|
406
|
+
fontScale: item.fontScale,
|
|
407
|
+
minFontSize: item.minFontSize,
|
|
408
|
+
maxFontSize: item.maxFontSize,
|
|
409
|
+
canvas: {
|
|
410
|
+
width: canvas.width,
|
|
411
|
+
height: canvas.height
|
|
412
|
+
},
|
|
413
|
+
resolved: point
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
ctx.save();
|
|
417
|
+
ctx.globalAlpha = item.opacity;
|
|
418
|
+
if (!isImageWatermarkItem(item)) {
|
|
419
|
+
_context.next = 23;
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
src = item.src || item.url || item.imageUrl;
|
|
423
|
+
_context.next = 15;
|
|
424
|
+
return loadWatermarkImage(src);
|
|
425
|
+
case 15:
|
|
426
|
+
watermarkImage = _context.sent;
|
|
427
|
+
size = resolveImageSize(canvas, item, watermarkImage);
|
|
428
|
+
box = resolveBoxPosition(canvas, item, margin, size.width, size.height);
|
|
429
|
+
ctx.translate(box.x + size.width / 2, box.y + size.height / 2);
|
|
430
|
+
ctx.rotate((item.rotate || 0) * Math.PI / 180);
|
|
431
|
+
ctx.drawImage(watermarkImage, -size.width / 2, -size.height / 2, size.width, size.height);
|
|
432
|
+
ctx.restore();
|
|
433
|
+
return _context.abrupt("continue", 27);
|
|
434
|
+
case 23:
|
|
435
|
+
ctx.font = "".concat(fontSize, "px ").concat(item.fontFamily);
|
|
436
|
+
ctx.fillStyle = item.color;
|
|
437
|
+
if (isFullscreenWatermarkItem(item)) {
|
|
438
|
+
spacing = resolveSpacing(canvas, item);
|
|
439
|
+
textWidth = ctx.measureText(item.text).width;
|
|
440
|
+
stepX = Math.max(textWidth + spacing, fontSize * 4);
|
|
441
|
+
stepY = Math.max(fontSize + spacing, fontSize * 3);
|
|
442
|
+
overflow = Math.max(canvas.width, canvas.height);
|
|
443
|
+
ctx.textAlign = 'center';
|
|
444
|
+
ctx.textBaseline = 'middle';
|
|
445
|
+
for (y = -overflow; y <= canvas.height + overflow; y += stepY) {
|
|
446
|
+
for (x = -overflow; x <= canvas.width + overflow; x += stepX) {
|
|
447
|
+
ctx.save();
|
|
448
|
+
ctx.translate(x, y);
|
|
449
|
+
ctx.rotate((item.rotate || 0) * Math.PI / 180);
|
|
450
|
+
ctx.fillText(item.text, 0, 0);
|
|
451
|
+
ctx.restore();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
} else {
|
|
455
|
+
ctx.textAlign = point.textAlign;
|
|
456
|
+
ctx.textBaseline = point.textBaseline;
|
|
457
|
+
ctx.translate(point.x, point.y);
|
|
458
|
+
ctx.rotate((item.rotate || 0) * Math.PI / 180);
|
|
459
|
+
ctx.fillText(item.text, 0, 0);
|
|
460
|
+
}
|
|
461
|
+
ctx.restore();
|
|
462
|
+
case 27:
|
|
463
|
+
_context.next = 3;
|
|
464
|
+
break;
|
|
465
|
+
case 29:
|
|
466
|
+
_context.next = 34;
|
|
467
|
+
break;
|
|
468
|
+
case 31:
|
|
469
|
+
_context.prev = 31;
|
|
470
|
+
_context.t0 = _context["catch"](1);
|
|
471
|
+
_iterator.e(_context.t0);
|
|
472
|
+
case 34:
|
|
473
|
+
_context.prev = 34;
|
|
474
|
+
_iterator.f();
|
|
475
|
+
return _context.finish(34);
|
|
476
|
+
case 37:
|
|
477
|
+
case "end":
|
|
478
|
+
return _context.stop();
|
|
479
|
+
}
|
|
480
|
+
}, _callee, null, [[1, 31, 34, 37]]);
|
|
481
|
+
}));
|
|
482
|
+
return function drawWatermarkItems(_x, _x2, _x3) {
|
|
483
|
+
return _ref2.apply(this, arguments);
|
|
484
|
+
};
|
|
485
|
+
}();
|
|
486
|
+
var canvasToBlob = function canvasToBlob(canvas, type) {
|
|
487
|
+
var quality = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.92;
|
|
488
|
+
return new Promise(function (resolve, reject) {
|
|
489
|
+
if (!canvas.toBlob) {
|
|
490
|
+
reject(new Error('当前浏览器不支持 Canvas 文件导出'));
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
canvas.toBlob(function (blob) {
|
|
494
|
+
if (blob) {
|
|
495
|
+
resolve(blob);
|
|
496
|
+
} else {
|
|
497
|
+
reject(new Error('水印图片生成失败'));
|
|
498
|
+
}
|
|
499
|
+
}, type, quality);
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
export var applyImageWatermark = /*#__PURE__*/function () {
|
|
503
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file, watermark) {
|
|
504
|
+
var url, image, canvas, ctx, outputType, blob;
|
|
505
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
506
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
507
|
+
case 0:
|
|
508
|
+
url = createObjectUrl(file);
|
|
509
|
+
_context2.prev = 1;
|
|
510
|
+
_context2.next = 4;
|
|
511
|
+
return new Promise(function (resolve, reject) {
|
|
512
|
+
var img = new window.Image();
|
|
513
|
+
img.onload = function () {
|
|
514
|
+
return resolve(img);
|
|
515
|
+
};
|
|
516
|
+
img.onerror = function () {
|
|
517
|
+
return reject(new Error('图片加载失败,无法添加水印'));
|
|
518
|
+
};
|
|
519
|
+
img.src = url;
|
|
520
|
+
});
|
|
521
|
+
case 4:
|
|
522
|
+
image = _context2.sent;
|
|
523
|
+
canvas = document.createElement('canvas');
|
|
524
|
+
canvas.width = image.naturalWidth || image.width;
|
|
525
|
+
canvas.height = image.naturalHeight || image.height;
|
|
526
|
+
ctx = canvas.getContext('2d');
|
|
527
|
+
if (ctx) {
|
|
528
|
+
_context2.next = 11;
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
throw new Error('当前浏览器不支持 Canvas 绘制');
|
|
532
|
+
case 11:
|
|
533
|
+
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
534
|
+
_context2.next = 14;
|
|
535
|
+
return drawWatermarkItems(ctx, canvas, watermark);
|
|
536
|
+
case 14:
|
|
537
|
+
outputType = file.type && file.type !== 'image/svg+xml' ? file.type : 'image/png';
|
|
538
|
+
_context2.next = 17;
|
|
539
|
+
return canvasToBlob(canvas, outputType);
|
|
540
|
+
case 17:
|
|
541
|
+
blob = _context2.sent;
|
|
542
|
+
return _context2.abrupt("return", blobToFile(blob, file, file.name));
|
|
543
|
+
case 19:
|
|
544
|
+
_context2.prev = 19;
|
|
545
|
+
revokeObjectUrl(url);
|
|
546
|
+
return _context2.finish(19);
|
|
547
|
+
case 22:
|
|
548
|
+
case "end":
|
|
549
|
+
return _context2.stop();
|
|
550
|
+
}
|
|
551
|
+
}, _callee2, null, [[1,, 19, 22]]);
|
|
552
|
+
}));
|
|
553
|
+
return function applyImageWatermark(_x4, _x5) {
|
|
554
|
+
return _ref3.apply(this, arguments);
|
|
555
|
+
};
|
|
556
|
+
}();
|
|
557
|
+
export var resolveWatermarkError = /*#__PURE__*/function () {
|
|
558
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error, context) {
|
|
559
|
+
var _context$watermark;
|
|
560
|
+
var handler;
|
|
561
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
562
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
563
|
+
case 0:
|
|
564
|
+
console.error('[UploadFile watermark error]', error);
|
|
565
|
+
handler = context === null || context === void 0 || (_context$watermark = context.watermark) === null || _context$watermark === void 0 ? void 0 : _context$watermark.onWatermarkError;
|
|
566
|
+
if (!(typeof handler !== 'function')) {
|
|
567
|
+
_context3.next = 4;
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
return _context3.abrupt("return", true);
|
|
571
|
+
case 4:
|
|
572
|
+
return _context3.abrupt("return", handler(error, context));
|
|
573
|
+
case 5:
|
|
574
|
+
case "end":
|
|
575
|
+
return _context3.stop();
|
|
576
|
+
}
|
|
577
|
+
}, _callee3);
|
|
578
|
+
}));
|
|
579
|
+
return function resolveWatermarkError(_x6, _x7) {
|
|
580
|
+
return _ref4.apply(this, arguments);
|
|
581
|
+
};
|
|
582
|
+
}();
|
package/package.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "xydata-tools",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "xydata tools",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"types": "dist/types/index.d.ts",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "https://172.16.1.252/wuxiaohu/xydata-tools.git"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://172.16.1.252/wuxiaohu/xydata-tools",
|
|
13
|
-
"scripts": {
|
|
14
|
-
"dev": "father dev",
|
|
15
|
-
"build": "father build",
|
|
16
|
-
"generate-types": "tsc --emitDeclarationOnly --project tsconfig.json",
|
|
17
|
-
"prepublishOnly": "npm run build && npm run generate-types"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [],
|
|
20
|
-
"authors": [],
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"sideEffects": [
|
|
23
|
-
"*.css",
|
|
24
|
-
"*.less"
|
|
25
|
-
],
|
|
26
|
-
"files": [
|
|
27
|
-
"/dist"
|
|
28
|
-
],
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"@ant-design/icons": "^4.5.0",
|
|
34
|
-
"@ant-design/pro-form": "^1.69.4",
|
|
35
|
-
"@ant-design/pro-table": "^2.80.8",
|
|
36
|
-
"antd": "^4.24.16",
|
|
37
|
-
"moment": "^2.30.1",
|
|
38
|
-
"react": "^17.0.0",
|
|
39
|
-
"react-dom": "^17.0.0",
|
|
40
|
-
"umi": "^3.5.20"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@ant-design/icons": "^4.5.0",
|
|
44
|
-
"@ant-design/pro-form": "^1.69.4",
|
|
45
|
-
"@ant-design/pro-table": "^2.80.8",
|
|
46
|
-
"@babel/core": "7.24.9",
|
|
47
|
-
"@babel/preset-env": "7.24.8",
|
|
48
|
-
"@babel/preset-react": "7.24.7",
|
|
49
|
-
"@vitejs/plugin-vue2": "2.3.1",
|
|
50
|
-
"antd": "^4.24.16",
|
|
51
|
-
"cross-env": "^10.1.0",
|
|
52
|
-
"dva": "^2.6.0-beta.23",
|
|
53
|
-
"father": "4.1.5",
|
|
54
|
-
"moment": "^2.30.1",
|
|
55
|
-
"react": "^17.0.0",
|
|
56
|
-
"react-dom": "^17.0.0",
|
|
57
|
-
"terser": "5.31.3",
|
|
58
|
-
"umi": "^3.5.20",
|
|
59
|
-
"vue": "2.7.16",
|
|
60
|
-
"vue-loader": "15.11.1",
|
|
61
|
-
"vue-template-compiler": "2.7.16"
|
|
62
|
-
},
|
|
63
|
-
"dependencies": {
|
|
64
|
-
"@zhengxs/js.tree": "0.5.0",
|
|
65
|
-
"querystring": "0.2.1",
|
|
66
|
-
"react-json-view": "^1.21.3",
|
|
67
|
-
"styled-components": "4.4.1"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "xydata-tools",
|
|
3
|
+
"version": "1.1.36",
|
|
4
|
+
"description": "xydata tools",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://172.16.1.252/wuxiaohu/xydata-tools.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://172.16.1.252/wuxiaohu/xydata-tools",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"dev": "father dev",
|
|
15
|
+
"build": "father build",
|
|
16
|
+
"generate-types": "tsc --emitDeclarationOnly --project tsconfig.json",
|
|
17
|
+
"prepublishOnly": "npm run build && npm run generate-types"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"authors": [],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"*.css",
|
|
24
|
+
"*.less"
|
|
25
|
+
],
|
|
26
|
+
"files": [
|
|
27
|
+
"/dist"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@ant-design/icons": "^4.5.0",
|
|
34
|
+
"@ant-design/pro-form": "^1.69.4",
|
|
35
|
+
"@ant-design/pro-table": "^2.80.8",
|
|
36
|
+
"antd": "^4.24.16",
|
|
37
|
+
"moment": "^2.30.1",
|
|
38
|
+
"react": "^17.0.0",
|
|
39
|
+
"react-dom": "^17.0.0",
|
|
40
|
+
"umi": "^3.5.20"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@ant-design/icons": "^4.5.0",
|
|
44
|
+
"@ant-design/pro-form": "^1.69.4",
|
|
45
|
+
"@ant-design/pro-table": "^2.80.8",
|
|
46
|
+
"@babel/core": "7.24.9",
|
|
47
|
+
"@babel/preset-env": "7.24.8",
|
|
48
|
+
"@babel/preset-react": "7.24.7",
|
|
49
|
+
"@vitejs/plugin-vue2": "2.3.1",
|
|
50
|
+
"antd": "^4.24.16",
|
|
51
|
+
"cross-env": "^10.1.0",
|
|
52
|
+
"dva": "^2.6.0-beta.23",
|
|
53
|
+
"father": "4.1.5",
|
|
54
|
+
"moment": "^2.30.1",
|
|
55
|
+
"react": "^17.0.0",
|
|
56
|
+
"react-dom": "^17.0.0",
|
|
57
|
+
"terser": "5.31.3",
|
|
58
|
+
"umi": "^3.5.20",
|
|
59
|
+
"vue": "2.7.16",
|
|
60
|
+
"vue-loader": "15.11.1",
|
|
61
|
+
"vue-template-compiler": "2.7.16"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@zhengxs/js.tree": "0.5.0",
|
|
65
|
+
"querystring": "0.2.1",
|
|
66
|
+
"react-json-view": "^1.21.3",
|
|
67
|
+
"styled-components": "4.4.1"
|
|
68
|
+
}
|
|
69
|
+
}
|