askbot-dragon 1.3.63 → 1.3.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "askbot-dragon",
3
- "version": "1.3.63",
3
+ "version": "1.3.65",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -165,11 +165,14 @@ export default {
165
165
  url: url
166
166
  },"*");
167
167
  } else {
168
- if (isMobile()) {
169
- this.$refs.previewPdf.previewShowPopup = false;
170
- } else {
171
- this.$refs.previewPdf.drawer = false;
172
- }
168
+ // if (isMobile()) {
169
+ // this.$refs.previewPdf.drawer = true;
170
+ // this.$refs.previewPdf.previewShowPopup = false;
171
+ // } else {
172
+ // this.$refs.previewPdf.drawer = false;
173
+ // }
174
+ this.$refs.previewPdf.previewShowPopup = false;
175
+ this.$refs.previewPdf.drawer = false;
173
176
  let index = url.lastIndexOf('?')
174
177
  let type = ''
175
178
  let httpUrl = '/knowledge-api/knowledge/getTemporaryCertificate'
@@ -190,8 +193,10 @@ export default {
190
193
  if(res.data.code == '0') {
191
194
  this.previewHref = res.data.data;
192
195
  if (isMobile()){
196
+ this.$refs.previewPdf.drawer = true;
193
197
  this.$refs.previewPdf.previewShowPopup = true;
194
198
  } else {
199
+ this.$refs.previewPdf.previewShowPopup = false;
195
200
  this.$refs.previewPdf.drawer = true;
196
201
  }
197
202
  this.$refs.previewPdf.fileType = type
@@ -210,7 +215,6 @@ export default {
210
215
  }
211
216
  })
212
217
  }
213
-
214
218
  },
215
219
  fileType (url) {
216
220
  const fileType = url.substring(url.lastIndexOf('.'));
@@ -61,7 +61,15 @@ export default {
61
61
  currentPage: 0,
62
62
  changetoolbar: false,
63
63
  allTr:[],
64
- preViewType: 'pdf'
64
+ preViewType: 'pdf',
65
+ displacement:{
66
+ pageX:0,
67
+ pageY:0,
68
+ moveable:false,
69
+ pageX2:0,
70
+ pageY2:0,
71
+ originScale:1,
72
+ }
65
73
  }
66
74
  },
67
75
  // methods:{
@@ -528,16 +536,14 @@ export default {
528
536
  }
529
537
  }
530
538
  }
531
- // }, 0)
532
539
  }
533
540
  textLayer.setTextContent(textContent);
534
541
  textLayer.render()
535
- // pageDom.appendChild(textLayer.div);
542
+ pageDom.appendChild(textLayer.textLayerDiv);
536
543
  page.dom = pageDom;
537
544
  this.contentView.appendChild(pageDom);
538
545
  if (this.changetoolbar) {
539
546
  setTimeout(() => {
540
- console.log('========');
541
547
  this.renderHighlights()
542
548
  this.changetoolbar = false
543
549
  }, 100)
@@ -549,16 +555,18 @@ export default {
549
555
  for (let n = 0; n < loadNum; n++) {
550
556
  this.loadPdfData(pageNo + n)
551
557
  }
558
+ } else {
559
+ this.renderHighlights()
552
560
  }
553
561
  if (this.$refs.pdfView.scrollTop == Math.floor((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL))) {
554
562
  this.fisrtLoad = false
555
563
  } else {
556
564
  this.$refs.pdfView.scrollTop = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL))}`
557
565
  }
566
+ this.openTouch()
558
567
  }, 100)
559
568
  }
560
569
  })
561
-
562
570
  },
563
571
  // 监听容器的滚动事件,触发 scrollPdf 方法
564
572
  // 这里加了防抖保证不会一次产生过多请求
@@ -573,48 +581,10 @@ export default {
573
581
  const pageIndex = scrollTop > 0 ?
574
582
  Math.ceil((scrollTop + (height / 2)) / (that.pageSize.height + that.PAGE_INTVERVAL)) :
575
583
  1;
576
- // 当前页码在gpt识别列表内
577
- // let pdfResloute = this.cachePdf[this.currentPage]
578
- // debugger
579
- // let pdfResloute = this.cachePdf.find(cache => {
580
- // return cache.page == pageIndex
581
- // })
582
- // if (pdfResloute) {
583
- // this.identifyTextPostion.extractInfo = pdfResloute.extractInfo
584
- // this.identifyTextPostion.currentPageAllLine = []
585
- // this.cachePdf.forEach(item => {
586
- // if (item.page == pdfResloute.page) {
587
- // this.identifyTextPostion.currentPageAllLine.push({
588
- // lines: [...item.extractInfo.lines],
589
- // page: item.page
590
- // })
591
- // }
592
- // })
593
- // this.identifyTextPostion.left = pdfResloute.extractInfo.location[0]
594
- // this.identifyTextPostion.top = pdfResloute.extractInfo.location[1]
595
- // this.identifyTextPostion.width = pdfResloute.extractInfo.location[2]
596
- // this.identifyTextPostion.height = pdfResloute.extractInfo.location[3]
597
- // this.identifyTextPostion.page = pdfResloute.page
598
- // this.identifyTextPostion.pageHeight = pdfResloute.pageHeight
599
- // this.identifyTextPostion.pageWidth = pdfResloute.pageWidth
600
- // }
584
+
601
585
  pageIndex - 1 != 0 && that.loadPdfData(pageIndex - 1)
602
586
  that.loadPdfData(pageIndex)
603
587
  pageIndex + 1 <= that.totalPageCount && that.loadPdfData(pageIndex + 1)
604
- // if (height - (that.pageSize.height + that.PAGE_INTVERVAL) > (that.pageSize.height + that.PAGE_INTVERVAL)) {
605
- // let loadNum = Math.ceil(height / (that.pageSize.height + that.PAGE_INTVERVAL))
606
- // if (loadNum > 2 && pageIndex > 1) {
607
- // that.loadPdfData(pageIndex - 1)
608
- // that.loadPdfData(pageIndex)
609
- // that.loadPdfData(pageIndex + 1)
610
- // } else {
611
- // for (let n = 0; n < loadNum; n++) {
612
- // that.loadPdfData(pageIndex + n)
613
- // }
614
- // }
615
- // } else {
616
- // that.loadPdfData(pageIndex)
617
- // }
618
588
  }, 200),
619
589
  directScrolling (e, that) {
620
590
  if (this.fisrtLoad) {
@@ -627,35 +597,9 @@ export default {
627
597
  const pageIndex = scrollTop > 0 ?
628
598
  Math.ceil((scrollTop + (height / 2)) / (that.pageSize.height + that.PAGE_INTVERVAL)) :
629
599
  1;
630
- // // 当前页码在gpt识别列表内
631
- // let pdfResloute = this.cachePdf[this.currentPage]
632
- // if (pdfResloute) {
633
- // this.identifyTextPostion.extractInfo = pdfResloute.extractInfo
634
- // this.identifyTextPostion.currentPageAllLine = []
635
- // this.cachePdf.forEach(item => {
636
- // if (item.page == pdfResloute.page) {
637
- // this.identifyTextPostion.currentPageAllLine.push({
638
- // lines: [...item.extractInfo.lines],
639
- // page: item.page
640
- // })
641
- // }
642
- // })
643
- // this.identifyTextPostion.left = pdfResloute.extractInfo.location[0]
644
- // this.identifyTextPostion.top = pdfResloute.extractInfo.location[1]
645
- // this.identifyTextPostion.width = pdfResloute.extractInfo.location[2]
646
- // this.identifyTextPostion.height = pdfResloute.extractInfo.location[3]
647
- // this.identifyTextPostion.page = pdfResloute.page
648
- // this.identifyTextPostion.pageHeight = pdfResloute.pageHeight
649
- // this.identifyTextPostion.pageWidth = pdfResloute.pageWidth
650
- // }
651
600
  this.loadPdfData(pageIndex)
652
601
  },
653
602
  pdfScroll (e) {
654
- // if (this.changetoolbar) {
655
- // this.directScrolling(e, this)
656
- // } else {
657
- // this.debounceScrollPdf(e, this)
658
- // }
659
603
  if(this.preViewType !== 'pdf') {
660
604
  return
661
605
  }
@@ -789,18 +733,11 @@ export default {
789
733
  this.identifyTextPostion.page = pdfResloute.page
790
734
  this.identifyTextPostion.pageHeight = pdfResloute.pageHeight
791
735
  this.identifyTextPostion.pageWidth = pdfResloute.pageWidth
792
- // console.log( Math.floor((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + (this.pageSize.height + this.PAGE_INTVERVAL * 2) ,this.$refs.pdfView.scrollHeight);
793
- // debugger
794
- // if(this.$refs.pdfView.scrollTop == Math.floor((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) ||
795
- // Math.floor((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + (this.pageSize.height + this.PAGE_INTVERVAL) >= this.$refs.pdfView.scrollHeight) {
796
- // this.renderHighlights()
797
- // } else {
798
736
  // 在当前段落在最后一页pdf时,根据计算的高度并不能触发滚动,在此执行重新渲染方法,非次情况会执行两次,待优化
799
737
  this.$nextTick(() => {
800
738
  this.renderHighlights()
801
739
  })
802
740
  this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL))}`
803
- // }
804
741
  },
805
742
  scrollToExcalTop(currentPage) {
806
743
  for (let index = 0; index < this.allTr.length; index++) {
@@ -873,6 +810,89 @@ export default {
873
810
  })
874
811
  }
875
812
  })
813
+ },
814
+ openTouch() {
815
+ // this.$nextTick()将回调延迟到下次 DOM 更新循环之后执行
816
+ let that = this;
817
+ this.$nextTick(() => {
818
+ // 获取放大或缩小的区域DOM
819
+ let matrix_box = this.contentView
820
+ matrix_box.addEventListener("touchstart", function (event) {
821
+ let touches = event.touches;
822
+ let events = touches[0];
823
+ let events2 = touches[1];
824
+
825
+ // event.preventDefault();
826
+
827
+ // 第一个触摸点的坐标
828
+ that.displacement.pageX = events.pageX;
829
+ that.displacement.pageY = events.pageY;
830
+
831
+ that.displacement.moveable = true;
832
+
833
+ if (events2) {
834
+ that.displacement.pageX2 = events2.pageX;
835
+ that.displacement.pageY2 = events2.pageY;
836
+ }
837
+
838
+ that.displacement.originScale = this.scale || 1;
839
+ // console.log(that.displacement);
840
+ });
841
+ document.addEventListener("touchmove", function (event) {
842
+ if (!that.displacement.moveable) {
843
+ return;
844
+ }
845
+ // event.preventDefault();
846
+ let touches = event.touches;
847
+ let events = touches[0];
848
+ let events2 = touches[1];
849
+ // 双指移动
850
+ if (events2) {
851
+ // 第2个指头坐标在touchmove时候获取
852
+ if (!that.displacement.pageX2) {
853
+ that.displacement.pageX2 = events2.pageX;
854
+ }
855
+ if (!that.displacement.pageY2) {
856
+ that.displacement.pageY2 = events2.pageY;
857
+ }
858
+ // 双指缩放比例计算
859
+ let zoom =
860
+ that.getDistance(
861
+ {
862
+ x: events.pageX,
863
+ y: events.pageY
864
+ },
865
+ {
866
+ x: events2.pageX,
867
+ y: events2.pageY
868
+ }
869
+ ) /
870
+ that.getDistance(
871
+ {
872
+ x: that.displacement.pageX,
873
+ y: that.displacement.pageY
874
+ },
875
+ {
876
+ x: that.displacement.pageX2,
877
+ y: that.displacement.pageY2
878
+ }
879
+ );
880
+ // 应用在元素上的缩放比例
881
+ let newScale = that.displacement.originScale * zoom;
882
+ // 最大缩放比例限制
883
+ if (newScale > 1) {
884
+ newScale = 1;
885
+ }
886
+ // 记住使用的缩放值
887
+ that.displacement.scale = newScale;
888
+ // 图像应用缩放效果
889
+ // console.log(newScale);
890
+ matrix_box.style.transform = "scale(" + newScale + ")";
891
+ // 设置旋转元素的基点位置
892
+ matrix_box.style.transformOrigin = "0px 0px 0px";
893
+ }
894
+ });
895
+ });
876
896
  }
877
897
  },
878
898
  computed:{
@@ -948,14 +968,8 @@ export default {
948
968
  immediate:true
949
969
  }
950
970
  },
951
-
952
- mounted() {
953
- // 在 pdf_view 下创建 所有canvs的容器
954
- // this.contentView = document.createElement('div')
955
- // // 从后端获取到当前分片后所有的pdf页码,初始化数组,数组下{} 对应每页pdf文件
956
- // this.initPages(8);
957
- // // 定位功能,加载对应页码位置
958
- // this.loadPdfData(1)
971
+ mounted () {
972
+
959
973
  }
960
974
  }
961
975
  </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <van-popup v-model="previewShowPopup" position="bottom" :style="{ height: '90%', background:'#FFFFFF'}" v-if="previewShowPopup">
2
+ <!-- <van-popup v-model="previewShowPopup" position="bottom" :style="{ height: '90%', background:'#FFFFFF'}" v-if="previewShowPopup">
3
3
  <div class="footer">
4
4
  <span>查看详情</span>
5
5
  <section @click="close">
@@ -32,14 +32,17 @@
32
32
  <div class="loading_img" v-show="loading">
33
33
  <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
34
34
  </div>
35
- </van-popup>
35
+ </van-popup> -->
36
36
  <el-drawer
37
37
  title="我是标题"
38
38
  :visible.sync="drawer"
39
- v-else-if="drawer"
40
39
  :with-header="false"
41
- size="65%"
40
+ :append-to-body="true"
41
+ :destroy-on-close="true"
42
+ :direction="previewShowPopup ? 'btt' : 'ltr'"
43
+ :size="previewShowPopup ? '90%' : '65%'"
42
44
  >
45
+ <!-- v-else-if="drawer" -->
43
46
  <div class="drawer-footer">
44
47
  <span>查看详情</span>
45
48
  <section @click="close">