xh-lab-rc 0.0.9 → 0.0.11

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.
@@ -17,12 +17,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
17
17
  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; }
18
18
  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; } }
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
- /*
21
- * @Author: xqy
22
- * @Date: 2024-04-23 13:43:55
23
- * @LastEditors: xqy
24
- * @LastEditTime: 2024-04-28 19:05:34
25
- * @Description: 高拍仪
20
+ /*
21
+ * @Author: xqy
22
+ * @Date: 2024-04-23 13:43:55
23
+ * @LastEditors: wusum
24
+ * @LastEditTime: 2024-05-11 13:51:03
25
+ * @Description: 高拍仪
26
26
  */
27
27
  import { Iconfont } from "../components";
28
28
  import { LabBase64ToFile } from "../utils/utils";
@@ -76,11 +76,18 @@ var LabAltimeter = function LabAltimeter(_ref) {
76
76
  _useState18 = _slicedToArray(_useState17, 2),
77
77
  pdfIndex = _useState18[0],
78
78
  setPdfIndex = _useState18[1];
79
- //预览的图片或pdf
80
- var _useState19 = useState(false),
79
+
80
+ //设置可编辑的图片下标
81
+ var _useState19 = useState(-1),
81
82
  _useState20 = _slicedToArray(_useState19, 2),
82
- isShowPdf = _useState20[0],
83
- setIsShowPdf = _useState20[1];
83
+ editIndex = _useState20[0],
84
+ setEditIndex = _useState20[1];
85
+
86
+ //预览的图片或pdf
87
+ var _useState21 = useState(false),
88
+ _useState22 = _slicedToArray(_useState21, 2),
89
+ isShowPdf = _useState22[0],
90
+ setIsShowPdf = _useState22[1];
84
91
  // 图标
85
92
  var iconType = ['icon-zuoxuan', 'icon-youxuan', 'icon-duijiao'];
86
93
  // 高拍仪类型
@@ -295,22 +302,11 @@ var LabAltimeter = function LabAltimeter(_ref) {
295
302
  };
296
303
 
297
304
  //鼠标移入图片(显示编辑和删除图标)
298
- var handleMouseEnter = function handleMouseEnter(item, index) {
299
- var updateList = _toConsumableArray(imgList);
300
- updateList[index].isShowIcon = true;
301
- setImgList(updateList);
305
+ var handleMouseEnter = function handleMouseEnter(item) {
302
306
  setOldDrageItem(item);
303
307
  setIsActive(item.filePath);
304
308
  };
305
309
 
306
- //鼠标移出图片(隐藏编辑和删除)
307
- var handleMouseLeave = function handleMouseLeave(index) {
308
- var updateList = _toConsumableArray(imgList);
309
- updateList[index].isShowIcon = false;
310
- updateList[index].disabled = true;
311
- setImgList(updateList);
312
- };
313
-
314
310
  //修改文件的名称
315
311
  var handChange = function handChange(e, index) {
316
312
  var updateList = _toConsumableArray(imgList);
@@ -320,9 +316,7 @@ var LabAltimeter = function LabAltimeter(_ref) {
320
316
 
321
317
  //点击编辑图标,允许编辑
322
318
  var onEdit = function onEdit(index) {
323
- var updateList = _toConsumableArray(imgList);
324
- updateList[index].disabled = false;
325
- setImgList(updateList);
319
+ setEditIndex(index);
326
320
  };
327
321
 
328
322
  //删除文件
@@ -429,7 +423,10 @@ var LabAltimeter = function LabAltimeter(_ref) {
429
423
  file: LabBase64ToFile(i.filePath, nameArr[0])
430
424
  });
431
425
  });
432
- onSave === null || onSave === void 0 || onSave(newImgList);
426
+ var selectList = newImgList.filter(function (item) {
427
+ return item.isChecked === true;
428
+ }); //选中的文件上传
429
+ onSave === null || onSave === void 0 || onSave(selectList);
433
430
  };
434
431
  useEffect(function () {
435
432
  openCamera(); //一开始就打开摄像头
@@ -492,7 +489,7 @@ var LabAltimeter = function LabAltimeter(_ref) {
492
489
  }, !isShowPdf ? /*#__PURE__*/React.createElement("img", {
493
490
  id: "view",
494
491
  src: "http://127.0.0.1:38088/video=stream&camidx=0",
495
- alt: "\u4E3B\u6444\u50CF\u5934"
492
+ alt: "\u8BF7\u8FDE\u63A5\u6444\u50CF\u5934\u8BBE\u5907\uFF01"
496
493
  }) : /*#__PURE__*/React.createElement("embed", {
497
494
  src: curPreviewPath,
498
495
  type: "application/pdf",
@@ -519,10 +516,7 @@ var LabAltimeter = function LabAltimeter(_ref) {
519
516
  draggable: true,
520
517
  key: index,
521
518
  onMouseEnter: function onMouseEnter() {
522
- return handleMouseEnter(item, index);
523
- },
524
- onMouseLeave: function onMouseLeave() {
525
- return handleMouseLeave(index);
519
+ return handleMouseEnter(item);
526
520
  },
527
521
  onDragStart: function onDragStart() {
528
522
  return _onDragStart(item);
@@ -539,7 +533,7 @@ var LabAltimeter = function LabAltimeter(_ref) {
539
533
  onClick: function onClick() {
540
534
  return onPreviewFile(item);
541
535
  }
542
- }, item.isShowIcon && /*#__PURE__*/React.createElement(Iconfont, {
536
+ }, /*#__PURE__*/React.createElement(Iconfont, {
543
537
  type: "icon-chahao",
544
538
  style: {
545
539
  fontSize: '13px',
@@ -549,6 +543,7 @@ var LabAltimeter = function LabAltimeter(_ref) {
549
543
  top: '0px',
550
544
  right: '1px'
551
545
  },
546
+ className: "hover-icon",
552
547
  onClick: function onClick() {
553
548
  return onDelete(item.filePath);
554
549
  }
@@ -567,25 +562,27 @@ var LabAltimeter = function LabAltimeter(_ref) {
567
562
  return handleSelectSingle(e, index);
568
563
  }
569
564
  })), /*#__PURE__*/React.createElement("p", {
570
- className: "img-text"
565
+ className: "img-text",
566
+ title: item.fileName
571
567
  }, /*#__PURE__*/React.createElement(Input, {
572
568
  variant: "borderless",
573
- disabled: item.disabled,
569
+ disabled: editIndex !== index,
574
570
  value: item === null || item === void 0 ? void 0 : item.fileName,
575
571
  onChange: function onChange(e) {
576
572
  return handChange(e, index);
577
573
  },
578
- suffix: item.isShowIcon ? /*#__PURE__*/React.createElement(Iconfont, {
574
+ suffix: /*#__PURE__*/React.createElement(Iconfont, {
579
575
  type: "icon-bianji",
580
576
  style: {
581
577
  fontSize: '13px',
582
578
  color: '#1677FF',
583
579
  cursor: 'pointer'
584
580
  },
581
+ className: "hover-icon",
585
582
  onClick: function onClick() {
586
583
  return onEdit(index);
587
584
  }
588
- }) : false
585
+ })
589
586
  })));
590
587
  }) : null))), /*#__PURE__*/React.createElement(SetupModal, {
591
588
  visible: setUpVisible,
@@ -5,6 +5,7 @@
5
5
  position: relative;
6
6
  padding: 4px;
7
7
  border: 1px solid #ddd;
8
+ min-height: 600px;
8
9
 
9
10
  .top {
10
11
  display: flex;
@@ -66,7 +67,7 @@
66
67
  }
67
68
 
68
69
  .con-right {
69
- width: 500px;
70
+ width: 600px;
70
71
  overflow-y: auto;
71
72
  }
72
73
 
@@ -91,6 +92,14 @@
91
92
  margin-bottom: 24px;
92
93
  }
93
94
 
95
+ .hover-icon {
96
+ display: none;
97
+ }
98
+
99
+ .preview-item:hover .hover-icon {
100
+ display: block; /* 鼠标经过时显示图标 */
101
+ }
102
+
94
103
  .active-item {
95
104
  border: 1px solid #cee4f8;
96
105
  }
@@ -141,7 +150,7 @@
141
150
  margin-top: 4px;
142
151
 
143
152
  .ant-input {
144
- font-size: 8px;
153
+ font-size: 10px;
145
154
  height: 20px;
146
155
  overflow: hidden;
147
156
  text-overflow: ellipsis;
@@ -152,13 +161,13 @@
152
161
 
153
162
  .ant-input-borderless[disabled] {
154
163
  color: #535353;
155
- font-size: 8px;
164
+ font-size: 10px;
156
165
  height: 20px;
157
166
  }
158
167
 
159
168
  .ant-input-affix-wrapper > input.ant-input {
160
169
  color: #535353;
161
- font-size: 8px;
170
+ font-size: 10px;
162
171
  height: 20px;
163
172
  }
164
173
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import './style.less';
3
3
  import type { IGtreeProps } from './typing';
4
- declare const LabGroupTree: ({ treeData, GBeforeIcon, showLine, showIcon, isShowNum, treeProperties, onExpand, onSelect, childTitleNode, ...restProps }: IGtreeProps) => React.JSX.Element;
4
+ declare const LabGroupTree: ({ treeData, GBeforeIcon, showLine, showIcon, isShowNum, treeProperties, onExpand, onSelect, childTitleNode, extraNodeProps, ...restProps }: IGtreeProps) => React.JSX.Element;
5
5
  export default LabGroupTree;
@@ -1,21 +1,32 @@
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 = ["treeData", "GBeforeIcon", "showLine", "showIcon", "isShowNum", "treeProperties", "onExpand", "onSelect", "childTitleNode"];
2
+ var _excluded = ["treeData", "GBeforeIcon", "showLine", "showIcon", "isShowNum", "treeProperties", "onExpand", "onSelect", "childTitleNode", "extraNodeProps"];
3
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); }
4
9
  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
10
  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
11
  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); }); }; }
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+ 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."); }
14
+ 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); }
15
+ 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; }
16
+ 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; } }
17
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
18
  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; }
8
19
  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; }
9
20
  /*
10
21
  * @Author: xqy
11
22
  * @Date: 2024-03-18 16:23:10
12
23
  * @LastEditors: xqy
13
- * @LastEditTime: 2024-04-10 10:09:12
24
+ * @LastEditTime: 2024-05-11 11:23:37
14
25
  * @Description:专业组树形
15
26
  */
16
27
  import { Iconfont } from "../components";
17
28
  import { Tree } from 'antd';
18
- import React from 'react';
29
+ import React, { useEffect, useState } from 'react';
19
30
  import "./style.less";
20
31
  var IconTypes = {
21
32
  '1': 'icon-jian',
@@ -51,7 +62,13 @@ var LabGroupTree = function LabGroupTree(_ref) {
51
62
  onExpand = _ref.onExpand,
52
63
  _onSelect = _ref.onSelect,
53
64
  childTitleNode = _ref.childTitleNode,
65
+ _ref$extraNodeProps = _ref.extraNodeProps,
66
+ extraNodeProps = _ref$extraNodeProps === void 0 ? [] : _ref$extraNodeProps,
54
67
  restProps = _objectWithoutProperties(_ref, _excluded);
68
+ var _useState = useState([]),
69
+ _useState2 = _slicedToArray(_useState, 2),
70
+ treeList = _useState2[0],
71
+ setTreeList = _useState2[1];
55
72
  //构造标题的结构
56
73
  var customTitle = function customTitle(nodeData) {
57
74
  var NAME = nodeData.NAME,
@@ -120,9 +137,39 @@ var LabGroupTree = function LabGroupTree(_ref) {
120
137
  return _ref2.apply(this, arguments);
121
138
  };
122
139
  }();
140
+
141
+ //递归treeList往树节点添加额外参数
142
+ var recursTree = function recursTree(data, extraNodeProps) {
143
+ if (data && data.length) {
144
+ data.map(function (item) {
145
+ //查找匹配的节点
146
+ var matchingNode = extraNodeProps.find(function (i) {
147
+ return i.NODE_TYPE === item.NODE_TYPE;
148
+ });
149
+ if (matchingNode) {
150
+ return _objectSpread(_objectSpread(_objectSpread({}, item), matchingNode), {}, {
151
+ CHILDREN: recursTree(item.CHILDREN, extraNodeProps)
152
+ });
153
+ } else {
154
+ return _objectSpread(_objectSpread({}, item), {}, {
155
+ CHILDREN: recursTree(item.CHILDREN, extraNodeProps)
156
+ });
157
+ }
158
+ });
159
+ }
160
+ return data;
161
+ };
162
+ useEffect(function () {
163
+ //是否需要自定义
164
+ if (extraNodeProps && extraNodeProps.length) {
165
+ var newTreeData = recursTree(treeData, extraNodeProps);
166
+ setTreeList(newTreeData);
167
+ }
168
+ setTreeList(treeData);
169
+ }, [treeData, extraNodeProps]);
123
170
  return /*#__PURE__*/React.createElement(Tree, _extends({
124
171
  rootClassName: "lab-group-tree",
125
- treeData: treeData,
172
+ treeData: treeList,
126
173
  onSelect: function onSelect(keys, node) {
127
174
  _onSelect === null || _onSelect === void 0 || _onSelect(keys, node);
128
175
  },
@@ -29,4 +29,6 @@ export interface IGtreeProps {
29
29
  treeProperties?: TreeProps;
30
30
  /**是否显示科室/管理/检验专业组下的统计数量 */
31
31
  isShowNum?: boolean;
32
+ /**匹配NODE_TYPE层级,添加除原数据额外的树节点参数 */
33
+ extraNodeProps?: any;
32
34
  }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface ListTitleProps {
3
+ titleName: string;
4
+ iconElement: React.ReactNode;
5
+ }
6
+ declare const ListTitle: (props: ListTitleProps) => React.JSX.Element;
7
+ export default ListTitle;
@@ -0,0 +1,13 @@
1
+ import { Button } from 'antd';
2
+ import React from 'react';
3
+ var ListTitle = function ListTitle(props) {
4
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
5
+ ghost: true,
6
+ type: "primary",
7
+ shape: "circle",
8
+ icon: props.iconElement
9
+ }), /*#__PURE__*/React.createElement("span", {
10
+ className: "title"
11
+ }, props.titleName));
12
+ };
13
+ export default ListTitle;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface PdfBookmarksProps {
3
+ Bookmarks: React.FC;
4
+ }
5
+ declare function PdfBookmarks(props: PdfBookmarksProps): React.JSX.Element;
6
+ export default PdfBookmarks;
@@ -0,0 +1,34 @@
1
+ /*
2
+ * @Descripttion:
3
+ * @Author: wusum
4
+ * @Date: 2024-05-06 11:01:53
5
+ * @LastEditors: wusum
6
+ * @LastEditTime: 2024-05-07 14:06:49
7
+ */
8
+ import { BarsOutlined, TagsOutlined } from '@ant-design/icons';
9
+ import { Timeline } from 'antd';
10
+ import React from 'react';
11
+ import ListTitle from "./ListTitle";
12
+ function PdfBookmarks(props) {
13
+ var timelineItems = [{
14
+ children: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ListTitle, {
15
+ titleName: '目录',
16
+ iconElement: /*#__PURE__*/React.createElement(BarsOutlined, null)
17
+ }))
18
+ }, {
19
+ children: /*#__PURE__*/React.createElement("div", {
20
+ className: "content"
21
+ }, /*#__PURE__*/React.createElement(props.Bookmarks, null))
22
+ }, {
23
+ children: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ListTitle, {
24
+ titleName: '书签',
25
+ iconElement: /*#__PURE__*/React.createElement(TagsOutlined, null)
26
+ }))
27
+ }];
28
+ return /*#__PURE__*/React.createElement("div", {
29
+ className: "book-marks"
30
+ }, /*#__PURE__*/React.createElement(Timeline, {
31
+ items: timelineItems
32
+ }));
33
+ }
34
+ export default PdfBookmarks;
@@ -0,0 +1,5 @@
1
+ export declare const enum SHOWMODE {
2
+ NormalMode = 0,// 预览模式
3
+ PrintMode = 1,// 打印模式
4
+ BookMarkMode = 2
5
+ }
@@ -0,0 +1,12 @@
1
+ /*
2
+ * @Descripttion:
3
+ * @Author: wusum
4
+ * @Date: 2024-05-11 14:53:12
5
+ * @LastEditors: wusum
6
+ * @LastEditTime: 2024-05-11 15:05:50
7
+ */
8
+ export var SHOWMODE = {
9
+ NormalMode: 0,
10
+ PrintMode: 1,
11
+ BookMarkMode: 2
12
+ }; // 书签模式
@@ -1,8 +1,16 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
+ import { SHOWMODE } from './enum/index';
2
3
  import './style.less';
3
- interface IndexProps {
4
+ interface PdfViewerProps {
4
5
  src: string;
5
- waterMark?: string;
6
+ fileId?: string;
7
+ showMode: SHOWMODE;
8
+ isShowCheck?: boolean;
9
+ checkedKey?: any[];
10
+ selectBookMask?: any;
11
+ selectedNode?: string[];
12
+ onIdsChange?: (string: any, Array: any) => void;
13
+ onBeforePrintCallback?: () => void;
6
14
  }
7
- declare const LabPdfView: React.FC<IndexProps>;
15
+ declare const LabPdfView: ({ src, onIdsChange, isShowCheck, checkedKey, selectBookMask, fileId, onBeforePrintCallback, showMode, }: PdfViewerProps) => React.JSX.Element;
8
16
  export default LabPdfView;
@@ -1,12 +1,269 @@
1
- import React from 'react';
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
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 _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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ /*
8
+ * @Descripttion:
9
+ * @Author: wusum
10
+ * @Date: 2024-04-11 16:50:48
11
+ * @LastEditors: wusum
12
+ * @LastEditTime: 2024-05-12 16:32:22
13
+ */
14
+ import { UnorderedListOutlined } from '@ant-design/icons';
15
+ import { Button, Empty, Tree } from 'antd';
16
+ import * as React from 'react';
17
+ import { useEffect, useRef, useState } from 'react';
18
+ import { SHOWMODE } from "./enum/index";
2
19
  import "./style.less";
3
20
  var LabPdfView = function LabPdfView(_ref) {
4
21
  var src = _ref.src,
5
- _ref$waterMark = _ref.waterMark,
6
- waterMark = _ref$waterMark === void 0 ? '' : _ref$waterMark;
7
- return /*#__PURE__*/React.createElement("iframe", {
8
- className: "pdf-iframe",
9
- src: "/statics/pdfjs/web/viewer.html?file=".concat(src).concat(waterMark ? '&watermark=' + waterMark : '')
10
- });
22
+ onIdsChange = _ref.onIdsChange,
23
+ _ref$isShowCheck = _ref.isShowCheck,
24
+ isShowCheck = _ref$isShowCheck === void 0 ? true : _ref$isShowCheck,
25
+ _ref$checkedKey = _ref.checkedKey,
26
+ checkedKey = _ref$checkedKey === void 0 ? [] : _ref$checkedKey,
27
+ selectBookMask = _ref.selectBookMask,
28
+ fileId = _ref.fileId,
29
+ onBeforePrintCallback = _ref.onBeforePrintCallback,
30
+ _ref$showMode = _ref.showMode,
31
+ showMode = _ref$showMode === void 0 ? SHOWMODE.NormalMode : _ref$showMode;
32
+ var pdfIframe = useRef();
33
+ var ids = [];
34
+ var _useState = useState([]),
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ bookMarks = _useState2[0],
37
+ setBookmarks = _useState2[1];
38
+
39
+ // 选择书签
40
+ function handleOnSelect(selectedKeys, info) {
41
+ var iframeWindow = pdfIframe.current.contentWindow;
42
+ if (info.node.dest) {
43
+ iframeWindow.PDFViewerApplication.pdfLinkService.goToDestination(info.node.dest);
44
+ }
45
+ }
46
+
47
+ // 勾选书签
48
+ function handleOnCheck(checkedKeys, event) {
49
+ ids = [];
50
+ event.checkedNodesPositions.forEach(function (v) {
51
+ ids.push({
52
+ dirLabelName: v.node.title,
53
+ dirLabelId: v.pos
54
+ });
55
+ });
56
+ if (onIdsChange) {
57
+ onIdsChange(fileId, ids);
58
+ }
59
+ }
60
+
61
+ // 加上书签id,和tree一致
62
+ function addItemId(t, j) {
63
+ t.forEach(function (e, i) {
64
+ e.id = j + '-' + i;
65
+ if (e.items.length > 0) {
66
+ addItemId(e.items, e.id);
67
+ }
68
+ });
69
+ }
70
+
71
+ // find 书签
72
+ function find(t, id) {
73
+ var item = {};
74
+ function findItem(t, id) {
75
+ for (var index = 0; index < t.length; index++) {
76
+ if (t[index].id === id) {
77
+ item = t[index];
78
+ return;
79
+ }
80
+ if (t[index].items.length > 0) {
81
+ findItem(t[index].items, id);
82
+ }
83
+ }
84
+ }
85
+ findItem(t, id);
86
+ return item;
87
+ }
88
+
89
+ // 加载完成后,已经可以操作iframeWindow
90
+ // 需要确保pdfjs已经基本完成初始化
91
+ // 采用定时轮询
92
+ var interval, interval1, interval2;
93
+ var loadSuccessPrint = function loadSuccessPrint() {
94
+ setTimeout(function () {
95
+ console.log(pdfIframe.current.contentWindow.PDFViewerApplication);
96
+ pdfIframe.current.contentWindow.PDFViewerApplication.triggerPrinting();
97
+ if (onBeforePrintCallback) onBeforePrintCallback();
98
+ }, 1000);
99
+ };
100
+ var loadSuccessBookMask = function loadSuccessBookMask(bookMarksList) {
101
+ if (bookMarksList) {
102
+ addItemId(bookMarksList, '0-0');
103
+ setBookmarks([{
104
+ isLeaf: false,
105
+ title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
106
+ type: "primary",
107
+ shape: "circle",
108
+ icon: /*#__PURE__*/React.createElement(UnorderedListOutlined, null)
109
+ }), /*#__PURE__*/React.createElement("span", {
110
+ style: {
111
+ color: '#1677ff',
112
+ marginLeft: '15px'
113
+ }
114
+ }, "\u4E66\u7B7E")),
115
+ checkable: false,
116
+ icon: /*#__PURE__*/React.createElement(Button, {
117
+ type: "primary",
118
+ icon: /*#__PURE__*/React.createElement(UnorderedListOutlined, null)
119
+ }),
120
+ id: '0',
121
+ items: bookMarksList
122
+ }]);
123
+ if (selectBookMask) {
124
+ var iframeWindow = pdfIframe.current.contentWindow;
125
+ var info = find(bookMarks, selectBookMask['dirLabelId']);
126
+ if (info.dest) {
127
+ iframeWindow.PDFViewerApplication.pdfLinkService.goToDestination(info.dest);
128
+ }
129
+ }
130
+ }
131
+ };
132
+ var loadMarksList = function loadMarksList(iframeWindow) {
133
+ var outline = iframeWindow.PDFViewerApplication.pdfOutlineViewer._outline;
134
+ if (outline === null) {
135
+ // 还在null时
136
+ // 书签组件在 iframeWindow-》PDFViewerApplication-》pdfOutlineViewer-》_outline
137
+ // 通过劫持_outline,得到书签读取完成的回调;
138
+ Object.defineProperty(iframeWindow.PDFViewerApplication.pdfOutlineViewer, '_outline', {
139
+ set: function set(newvalue) {
140
+ console.log('Loading bookMarksList Success_!');
141
+ setTimeout(function () {
142
+ loadSuccessBookMask(newvalue);
143
+ }, 250);
144
+ clearInterval(interval1);
145
+ }
146
+ });
147
+ } else {
148
+ console.log('Loading bookMarksList Success!');
149
+ clearInterval(interval1);
150
+ setTimeout(function () {
151
+ loadSuccessBookMask(outline);
152
+ }, 250);
153
+ }
154
+ };
155
+ var loadPdfDocument = function loadPdfDocument(iframeWindow) {
156
+ if (iframeWindow.PDFViewerApplication.pdfDocument === null) {
157
+ console.info('Loading pdfDocument...');
158
+ } else {
159
+ console.info('Loading pdfDocument Success!');
160
+ clearInterval(interval2);
161
+ loadSuccessPrint();
162
+ }
163
+ };
164
+ var loadPDFOutlineViewer = function loadPDFOutlineViewer(iframeWindow) {
165
+ if (iframeWindow.PDFViewerApplication.pdfOutlineViewer === null) {
166
+ console.info('Loading pdfOutlineViewer...');
167
+ } else {
168
+ console.info('Loading pdfOutlineViewer Success!');
169
+ clearInterval(interval1);
170
+ loadMarksList(iframeWindow);
171
+ }
172
+ };
173
+ var loadPDFViewerApplication = function loadPDFViewerApplication(iframeWindow) {
174
+ if (iframeWindow.PDFViewerApplication === null) {
175
+ console.info('Loading PDFViewerApplication...');
176
+ } else {
177
+ console.info('Loading PDFViewerApplication Success!');
178
+ clearInterval(interval);
179
+ if (showMode === SHOWMODE.BookMarkMode) {
180
+ interval1 = setInterval(function () {
181
+ loadPDFOutlineViewer(iframeWindow);
182
+ }, 100);
183
+ }
184
+ if (showMode === SHOWMODE.PrintMode) {
185
+ interval2 = setInterval(function () {
186
+ loadPdfDocument(iframeWindow);
187
+ }, 100);
188
+ }
189
+ }
190
+ };
191
+ useEffect(function () {
192
+ // SHOWMODE.BookMarkMode
193
+ if (showMode === SHOWMODE.BookMarkMode && pdfIframe.current) {
194
+ var iframeWindow = pdfIframe.current.contentWindow;
195
+ if (iframeWindow) {
196
+ // 监听iframe中的load事件
197
+ // 注:组件重绘不会引起执行第二次
198
+ iframeWindow.addEventListener('load', function () {
199
+ interval = setInterval(function () {
200
+ loadPDFViewerApplication(iframeWindow);
201
+ }, 100);
202
+ });
203
+ }
204
+ }
205
+
206
+ // SHOWMODE.PrintMode
207
+ if (showMode === SHOWMODE.PrintMode && pdfIframe.current) {
208
+ var _iframeWindow = pdfIframe.current.contentWindow;
209
+ if (_iframeWindow) {
210
+ // 监听iframe中的事件
211
+ _iframeWindow.addEventListener('load', function () {
212
+ interval = setInterval(function () {
213
+ loadPDFViewerApplication(_iframeWindow);
214
+ }, 100);
215
+ });
216
+ }
217
+ }
218
+ }, []);
219
+ var pfdStyle = function pfdStyle() {
220
+ var s = {};
221
+ switch (showMode) {
222
+ case SHOWMODE.BookMarkMode:
223
+ s.width = 'calc(100% - 200px)';
224
+ break;
225
+ case SHOWMODE.NormalMode:
226
+ s.width = '100%';
227
+ break;
228
+ case SHOWMODE.PrintMode:
229
+ s.width = '0px';
230
+ s.height = '0px';
231
+ break;
232
+ }
233
+ return s;
234
+ };
235
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
236
+ className: "lab-pdf-view"
237
+ }, /*#__PURE__*/React.createElement("div", {
238
+ className: "view-box",
239
+ style: pfdStyle()
240
+ }, /*#__PURE__*/React.createElement("iframe", {
241
+ ref: pdfIframe,
242
+ style: {
243
+ width: '100%',
244
+ height: '100%'
245
+ },
246
+ src: "/statics/pdfjs/web/viewer.html?file=".concat(src)
247
+ })), showMode === SHOWMODE.BookMarkMode ? /*#__PURE__*/React.createElement("div", {
248
+ className: "bookmarks-box"
249
+ }, bookMarks.length <= 0 ? /*#__PURE__*/React.createElement(Empty, {
250
+ description: "\u6682\u65E0\u4E66\u7B7E"
251
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tree, {
252
+ selectedKeys: [selectBookMask === null || selectBookMask === void 0 ? void 0 : selectBookMask.dirLabelId],
253
+ checkable: isShowCheck,
254
+ showLine: true,
255
+ defaultExpandAll: true,
256
+ defaultCheckedKeys: checkedKey && checkedKey.map(function (v) {
257
+ return v.dirLabelId;
258
+ }),
259
+ onSelect: handleOnSelect,
260
+ onCheck: handleOnCheck,
261
+ treeData: bookMarks,
262
+ fieldNames: {
263
+ title: 'title',
264
+ key: 'id',
265
+ children: 'items'
266
+ }
267
+ }))) : ''));
11
268
  };
12
269
  export default LabPdfView;
@@ -1,18 +1,18 @@
1
- .img-wrap {
2
- width: 100%;
3
- height: 100%;
4
- margin: 0;
5
- overflow: hidden;
6
- background: #fff;
1
+ // .img-wrap {
2
+ // width: 100%;
3
+ // height: 100%;
4
+ // margin: 0;
5
+ // overflow: hidden;
6
+ // background: #fff;
7
7
 
8
- img {
9
- display: block;
10
- width: auto;
11
- max-width: 94%;
12
- height: auto;
13
- max-height: 94%;
14
- }
15
- }
8
+ // img {
9
+ // display: block;
10
+ // width: auto;
11
+ // max-width: 94%;
12
+ // height: auto;
13
+ // max-height: 94%;
14
+ // }
15
+ // }
16
16
 
17
17
  .pdf-iframe {
18
18
  width: 100%;
@@ -20,3 +20,25 @@
20
20
  border: none;
21
21
  outline: none;
22
22
  }
23
+
24
+ .lab-pdf-view {
25
+ display: flex;
26
+ width: 100%;
27
+ height: 100%;
28
+
29
+ .view-box {
30
+ width: calc(100% - 200px);
31
+ height: 100%;
32
+ overflow: hidden;
33
+ }
34
+
35
+ .bookmarks-box {
36
+ width: 200px;
37
+ padding: 10px;
38
+ font-size: 18px;
39
+
40
+ .bookmasks-ol {
41
+ list-style-type: none;
42
+ }
43
+ }
44
+ }
@@ -11,8 +11,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  /*
12
12
  * @Author: xqy
13
13
  * @Date: 2024-04-10 11:04:12
14
- * @LastEditors: xqy
15
- * @LastEditTime: 2024-04-17 10:37:14
14
+ * @LastEditors: wusum
15
+ * @LastEditTime: 2024-05-11 16:47:26
16
16
  * @Description:图片轮播切换组件(支持pdf切换预览)
17
17
  */
18
18
  import { CloseOutlined, LeftOutlined, RightOutlined } from '@ant-design/icons';
@@ -44,7 +44,7 @@ var LabPictureCarousel = function LabPictureCarousel(props) {
44
44
  var _useState5 = useState(1),
45
45
  _useState6 = _slicedToArray(_useState5, 2),
46
46
  scale = _useState6[0],
47
- setScale = _useState6[1];
47
+ setScale = _useState6[1]; //初始缩放比例
48
48
  var _useState7 = useState([]),
49
49
  _useState8 = _slicedToArray(_useState7, 2),
50
50
  list = _useState8[0],
@@ -54,11 +54,9 @@ var LabPictureCarousel = function LabPictureCarousel(props) {
54
54
  var handleWheel = function handleWheel(event) {
55
55
  // event.preventDefault() //阻止默认的滚动行为,防止浏览器默认进行页面滚动
56
56
  var scaleChange = event.deltaY > 0 ? -0.1 : 0.1;
57
- var newScale = scale + scaleChange; // 计算新的缩放比例
58
- // 限制缩放比例在一定范围内(0.5到2之间)限制放大和缩小的范围
59
- if (newScale >= 0.2 && newScale <= 3) {
60
- setScale(newScale);
61
- }
57
+ //计算缩放比例,限制缩放比例在(0.5到4之间),防止过大或过小
58
+ var newScale = Math.min(Math.max(0.2, scale + scaleChange), 3);
59
+ setScale(newScale);
62
60
  };
63
61
 
64
62
  //点击切换事件
@@ -90,6 +88,14 @@ var LabPictureCarousel = function LabPictureCarousel(props) {
90
88
  close === null || close === void 0 || close();
91
89
  setScale(1); //恢复到初始图片的尺寸状态
92
90
  };
91
+
92
+ //监听esc事件
93
+ var handleKeyDown = function handleKeyDown(event) {
94
+ if (event !== null && event !== void 0 && event.key && (event === null || event === void 0 ? void 0 : event.key) === 'Escape') {
95
+ // esc键盘被按下
96
+ closeCarousel();
97
+ }
98
+ };
93
99
  useEffect(function () {
94
100
  if (Array.isArray(imgList) && imgList.length) {
95
101
  var _document$getElements, _document;
@@ -116,9 +122,14 @@ var LabPictureCarousel = function LabPictureCarousel(props) {
116
122
  return item;
117
123
  });
118
124
  }
125
+ //监听按键事件
126
+ document.addEventListener('keydown', handleKeyDown);
119
127
  }
120
128
  setIsShow(visible);
121
129
  setCurIndex(curImgIndex !== null && curImgIndex !== void 0 ? curImgIndex : 0);
130
+ return function () {
131
+ document.addEventListener('keydown', handleKeyDown);
132
+ };
122
133
  }, [visible]);
123
134
  return isShow && /*#__PURE__*/React.createElement("div", {
124
135
  className: cn('about-wrap')
@@ -147,13 +158,16 @@ var LabPictureCarousel = function LabPictureCarousel(props) {
147
158
  }, /*#__PURE__*/React.createElement("div", {
148
159
  className: cn('imgContainer', list[curIndex].fileType === 'pdf' && 'pdfStyle')
149
160
  }, list[curIndex].fileType === 'pdf' ? /*#__PURE__*/React.createElement(LabPdfView, {
161
+ showMode: 1,
150
162
  src: list[curIndex].filePath
151
163
  }) : /*#__PURE__*/React.createElement("img", {
152
164
  style: {
153
165
  maxWidth: '100%',
154
166
  maxHeight: '100%',
155
- transform: "scale(".concat(scale, ")"),
156
- transition: 'transform 0.25s ease' // 添加平滑的缩放过渡效果
167
+ transform: "scale3d(".concat(scale, ", ").concat(scale, ", 1)"),
168
+ transition: 'transform 0.25s ease',
169
+ // 添加平滑的缩放过渡效果
170
+ cursor: 'grab'
157
171
  },
158
172
  src: list[curIndex].filePath,
159
173
  onWheel: handleWheel
package/package.json CHANGED
@@ -1,78 +1,74 @@
1
- {
2
- "name": "xh-lab-rc",
3
- "version": "0.0.9",
4
- "description": " A react library for xinhelab",
5
- "license": "MIT",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
- "scripts": {
12
- "build": "father build",
13
- "build:watch": "father dev",
14
- "dev": "dumi dev",
15
- "docs:build": "dumi build",
16
- "doctor": "father doctor",
17
- "lint": "npm run lint:es && npm run lint:css",
18
- "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
19
- "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
20
- "prepare": "husky install && dumi setup",
21
- "prepublishOnly": "father doctor && npm run build",
22
- "start": "npm run dev"
23
- },
24
- "commitlint": {
25
- "extends": [
26
- "@commitlint/config-conventional"
27
- ]
28
- },
29
- "lint-staged": {
30
- "*.{md,json}": [
31
- "prettier --write --no-error-on-unmatched-pattern"
32
- ],
33
- "*.{css,less}": [
34
- "stylelint --fix",
35
- "prettier --write"
36
- ],
37
- "*.{js,jsx}": [
38
- "eslint --fix",
39
- "prettier --write"
40
- ],
41
- "*.{ts,tsx}": [
42
- "eslint --fix",
43
- "prettier --parser=typescript --write"
44
- ]
45
- },
46
- "dependencies": {
47
- "@ant-design/icons": "^5.3.5",
48
- "antd": "^5.15.3",
49
- "classnames": "^2.5.1",
50
- "dayjs": "^1.11.10"
51
- },
52
- "devDependencies": {
53
- "@commitlint/cli": "^17.1.2",
54
- "@commitlint/config-conventional": "^17.1.0",
55
- "@types/react": "^18.0.0",
56
- "@types/react-dom": "^18.0.0",
57
- "@umijs/lint": "^4.0.0",
58
- "dumi": "^2.2.13",
59
- "eslint": "^8.23.0",
60
- "father": "^4.1.0",
61
- "husky": "^8.0.1",
62
- "lint-staged": "^13.0.3",
63
- "prettier": "^2.7.1",
64
- "prettier-plugin-organize-imports": "^3.0.0",
65
- "prettier-plugin-packagejson": "^2.2.18",
66
- "react": "^18.0.0",
67
- "react-dom": "^18.0.0",
68
- "stylelint": "^14.9.1"
69
- },
70
- "peerDependencies": {
71
- "react": ">=16.9.0",
72
- "react-dom": ">=16.9.0"
73
- },
74
- "publishConfig": {
75
- "access": "public"
76
- },
77
- "authors": []
78
- }
1
+ {
2
+ "name": "xh-lab-rc",
3
+ "version": "0.0.11",
4
+ "description": " A react library for xinhelab",
5
+ "license": "MIT",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "father build",
13
+ "build:watch": "father dev",
14
+ "dev": "dumi dev",
15
+ "docs:build": "dumi build",
16
+ "doctor": "father doctor",
17
+ "lint": "npm run lint:es && npm run lint:css",
18
+ "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
19
+ "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
20
+ "prepare": "husky install && dumi setup",
21
+ "prepublishOnly": "father doctor && npm run build",
22
+ "start": "npm run dev"
23
+ },
24
+ "commitlint": {
25
+ "extends": [
26
+ "@commitlint/config-conventional"
27
+ ]
28
+ },
29
+ "lint-staged": {
30
+ "*.{md,json}": [
31
+ "prettier --write --no-error-on-unmatched-pattern"
32
+ ],
33
+ "*.{css,less}": [
34
+ "stylelint --fix",
35
+ "prettier --write"
36
+ ],
37
+ "*.{js,jsx}": [
38
+ "eslint --fix",
39
+ "prettier --write"
40
+ ],
41
+ "*.{ts,tsx}": [
42
+ "eslint --fix",
43
+ "prettier --parser=typescript --write"
44
+ ]
45
+ },
46
+ "dependencies": {
47
+ "@ant-design/icons": "^5.3.5",
48
+ "antd": "^5.15.3",
49
+ "classnames": "^2.5.1",
50
+ "dayjs": "^1.11.10"
51
+ },
52
+ "devDependencies": {
53
+ "@commitlint/cli": "^17.1.2",
54
+ "@commitlint/config-conventional": "^17.1.0",
55
+ "@types/react": "^18.0.0",
56
+ "@types/react-dom": "^18.0.0",
57
+ "@umijs/lint": "^4.0.0",
58
+ "dumi": "^2.2.13",
59
+ "eslint": "^8.23.0",
60
+ "father": "^4.1.0",
61
+ "husky": "^8.0.1",
62
+ "lint-staged": "^13.0.3",
63
+ "prettier": "^2.7.1",
64
+ "prettier-plugin-organize-imports": "^3.0.0",
65
+ "prettier-plugin-packagejson": "^2.2.18",
66
+ "react": "^18.0.0",
67
+ "react-dom": "^18.0.0",
68
+ "stylelint": "^14.9.1"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public"
72
+ },
73
+ "authors": []
74
+ }