xh-lab-rc 0.16.3 → 0.16.5

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.
@@ -15,6 +15,10 @@ interface PdfViewerProps {
15
15
  onDownloaded?: () => void;
16
16
  isColl?: boolean;
17
17
  btnShowList?: Array<boolean>;
18
+ onRenameBtnClick?: () => void;
19
+ onMoveBtnClick?: () => void;
20
+ onDownBtnClick?: () => void;
21
+ onDeleteBtnClick?: () => void;
18
22
  }
19
- declare const LabPdfViewMobile: ({ src, pdfjsSrc, fileTypeName, fileTitle, isColl, timeout, showTop, onCollected, onDownloaded, onTimeoutCallback, onChangeBookmarkDatas, btnShowList, }: PdfViewerProps) => React.JSX.Element;
23
+ declare const LabPdfViewMobile: ({ src, pdfjsSrc, fileTypeName, fileTitle, isColl, timeout, showTop, onCollected, onDownloaded, onTimeoutCallback, onChangeBookmarkDatas, onRenameBtnClick, onMoveBtnClick, onDownBtnClick, onDeleteBtnClick, btnShowList, }: PdfViewerProps) => React.JSX.Element;
20
24
  export default LabPdfViewMobile;
@@ -6,7 +6,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  * @Author: wusum
7
7
  * @Date: 2024-05-27 14:50:05
8
8
  * @LastEditors: wusum
9
- * @LastEditTime: 2024-06-14 14:28:21
9
+ * @LastEditTime: 2024-08-15 11:01:54
10
10
  */
11
11
  import { SearchBar, TabBar } from 'antd-mobile';
12
12
  import { CloseOutline, DownlandOutline, LeftOutline, RightOutline, SearchOutline, StarOutline, UnorderedListOutline } from 'antd-mobile-icons';
@@ -14,6 +14,7 @@ import * as React from 'react';
14
14
  import { useEffect, useState } from 'react';
15
15
  import "./style.less";
16
16
  var iframeWindow;
17
+ var bookList = [];
17
18
  var LabPdfViewMobile = function LabPdfViewMobile(_ref) {
18
19
  var src = _ref.src,
19
20
  _ref$pdfjsSrc = _ref.pdfjsSrc,
@@ -30,8 +31,12 @@ var LabPdfViewMobile = function LabPdfViewMobile(_ref) {
30
31
  onDownloaded = _ref.onDownloaded,
31
32
  onTimeoutCallback = _ref.onTimeoutCallback,
32
33
  onChangeBookmarkDatas = _ref.onChangeBookmarkDatas,
34
+ onRenameBtnClick = _ref.onRenameBtnClick,
35
+ onMoveBtnClick = _ref.onMoveBtnClick,
36
+ onDownBtnClick = _ref.onDownBtnClick,
37
+ onDeleteBtnClick = _ref.onDeleteBtnClick,
33
38
  _ref$btnShowList = _ref.btnShowList,
34
- btnShowList = _ref$btnShowList === void 0 ? [true, true, false, false] : _ref$btnShowList;
39
+ btnShowList = _ref$btnShowList === void 0 ? [true, true, false, false, false] : _ref$btnShowList;
35
40
  var fileSrc = src.replace(/\.(doc|docx|xls|xlsx)$/, '.pdf');
36
41
  var isTimeout = false;
37
42
  var isWork = false;
@@ -48,10 +53,15 @@ var LabPdfViewMobile = function LabPdfViewMobile(_ref) {
48
53
  _useState6 = _slicedToArray(_useState5, 2),
49
54
  isShowFind = _useState6[0],
50
55
  setIsShowFind = _useState6[1];
51
- var _useState7 = useState(['0', '0']),
56
+ var _useState7 = useState(false),
52
57
  _useState8 = _slicedToArray(_useState7, 2),
53
- findCount = _useState8[0],
54
- setFindCount = _useState8[1];
58
+ isShowOtherBtn = _useState8[0],
59
+ setIsShowOtherBtn = _useState8[1];
60
+ var _useState9 = useState(['0', '0']),
61
+ _useState10 = _slicedToArray(_useState9, 2),
62
+ findCount = _useState10[0],
63
+ setFindCount = _useState10[1];
64
+
55
65
  // 编排树形id
56
66
  function addItemId(t, j) {
57
67
  t.forEach(function (e, i) {
@@ -93,10 +103,13 @@ var LabPdfViewMobile = function LabPdfViewMobile(_ref) {
93
103
  function changeTabHandle(key) {
94
104
  setIsShowBookMark(false);
95
105
  setIsShowFind(false);
106
+ setIsShowOtherBtn(false);
96
107
  if (key === 'title') {
97
108
  setIsShowBookMark(true);
98
109
  } else if (key === 'find') {
99
110
  setIsShowFind(true);
111
+ } else if (key === 'op') {
112
+ setIsShowOtherBtn(!isShowOtherBtn);
100
113
  } else if (key === 'down') {
101
114
  downFileToLocal();
102
115
  setIsShowBookMark(false);
@@ -105,6 +118,31 @@ var LabPdfViewMobile = function LabPdfViewMobile(_ref) {
105
118
  setIsShowBookMark(false);
106
119
  }
107
120
  }
121
+ // 筛选书签
122
+ function handleSearch(bookList, value) {
123
+ var filterBookList = function filterBookList(list, value) {
124
+ return list.filter(function (item) {
125
+ if (item.title.indexOf(value) > -1) {
126
+ return item.title.indexOf(value) > -1;
127
+ } else {
128
+ if (item.items.length > 0) {
129
+ return item.items.some(function (v) {
130
+ return v.title.indexOf(value) > -1;
131
+ });
132
+ }
133
+ }
134
+ return false;
135
+ }).map(function (item) {
136
+ var itemNew = Object.assign({}, item);
137
+ if (itemNew.items.length > 0) {
138
+ itemNew.items = filterBookList(itemNew.items, value);
139
+ }
140
+ return itemNew;
141
+ });
142
+ };
143
+ var myBookList = filterBookList(bookList, value);
144
+ setBookmarks(myBookList);
145
+ }
108
146
  // 选择书签
109
147
  function clickBookMarkHandle(item) {
110
148
  if (item.dest) {
@@ -186,6 +224,8 @@ var LabPdfViewMobile = function LabPdfViewMobile(_ref) {
186
224
  if (bookMarksList) {
187
225
  addItemId(bookMarksList, '0-0');
188
226
  setBookmarks(bookMarksList);
227
+ bookList = bookMarksList;
228
+ console.log(111, bookList);
189
229
  onChangeBookmarkDatas === null || onChangeBookmarkDatas === void 0 || onChangeBookmarkDatas(bookMarksList);
190
230
  }
191
231
  readAndSetPage();
@@ -291,11 +331,18 @@ var LabPdfViewMobile = function LabPdfViewMobile(_ref) {
291
331
  className: "title"
292
332
  }, /*#__PURE__*/React.createElement("span", null, "\u76EE\u5F55"), /*#__PURE__*/React.createElement("span", {
293
333
  onClick: function onClick() {
334
+ handleSearch(bookList, '');
294
335
  setIsShowBookMark(false);
295
336
  }
296
337
  }, "\u5173\u95ED")), /*#__PURE__*/React.createElement("div", {
297
338
  className: "search"
298
339
  }, /*#__PURE__*/React.createElement(SearchBar, {
340
+ onSearch: function onSearch(v) {
341
+ handleSearch(bookList, v);
342
+ },
343
+ onClear: function onClear() {
344
+ handleSearch(bookList, '');
345
+ },
299
346
  placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9"
300
347
  })), /*#__PURE__*/React.createElement("div", {
301
348
  className: "book-mark-contents"
@@ -304,7 +351,49 @@ var LabPdfViewMobile = function LabPdfViewMobile(_ref) {
304
351
  key: place.id,
305
352
  place: place
306
353
  });
307
- }))))), isShowFind && /*#__PURE__*/React.createElement("div", {
354
+ }))))), isShowOtherBtn && /*#__PURE__*/React.createElement("div", {
355
+ className: "other-btn-box"
356
+ }, /*#__PURE__*/React.createElement("p", {
357
+ onClick: function onClick() {
358
+ setIsShowOtherBtn(false);
359
+ onRenameBtnClick === null || onRenameBtnClick === void 0 || onRenameBtnClick();
360
+ }
361
+ }, /*#__PURE__*/React.createElement("img", {
362
+ style: {
363
+ width: 15
364
+ },
365
+ src: '/statics/image/icon-rename.png'
366
+ }), /*#__PURE__*/React.createElement("span", null, "\u91CD\u547D\u540D")), /*#__PURE__*/React.createElement("p", {
367
+ onClick: function onClick() {
368
+ setIsShowOtherBtn(false);
369
+ onMoveBtnClick === null || onMoveBtnClick === void 0 || onMoveBtnClick();
370
+ }
371
+ }, /*#__PURE__*/React.createElement("img", {
372
+ style: {
373
+ width: 15
374
+ },
375
+ src: '/statics/image/icon-move.png'
376
+ }), /*#__PURE__*/React.createElement("span", null, "\u79FB\u52A8\u5230")), /*#__PURE__*/React.createElement("p", {
377
+ onClick: function onClick() {
378
+ setIsShowOtherBtn(false);
379
+ onDownBtnClick === null || onDownBtnClick === void 0 || onDownBtnClick();
380
+ }
381
+ }, /*#__PURE__*/React.createElement("img", {
382
+ style: {
383
+ width: 15
384
+ },
385
+ src: '/statics/image/icon-download.png'
386
+ }), /*#__PURE__*/React.createElement("span", null, "\u4E0B\u8F7D")), /*#__PURE__*/React.createElement("p", {
387
+ onClick: function onClick() {
388
+ setIsShowOtherBtn(false);
389
+ onDeleteBtnClick === null || onDeleteBtnClick === void 0 || onDeleteBtnClick();
390
+ }
391
+ }, /*#__PURE__*/React.createElement("img", {
392
+ style: {
393
+ width: 15
394
+ },
395
+ src: '/statics/image/icon-delete.png'
396
+ }), /*#__PURE__*/React.createElement("span", null, "\u5220\u9664"))), isShowFind && /*#__PURE__*/React.createElement("div", {
308
397
  className: "find-box"
309
398
  }, /*#__PURE__*/React.createElement("div", {
310
399
  className: "find",
@@ -344,21 +433,42 @@ var LabPdfViewMobile = function LabPdfViewMobile(_ref) {
344
433
  onChange: changeTabHandle
345
434
  }, btnShowList[0] && /*#__PURE__*/React.createElement(TabBar.Item, {
346
435
  key: 'title',
347
- icon: /*#__PURE__*/React.createElement(UnorderedListOutline, null),
436
+ icon: /*#__PURE__*/React.createElement(UnorderedListOutline, {
437
+ style: {
438
+ color: '#969ca6'
439
+ }
440
+ }),
348
441
  title: '目录'
349
442
  }), btnShowList[1] && /*#__PURE__*/React.createElement(TabBar.Item, {
350
443
  key: 'find',
351
- icon: /*#__PURE__*/React.createElement(SearchOutline, null),
444
+ icon: /*#__PURE__*/React.createElement(SearchOutline, {
445
+ style: {
446
+ color: '#969ca6'
447
+ }
448
+ }),
352
449
  title: '查询'
353
450
  }), btnShowList[2] && /*#__PURE__*/React.createElement(TabBar.Item, {
354
451
  key: 'down',
355
- icon: /*#__PURE__*/React.createElement(DownlandOutline, null),
452
+ icon: /*#__PURE__*/React.createElement(DownlandOutline, {
453
+ style: {
454
+ color: '#969ca6'
455
+ }
456
+ }),
356
457
  title: '下载'
357
458
  }), btnShowList[3] && /*#__PURE__*/React.createElement(TabBar.Item, {
459
+ key: 'op',
460
+ icon: /*#__PURE__*/React.createElement("img", {
461
+ style: {
462
+ width: 24
463
+ },
464
+ src: '/statics/image/icon-op.png'
465
+ }),
466
+ title: '操作'
467
+ }), btnShowList[4] && /*#__PURE__*/React.createElement(TabBar.Item, {
358
468
  key: 'remark',
359
469
  icon: /*#__PURE__*/React.createElement(StarOutline, {
360
470
  style: {
361
- color: isColl ? '#0069fd' : ''
471
+ color: isColl ? '#0069fd' : '#969ca6'
362
472
  }
363
473
  }),
364
474
  title: '收藏'
@@ -104,6 +104,33 @@
104
104
  align-items: center;
105
105
  }
106
106
  }
107
+
108
+ .other-btn-box {
109
+ animation: animate-find linear 0.3s;
110
+ display: flex;
111
+ flex-direction: column;
112
+ z-index: 2;
113
+ position: absolute;
114
+ bottom: 6px;
115
+ left: 0;
116
+ background-color: rgba(234, 234, 234, 100%);
117
+ border-radius: 8px;
118
+ width: 25%;
119
+ margin: 0 0 0 50%;
120
+
121
+ p {
122
+ display: flex;
123
+ flex-direction: row;
124
+ align-items: center;
125
+ justify-content: flex-start;
126
+ font-size: 14px;
127
+
128
+ img {
129
+ margin-right: 5px;
130
+ margin-left: 15px;
131
+ }
132
+ }
133
+ }
107
134
  }
108
135
 
109
136
  .bookmarks-box {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xh-lab-rc",
3
- "version": "0.16.3",
3
+ "version": "0.16.5",
4
4
  "description": " A react library for xinhelab",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",