@yilianjituan/yilian_dgerm 0.0.1-alpha.32 → 0.0.1-alpha.35
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/CustomButtonModal/index.d.ts +4 -0
- package/dist/components/CustomButtonModal/index.interface.d.ts +14 -0
- package/dist/components/CustomButtonModal/index.interface.js +1 -0
- package/dist/components/CustomButtonModal/index.js +69 -0
- package/dist/components/DateTimePicker/index.d.ts +4 -0
- package/dist/components/DateTimePicker/index.interface.d.ts +6 -0
- package/dist/components/DateTimePicker/index.interface.js +1 -0
- package/dist/components/DateTimePicker/index.js +100 -0
- package/dist/components/FileUpload/fileUtil.d.ts +34 -0
- package/dist/components/FileUpload/fileUtil.js +146 -0
- package/dist/components/FileUpload/index.d.ts +5 -0
- package/dist/components/FileUpload/index.interface.d.ts +119 -0
- package/dist/components/FileUpload/index.interface.js +1 -0
- package/dist/components/FileUpload/index.js +389 -0
- package/dist/components/FileUpload/index.scss +78 -0
- package/dist/components/OcrCommon/index.config.d.ts +10 -0
- package/dist/components/OcrCommon/index.config.js +30 -1
- package/dist/components/OcrCommon/index.interface.d.ts +6 -0
- package/dist/components/OcrCommon/index.js +88 -55
- package/dist/components/OcrCommon/index.scss +4 -0
- package/dist/components/TypographyText/index.d.ts +5 -0
- package/dist/components/TypographyText/index.interface.d.ts +13 -0
- package/dist/components/TypographyText/index.interface.js +1 -0
- package/dist/components/TypographyText/index.js +67 -0
- package/dist/components/TypographyText/index.scss +9 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +3 -1
|
@@ -1,9 +1,5 @@
|
|
|
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
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
3
|
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; }
|
|
8
4
|
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); } }
|
|
9
5
|
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); }); }; }
|
|
@@ -17,13 +13,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
17
13
|
* @Author: chengjiang
|
|
18
14
|
* @Date: 2024-11-05 09:35:37
|
|
19
15
|
* @Last Modified by: chengjiang
|
|
20
|
-
* @Last Modified time: 2024-11-
|
|
16
|
+
* @Last Modified time: 2024-11-15 11:40:29
|
|
21
17
|
*/
|
|
22
18
|
import "./index.scss";
|
|
23
19
|
import { Button, ColorPicker, Image, message, Modal, Radio, Switch } from 'antd';
|
|
24
20
|
import copy from 'copy-to-clipboard';
|
|
25
21
|
import React, { useEffect, useState } from 'react';
|
|
26
|
-
import { fontSizeOpt, imgSizeOpt } from "./index.config";
|
|
22
|
+
import { fontSizeOpt, imgSizeOpt, ocrDirection } from "./index.config";
|
|
27
23
|
var Index = function Index(props) {
|
|
28
24
|
var http = props.http,
|
|
29
25
|
open = props.open,
|
|
@@ -37,7 +33,11 @@ var Index = function Index(props) {
|
|
|
37
33
|
_props$showHandleBtn = props.showHandleBtn,
|
|
38
34
|
showHandleBtn = _props$showHandleBtn === void 0 ? true : _props$showHandleBtn,
|
|
39
35
|
_props$modalProps = props.modalProps,
|
|
40
|
-
modalProps = _props$modalProps === void 0 ? {} : _props$modalProps
|
|
36
|
+
modalProps = _props$modalProps === void 0 ? {} : _props$modalProps,
|
|
37
|
+
_props$afterRequest = props.afterRequest,
|
|
38
|
+
afterRequest = _props$afterRequest === void 0 ? function (params) {
|
|
39
|
+
return params;
|
|
40
|
+
} : _props$afterRequest;
|
|
41
41
|
var _useState = useState(''),
|
|
42
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
43
43
|
ocrImg = _useState2[0],
|
|
@@ -75,6 +75,14 @@ var Index = function Index(props) {
|
|
|
75
75
|
boxBackGround = _useState18[0],
|
|
76
76
|
setBoxBackGround = _useState18[1]; // ocr识别文字背景色
|
|
77
77
|
|
|
78
|
+
var _useState19 = useState(window.innerWidth * 0.8),
|
|
79
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
80
|
+
modalWidth = _useState20[0],
|
|
81
|
+
setModalWidth = _useState20[1];
|
|
82
|
+
var _useState21 = useState(undefined),
|
|
83
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
84
|
+
modalHeight = _useState22[0],
|
|
85
|
+
setModalHeight = _useState22[1];
|
|
78
86
|
useEffect(function () {
|
|
79
87
|
if (!url) return;
|
|
80
88
|
handleOcr();
|
|
@@ -107,7 +115,7 @@ var Index = function Index(props) {
|
|
|
107
115
|
// 进行ocr识别
|
|
108
116
|
var handleOcr = /*#__PURE__*/function () {
|
|
109
117
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
110
|
-
var _url$method, method,
|
|
118
|
+
var _url$method, method, res, _result;
|
|
111
119
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
112
120
|
while (1) switch (_context2.prev = _context2.next) {
|
|
113
121
|
case 0:
|
|
@@ -129,16 +137,17 @@ var Index = function Index(props) {
|
|
|
129
137
|
_context2.next = 9;
|
|
130
138
|
return http[method](url.url, params);
|
|
131
139
|
case 9:
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
140
|
+
res = _context2.sent;
|
|
141
|
+
if (res.code === 'OK') {
|
|
142
|
+
_result = afterRequest(res.result);
|
|
143
|
+
setOcrResult(_result);
|
|
135
144
|
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
136
145
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
137
146
|
while (1) switch (_context.prev = _context.next) {
|
|
138
147
|
case 0:
|
|
139
148
|
setOcrContentShow(true);
|
|
140
149
|
_context.next = 3;
|
|
141
|
-
return renderDom(
|
|
150
|
+
return renderDom(_result);
|
|
142
151
|
case 3:
|
|
143
152
|
case "end":
|
|
144
153
|
return _context.stop();
|
|
@@ -199,7 +208,7 @@ var Index = function Index(props) {
|
|
|
199
208
|
// 渲染
|
|
200
209
|
var renderDom = /*#__PURE__*/function () {
|
|
201
210
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(res, num, numScale, color) {
|
|
202
|
-
var ocrTextBox, texts, src;
|
|
211
|
+
var ocrTextBox, texts, direction, src;
|
|
203
212
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
204
213
|
while (1) switch (_context4.prev = _context4.next) {
|
|
205
214
|
case 0:
|
|
@@ -210,12 +219,13 @@ var Index = function Index(props) {
|
|
|
210
219
|
}
|
|
211
220
|
return _context4.abrupt("return");
|
|
212
221
|
case 3:
|
|
213
|
-
texts = res.
|
|
214
|
-
|
|
215
|
-
|
|
222
|
+
texts = res.wordsResult;
|
|
223
|
+
direction = res.direction;
|
|
224
|
+
src = params.imageUrl;
|
|
225
|
+
_context4.next = 8;
|
|
216
226
|
return getBase64ImageDimensions(src).then( /*#__PURE__*/function () {
|
|
217
227
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(dimensions) {
|
|
218
|
-
var scale, screenWidth, screenHeight, imgWidth, reduction, numBoxes, fragment, fontSize, i, box,
|
|
228
|
+
var scale, screenWidth, screenHeight, imgWidth, imgHeight, reduction, numBoxes, fragment, fontSize, i, box, width, height, left, staticStyles, div, divStyle;
|
|
219
229
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
220
230
|
while (1) switch (_context3.prev = _context3.next) {
|
|
221
231
|
case 0:
|
|
@@ -223,30 +233,36 @@ var Index = function Index(props) {
|
|
|
223
233
|
screenWidth = window.innerWidth;
|
|
224
234
|
screenHeight = window.innerHeight;
|
|
225
235
|
imgWidth = screenWidth * 0.8 * (numScale || imgScale);
|
|
236
|
+
imgHeight = imgWidth / scale;
|
|
237
|
+
if (direction === 3 || direction === 1) {
|
|
238
|
+
scale = dimensions.height / dimensions.width;
|
|
239
|
+
imgHeight = screenWidth * 0.8 * (numScale || imgScale);
|
|
240
|
+
imgWidth = imgHeight / scale;
|
|
241
|
+
}
|
|
226
242
|
if (!(screenWidth * 0.8 > minWidth && imgWidth < minWidth)) {
|
|
227
|
-
_context3.next =
|
|
243
|
+
_context3.next = 9;
|
|
228
244
|
break;
|
|
229
245
|
}
|
|
230
246
|
message.warning('无法缩小到该比例!');
|
|
231
247
|
return _context3.abrupt("return");
|
|
232
|
-
case
|
|
248
|
+
case 9:
|
|
233
249
|
numScale && setImgScale(numScale); // 可以缩小,同步该值
|
|
234
250
|
num && setNumValue(num); // 字体可以变小,同步该值
|
|
235
251
|
|
|
236
252
|
// 清除之前渲染
|
|
237
|
-
case
|
|
253
|
+
case 11:
|
|
238
254
|
if (!ocrTextBox.firstChild) {
|
|
239
|
-
_context3.next =
|
|
255
|
+
_context3.next = 16;
|
|
240
256
|
break;
|
|
241
257
|
}
|
|
242
|
-
_context3.next =
|
|
258
|
+
_context3.next = 14;
|
|
243
259
|
return ocrTextBox.removeChild(ocrTextBox.firstChild);
|
|
244
|
-
case 12:
|
|
245
|
-
_context3.next = 9;
|
|
246
|
-
break;
|
|
247
260
|
case 14:
|
|
261
|
+
_context3.next = 11;
|
|
262
|
+
break;
|
|
263
|
+
case 16:
|
|
248
264
|
setImgWidth(imgWidth);
|
|
249
|
-
setImgHeight(
|
|
265
|
+
setImgHeight(imgHeight);
|
|
250
266
|
reduction = dimensions.width / imgWidth; // 识别文字定位缩放比
|
|
251
267
|
numBoxes = texts.length; // 识别总量
|
|
252
268
|
fragment = document.createDocumentFragment(); // 创建dom节点
|
|
@@ -258,26 +274,29 @@ var Index = function Index(props) {
|
|
|
258
274
|
} else {
|
|
259
275
|
fontSize = fontSize * (num || numValue);
|
|
260
276
|
}
|
|
277
|
+
if (direction === 3 || direction === 1) {
|
|
278
|
+
setModalHeight(imgWidth + 50);
|
|
279
|
+
setModalWidth(imgHeight + 50);
|
|
280
|
+
} else {
|
|
281
|
+
setModalHeight(imgHeight + 50);
|
|
282
|
+
setModalWidth(imgWidth + 50);
|
|
283
|
+
}
|
|
261
284
|
for (i = 0; i < numBoxes; i++) {
|
|
262
285
|
box = document.createElement('div');
|
|
263
286
|
box.className = 'box';
|
|
264
287
|
|
|
265
288
|
// 计算矩形的位置和尺寸
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
minY = Math.min.apply(Math, _toConsumableArray(yCoords));
|
|
275
|
-
maxY = Math.max.apply(Math, _toConsumableArray(yCoords));
|
|
276
|
-
width = maxX - minX;
|
|
277
|
-
height = maxY - minY; // 将样式设置为静态值
|
|
289
|
+
width = texts[i].location.width / reduction;
|
|
290
|
+
height = texts[i].location.height / reduction;
|
|
291
|
+
left = texts[i].location.left / reduction;
|
|
292
|
+
if (direction === 3) {
|
|
293
|
+
left = left + (imgHeight - imgWidth);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// 将样式设置为静态值
|
|
278
297
|
staticStyles = {
|
|
279
|
-
left: "".concat(
|
|
280
|
-
top: "".concat(
|
|
298
|
+
left: "".concat(left, "px"),
|
|
299
|
+
top: "".concat(texts[i].location.top / reduction, "px"),
|
|
281
300
|
width: "".concat(width, "px"),
|
|
282
301
|
height: "".concat(height, "px"),
|
|
283
302
|
fontSize: "".concat(fontSize, "px"),
|
|
@@ -286,13 +305,20 @@ var Index = function Index(props) {
|
|
|
286
305
|
Object.assign(box.style, staticStyles);
|
|
287
306
|
|
|
288
307
|
// 添加文本内容
|
|
289
|
-
|
|
308
|
+
div = document.createElement('div');
|
|
309
|
+
div.className = 'text-item';
|
|
310
|
+
divStyle = {
|
|
311
|
+
transform: "rotate(-".concat(ocrDirection[direction], "deg)")
|
|
312
|
+
};
|
|
313
|
+
Object.assign(div.style, divStyle);
|
|
314
|
+
div.innerText = texts[i].words || '';
|
|
315
|
+
box.appendChild(div);
|
|
290
316
|
fragment.appendChild(box);
|
|
291
|
-
setOcrImg(src);
|
|
292
317
|
}
|
|
293
|
-
|
|
318
|
+
setOcrImg(src);
|
|
319
|
+
_context3.next = 28;
|
|
294
320
|
return ocrTextBox.appendChild(fragment);
|
|
295
|
-
case
|
|
321
|
+
case 28:
|
|
296
322
|
case "end":
|
|
297
323
|
return _context3.stop();
|
|
298
324
|
}
|
|
@@ -305,7 +331,7 @@ var Index = function Index(props) {
|
|
|
305
331
|
message.error('识别失败,请重试!');
|
|
306
332
|
onCancel();
|
|
307
333
|
});
|
|
308
|
-
case
|
|
334
|
+
case 8:
|
|
309
335
|
case "end":
|
|
310
336
|
return _context4.stop();
|
|
311
337
|
}
|
|
@@ -318,13 +344,13 @@ var Index = function Index(props) {
|
|
|
318
344
|
|
|
319
345
|
// 更改字体大小步进器
|
|
320
346
|
var handleChangeFontSlider = function handleChangeFontSlider(e) {
|
|
321
|
-
if (!ocrResult || !ocrResult.
|
|
347
|
+
if (!ocrResult || !ocrResult.wordsResult) return;
|
|
322
348
|
renderDom(ocrResult, e.target.value);
|
|
323
349
|
};
|
|
324
350
|
|
|
325
351
|
// 更改缩放比步进器
|
|
326
352
|
var handleChangeImgSlider = function handleChangeImgSlider(e) {
|
|
327
|
-
if (!ocrResult || !ocrResult.
|
|
353
|
+
if (!ocrResult || !ocrResult.wordsResult) return;
|
|
328
354
|
renderDom(ocrResult, undefined, e.target.value);
|
|
329
355
|
};
|
|
330
356
|
|
|
@@ -343,9 +369,9 @@ var Index = function Index(props) {
|
|
|
343
369
|
|
|
344
370
|
// 选中全部
|
|
345
371
|
var handleSelectAll = function handleSelectAll() {
|
|
346
|
-
if (!ocrResult || !ocrResult.
|
|
347
|
-
var allText = ocrResult.
|
|
348
|
-
return item
|
|
372
|
+
if (!ocrResult || !ocrResult.wordsResult) return;
|
|
373
|
+
var allText = ocrResult.wordsResult.map(function (item) {
|
|
374
|
+
return item.words;
|
|
349
375
|
}).join(' ');
|
|
350
376
|
copy(allText);
|
|
351
377
|
message.success('复制成功');
|
|
@@ -353,9 +379,12 @@ var Index = function Index(props) {
|
|
|
353
379
|
return loading ? /*#__PURE__*/React.createElement(React.Fragment, null) : /*#__PURE__*/React.createElement(Modal, _extends({
|
|
354
380
|
zIndex: 9999 // 默认1000
|
|
355
381
|
,
|
|
356
|
-
open: open
|
|
357
|
-
width
|
|
358
|
-
height
|
|
382
|
+
open: open
|
|
383
|
+
// width={imgWidth ? imgWidth + 50 : window.innerWidth * 0.8}
|
|
384
|
+
// height={imgWidth ? imgHeight + 100 : undefined}
|
|
385
|
+
,
|
|
386
|
+
width: modalWidth,
|
|
387
|
+
height: modalHeight,
|
|
359
388
|
title: /*#__PURE__*/React.createElement("div", {
|
|
360
389
|
className: "common_ocr_modal_title"
|
|
361
390
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -426,11 +455,15 @@ var Index = function Index(props) {
|
|
|
426
455
|
footer: null
|
|
427
456
|
}, modalProps), /*#__PURE__*/React.createElement("div", {
|
|
428
457
|
className: "ocr_img",
|
|
429
|
-
id: "canvas"
|
|
458
|
+
id: "canvas",
|
|
459
|
+
style: {
|
|
460
|
+
transform: "rotate(".concat(ocrDirection[ocrResult.direction], "deg)")
|
|
461
|
+
}
|
|
430
462
|
}, /*#__PURE__*/React.createElement(Image, {
|
|
431
463
|
style: {
|
|
432
464
|
width: imgWidth + 'px',
|
|
433
|
-
height: imgHeight + 'px'
|
|
465
|
+
height: imgHeight + 'px',
|
|
466
|
+
marginLeft: ocrResult.direction === 3 ? imgHeight - imgWidth + 'px' : '0'
|
|
434
467
|
},
|
|
435
468
|
preview: false,
|
|
436
469
|
className: "ocr_img_box",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface IndexProps {
|
|
3
|
+
text: string;
|
|
4
|
+
rows?: number;
|
|
5
|
+
copy?: boolean;
|
|
6
|
+
type?: 'secondary' | 'success' | 'warning' | 'danger';
|
|
7
|
+
expandable?: boolean | 'collapsible';
|
|
8
|
+
ellipsis?: {
|
|
9
|
+
suffix?: string;
|
|
10
|
+
symbol?: ReactNode | ((expanded: boolean) => ReactNode);
|
|
11
|
+
onEllipsis?: (ellipsis: any) => void;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
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 = ["text", "rows", "copy", "type", "expandable", "ellipsis"];
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
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); }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
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."); }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
import { Tooltip, Typography } from 'antd';
|
|
18
|
+
import React, { useState } from 'react';
|
|
19
|
+
import "./index.scss";
|
|
20
|
+
|
|
21
|
+
// 参考antd的Typography,只能用与Paragraph
|
|
22
|
+
/// 如果需要自定义,则手动传入ellipsis,会覆盖默认值
|
|
23
|
+
var Index = function Index(props) {
|
|
24
|
+
var text = props.text,
|
|
25
|
+
_props$rows = props.rows,
|
|
26
|
+
rows = _props$rows === void 0 ? 1 : _props$rows,
|
|
27
|
+
_props$copy = props.copy,
|
|
28
|
+
copy = _props$copy === void 0 ? false : _props$copy,
|
|
29
|
+
_props$type = props.type,
|
|
30
|
+
type = _props$type === void 0 ? 'secondary' : _props$type,
|
|
31
|
+
_props$expandable = props.expandable,
|
|
32
|
+
expandable = _props$expandable === void 0 ? false : _props$expandable,
|
|
33
|
+
_props$ellipsis = props.ellipsis,
|
|
34
|
+
ellipsis = _props$ellipsis === void 0 ? {} : _props$ellipsis,
|
|
35
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
36
|
+
var _useState = useState(false),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
expanded = _useState2[0],
|
|
39
|
+
setExpanded = _useState2[1]; // 展开收起
|
|
40
|
+
|
|
41
|
+
var textRender = function textRender() {
|
|
42
|
+
return /*#__PURE__*/React.createElement(Typography.Paragraph, _extends({
|
|
43
|
+
// rows = 1时,需要自行设置css,否则会默认全部展示
|
|
44
|
+
className: rows === 1 && !expanded && !expandable ? 'custom_Typography_row1' : '',
|
|
45
|
+
style: {
|
|
46
|
+
marginBottom: 0
|
|
47
|
+
},
|
|
48
|
+
ellipsis: _objectSpread({
|
|
49
|
+
rows: rows,
|
|
50
|
+
expandable: expandable,
|
|
51
|
+
expanded: expanded,
|
|
52
|
+
onExpand: function onExpand(_, info) {
|
|
53
|
+
return setExpanded(info.expanded);
|
|
54
|
+
},
|
|
55
|
+
symbol: function symbol(expanded) {
|
|
56
|
+
return !expanded ? '展开' : '收起';
|
|
57
|
+
}
|
|
58
|
+
}, ellipsis),
|
|
59
|
+
copyable: copy,
|
|
60
|
+
type: type
|
|
61
|
+
}, rest), /*#__PURE__*/React.createElement(React.Fragment, null, text || ''));
|
|
62
|
+
};
|
|
63
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !expanded ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
64
|
+
title: text
|
|
65
|
+
}, textRender()) : /*#__PURE__*/React.createElement(React.Fragment, null, textRender()));
|
|
66
|
+
};
|
|
67
|
+
export default Index;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export { default as NumberInput } from './components/NumberInput';
|
|
|
8
8
|
export { default as OcrCommon } from './components/OcrCommon';
|
|
9
9
|
export { default as PageTemplate } from './components/PageTemplate';
|
|
10
10
|
export { default as ReactEcharts } from './components/ReactEcharts';
|
|
11
|
+
export { default as FileUpload } from './components/FileUpload';
|
|
12
|
+
export { default as CustomButtonModal } from './components/CustomButtonModal';
|
|
13
|
+
export { default as DateTimePicker } from './components/DateTimePicker';
|
|
14
|
+
export { default as TypographyText } from './components/TypographyText';
|
|
11
15
|
export { default as SelectMax } from './components/SelectMax';
|
|
12
16
|
export { default as SelectPosition } from './components/SelectPosition';
|
|
13
17
|
export { default as SuperCascader } from './components/SuperCascader';
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,10 @@ export { default as NumberInput } from "./components/NumberInput";
|
|
|
9
9
|
export { default as OcrCommon } from "./components/OcrCommon";
|
|
10
10
|
export { default as PageTemplate } from "./components/PageTemplate";
|
|
11
11
|
export { default as ReactEcharts } from "./components/ReactEcharts";
|
|
12
|
+
export { default as FileUpload } from "./components/FileUpload";
|
|
13
|
+
export { default as CustomButtonModal } from "./components/CustomButtonModal";
|
|
14
|
+
export { default as DateTimePicker } from "./components/DateTimePicker";
|
|
15
|
+
export { default as TypographyText } from "./components/TypographyText";
|
|
12
16
|
export { default as SelectMax } from "./components/SelectMax";
|
|
13
17
|
export { default as SelectPosition } from "./components/SelectPosition";
|
|
14
18
|
export { default as SuperCascader } from "./components/SuperCascader";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yilianjituan/yilian_dgerm",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.35",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"React",
|
|
@@ -58,11 +58,13 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@ant-design/icons": "^5.5.1",
|
|
60
60
|
"@hanyk/rc-viewer": "^0.0.3",
|
|
61
|
+
"ahooks": "^3.7.2",
|
|
61
62
|
"antd": "^5.18.0",
|
|
62
63
|
"axios": "^1.7.7",
|
|
63
64
|
"copy-to-clipboard": "^3.3.3",
|
|
64
65
|
"dayjs": "^1.11.11",
|
|
65
66
|
"echarts": "^5.0.0",
|
|
67
|
+
"heic2any": "^0.0.4",
|
|
66
68
|
"jsdom": "20.0.0",
|
|
67
69
|
"lodash": "^4.17.20",
|
|
68
70
|
"qs": "^6.9.7",
|