askbot-dragon 1.3.63 → 1.3.64

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.64",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -528,16 +528,14 @@ export default {
528
528
  }
529
529
  }
530
530
  }
531
- // }, 0)
532
531
  }
533
532
  textLayer.setTextContent(textContent);
534
533
  textLayer.render()
535
- // pageDom.appendChild(textLayer.div);
534
+ pageDom.appendChild(textLayer.textLayerDiv);
536
535
  page.dom = pageDom;
537
536
  this.contentView.appendChild(pageDom);
538
537
  if (this.changetoolbar) {
539
538
  setTimeout(() => {
540
- console.log('========');
541
539
  this.renderHighlights()
542
540
  this.changetoolbar = false
543
541
  }, 100)
@@ -549,16 +547,18 @@ export default {
549
547
  for (let n = 0; n < loadNum; n++) {
550
548
  this.loadPdfData(pageNo + n)
551
549
  }
550
+ } else {
551
+ this.renderHighlights()
552
552
  }
553
553
  if (this.$refs.pdfView.scrollTop == Math.floor((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL))) {
554
554
  this.fisrtLoad = false
555
555
  } else {
556
556
  this.$refs.pdfView.scrollTop = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL))}`
557
557
  }
558
+ this.openTouch()
558
559
  }, 100)
559
560
  }
560
561
  })
561
-
562
562
  },
563
563
  // 监听容器的滚动事件,触发 scrollPdf 方法
564
564
  // 这里加了防抖保证不会一次产生过多请求
@@ -573,48 +573,10 @@ export default {
573
573
  const pageIndex = scrollTop > 0 ?
574
574
  Math.ceil((scrollTop + (height / 2)) / (that.pageSize.height + that.PAGE_INTVERVAL)) :
575
575
  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
- // }
576
+
601
577
  pageIndex - 1 != 0 && that.loadPdfData(pageIndex - 1)
602
578
  that.loadPdfData(pageIndex)
603
579
  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
580
  }, 200),
619
581
  directScrolling (e, that) {
620
582
  if (this.fisrtLoad) {
@@ -627,35 +589,9 @@ export default {
627
589
  const pageIndex = scrollTop > 0 ?
628
590
  Math.ceil((scrollTop + (height / 2)) / (that.pageSize.height + that.PAGE_INTVERVAL)) :
629
591
  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
592
  this.loadPdfData(pageIndex)
652
593
  },
653
594
  pdfScroll (e) {
654
- // if (this.changetoolbar) {
655
- // this.directScrolling(e, this)
656
- // } else {
657
- // this.debounceScrollPdf(e, this)
658
- // }
659
595
  if(this.preViewType !== 'pdf') {
660
596
  return
661
597
  }
@@ -789,18 +725,11 @@ export default {
789
725
  this.identifyTextPostion.page = pdfResloute.page
790
726
  this.identifyTextPostion.pageHeight = pdfResloute.pageHeight
791
727
  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
728
  // 在当前段落在最后一页pdf时,根据计算的高度并不能触发滚动,在此执行重新渲染方法,非次情况会执行两次,待优化
799
729
  this.$nextTick(() => {
800
730
  this.renderHighlights()
801
731
  })
802
732
  this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL))}`
803
- // }
804
733
  },
805
734
  scrollToExcalTop(currentPage) {
806
735
  for (let index = 0; index < this.allTr.length; index++) {
@@ -873,6 +802,89 @@ export default {
873
802
  })
874
803
  }
875
804
  })
805
+ },
806
+ openTouch() {
807
+ // this.$nextTick()将回调延迟到下次 DOM 更新循环之后执行
808
+ let that = this;
809
+ this.$nextTick(() => {
810
+ // 获取放大或缩小的区域DOM
811
+ let matrix_box = this.contentView
812
+ matrix_box.addEventListener("touchstart", function (event) {
813
+ let touches = event.touches;
814
+ let events = touches[0];
815
+ let events2 = touches[1];
816
+
817
+ // event.preventDefault();
818
+
819
+ // 第一个触摸点的坐标
820
+ that.displacement.pageX = events.pageX;
821
+ that.displacement.pageY = events.pageY;
822
+
823
+ that.displacement.moveable = true;
824
+
825
+ if (events2) {
826
+ that.displacement.pageX2 = events2.pageX;
827
+ that.displacement.pageY2 = events2.pageY;
828
+ }
829
+
830
+ that.displacement.originScale = that.displacement.scale || 1;
831
+ // console.log(that.displacement);
832
+ });
833
+ document.addEventListener("touchmove", function (event) {
834
+ if (!that.displacement.moveable) {
835
+ return;
836
+ }
837
+ event.preventDefault();
838
+ let touches = event.touches;
839
+ let events = touches[0];
840
+ let events2 = touches[1];
841
+ // 双指移动
842
+ if (events2) {
843
+ // 第2个指头坐标在touchmove时候获取
844
+ if (!that.displacement.pageX2) {
845
+ that.displacement.pageX2 = events2.pageX;
846
+ }
847
+ if (!that.displacement.pageY2) {
848
+ that.displacement.pageY2 = events2.pageY;
849
+ }
850
+ // 双指缩放比例计算
851
+ let zoom =
852
+ that.getDistance(
853
+ {
854
+ x: events.pageX,
855
+ y: events.pageY
856
+ },
857
+ {
858
+ x: events2.pageX,
859
+ y: events2.pageY
860
+ }
861
+ ) /
862
+ that.getDistance(
863
+ {
864
+ x: that.displacement.pageX,
865
+ y: that.displacement.pageY
866
+ },
867
+ {
868
+ x: that.displacement.pageX2,
869
+ y: that.displacement.pageY2
870
+ }
871
+ );
872
+ // 应用在元素上的缩放比例
873
+ let newScale = that.displacement.originScale * zoom;
874
+ // 最大缩放比例限制
875
+ if (newScale > 1) {
876
+ newScale = 1;
877
+ }
878
+ // 记住使用的缩放值
879
+ that.displacement.scale = newScale;
880
+ // 图像应用缩放效果
881
+ // console.log(newScale);
882
+ matrix_box.style.transform = "scale(" + newScale + ")";
883
+ // 设置旋转元素的基点位置
884
+ matrix_box.style.transformOrigin = "0px 0px 0px";
885
+ }
886
+ });
887
+ });
876
888
  }
877
889
  },
878
890
  computed:{
@@ -887,6 +899,156 @@ export default {
887
899
  // 在 pdf_view 下创建 所有canvs的容器
888
900
  this.contentView = document.createElement('div')
889
901
  this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + value.join(',')).then(res =>{
902
+ res.data = {
903
+ "data": [
904
+ {
905
+ "id": "64592044ec66de61a8971049",
906
+ "knowledgeId": "64591f8ca3222a26557e17f0",
907
+ "mainId": "137e3903781f45cb8f6d5c4a1e17ac9c",
908
+ "page": 1,
909
+ "total": 2,
910
+ "pageHeight": 841.9,
911
+ "pageWidth": 595.3,
912
+ "publicPageFileUrl": "https://askbot-pdf-all.oss-cn-zhangjiakou.aliyuncs.com/137e3903781f45cb8f6d5c4a1e17ac9c/2023/05/09/12/16/02/64592042ec66de61a8970ff4/1.pdf",
913
+ "extractInfo": {
914
+ "location": [
915
+ 90,
916
+ 389.32,
917
+ 419.05,
918
+ 138.96997
919
+ ],
920
+ "content": "没想到正直的魏绛一口谢绝了赠礼,并劝晋悼公说:“《书》曰:‘居安思危’,思则有备,有备无患。”意思是说,如今晋国虽然很强大昌盛,但是我们绝对不能因此而大意,因为人在安全的时候,一定要想到未来可能会发生的危险,这样才会先做准备,以避免失败和灾祸的发生。[2]",
921
+ "lines": [
922
+ {
923
+ "content": "没想到正直的魏绛一口谢绝了赠礼,并劝晋悼公说:“《书》曰:",
924
+ "location": [
925
+ 111,
926
+ 389.32,
927
+ 398.05,
928
+ 14.169983
929
+ ]
930
+ },
931
+ {
932
+ "content": "‘居安思危’,思则有备,有备无患。”意思是说,如今晋国虽然很强大",
933
+ "location": [
934
+ 90,
935
+ 420.519,
936
+ 415.32794,
937
+ 14.17099
938
+ ]
939
+ },
940
+ {
941
+ "content": "昌盛,但是我们绝对不能因此而大意,因为人在安全的时候,一定要",
942
+ "location": [
943
+ 90,
944
+ 451.84003,
945
+ 415.3284,
946
+ 14.049988
947
+ ]
948
+ },
949
+ {
950
+ "content": "想到未来可能会发生的危险,这样才会先做准备,以避免失败和灾祸",
951
+ "location": [
952
+ 90,
953
+ 483.04,
954
+ 415.32837,
955
+ 14.049988
956
+ ]
957
+ },
958
+ {
959
+ "content": "的发生。[2]",
960
+ "location": [
961
+ 90,
962
+ 514.24,
963
+ 72.16771,
964
+ 14.049988
965
+ ]
966
+ }
967
+ ],
968
+ "tagId": null
969
+ }
970
+ },
971
+ {
972
+ "id": "64592044ec66de61a897104d",
973
+ "knowledgeId": "64591f8ca3222a26557e17f0",
974
+ "mainId": "137e3903781f45cb8f6d5c4a1e17ac9c",
975
+ "page": 2,
976
+ "total": 2,
977
+ "pageHeight": 841.9,
978
+ "pageWidth": 595.3,
979
+ "publicPageFileUrl": "https://askbot-pdf-all.oss-cn-zhangjiakou.aliyuncs.com/137e3903781f45cb8f6d5c4a1e17ac9c/2023/05/09/12/16/02/64592042ec66de61a8970ff4/2.pdf",
980
+ "extractInfo": {
981
+ "location": [
982
+ 90,
983
+ 109.84001,
984
+ 415.33,
985
+ 170.05
986
+ ],
987
+ "content": "家来说则更是如此。居安思危是一种超前的危机意识和忧患意识,人的一生当中不可能始终是一帆风顺,总会有曲折与风雨相伴,坎坷与逆境相随。所以,面对任何事情,人们都应当做到未雨绸缪,这样在遇到突发情况时才不至于手忙脚乱。在和平时期,要有居安思危的应变措施,在做好物质准备的同时,思想上还要常守不虞之戒,牢记失戒的教训,只有做到居安思危,才能有备无患,防患于未然。",
988
+ "lines": [
989
+ {
990
+ "content": "家来说则更是如此。居安思危是一种超前的危机意识和忧患意识,人",
991
+ "location": [
992
+ 90,
993
+ 109.84001,
994
+ 415.33,
995
+ 14.050003
996
+ ]
997
+ },
998
+ {
999
+ "content": "的一生当中不可能始终是一帆风顺,总会有曲折与风雨相伴,坎坷与",
1000
+ "location": [
1001
+ 90,
1002
+ 141.03996,
1003
+ 415.3284,
1004
+ 14.050003
1005
+ ]
1006
+ },
1007
+ {
1008
+ "content": "逆境相随。所以,面对任何事情,人们都应当做到未雨绸缪,这样在",
1009
+ "location": [
1010
+ 90,
1011
+ 172.23997,
1012
+ 415.3284,
1013
+ 14.050003
1014
+ ]
1015
+ },
1016
+ {
1017
+ "content": "遇到突发情况时才不至于手忙脚乱。在和平时期,要有居安思危的应",
1018
+ "location": [
1019
+ 90,
1020
+ 203.43999,
1021
+ 415.32837,
1022
+ 14.050003
1023
+ ]
1024
+ },
1025
+ {
1026
+ "content": "变措施,在做好物质准备的同时,思想上还要常守不虞之戒,牢记失",
1027
+ "location": [
1028
+ 90,
1029
+ 234.64,
1030
+ 415.3284,
1031
+ 14.050003
1032
+ ]
1033
+ },
1034
+ {
1035
+ "content": "戒的教训,只有做到居安思危,才能有备无患,防患于未然。",
1036
+ "location": [
1037
+ 90,
1038
+ 265.84003,
1039
+ 378.0035,
1040
+ 14.049988
1041
+ ]
1042
+ }
1043
+ ],
1044
+ "tagId": null
1045
+ }
1046
+ }
1047
+ ],
1048
+ "code": "0",
1049
+ "msg": null,
1050
+ "traceId": null
1051
+ }
890
1052
  if (res.data.code == 0) {
891
1053
  // tagIds 会按照gpt识别的生成有序的数组,前端直接按照下标的顺序取就可以了
892
1054
  // 缓存拿到的所有数据
@@ -948,14 +1110,8 @@ export default {
948
1110
  immediate:true
949
1111
  }
950
1112
  },
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)
1113
+ mounted () {
1114
+
959
1115
  }
960
1116
  }
961
1117
  </script>