askbot-dragon 1.7.44-beta → 1.7.45-beta
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
|
@@ -353,6 +353,10 @@ export default {
|
|
|
353
353
|
// } else {
|
|
354
354
|
// this.$refs.previewPdf.drawer = false;
|
|
355
355
|
// }
|
|
356
|
+
//该事件是为了打开新的弹框时关闭上一个弹框
|
|
357
|
+
window.parent.postMessage({
|
|
358
|
+
data: "close_drawer"
|
|
359
|
+
}, "*");
|
|
356
360
|
this.title = item.from || item.name
|
|
357
361
|
this.folderName = item.folderName
|
|
358
362
|
this.folderUrl = item.folderUrl
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="pdfViewPage" id="pdfViewPage">
|
|
3
3
|
<!-- 按钮容器 -->
|
|
4
|
-
<div class="button-container"
|
|
4
|
+
<div class="button-container">
|
|
5
|
+
<div class="change_scale">
|
|
6
|
+
<section @click="zoomOut">
|
|
7
|
+
<i class="el-icon-minus"></i>
|
|
8
|
+
</section>
|
|
9
|
+
<el-divider direction="vertical"></el-divider>
|
|
10
|
+
<section @click="zoomIn">
|
|
11
|
+
<i class="el-icon-plus"></i>
|
|
12
|
+
</section>
|
|
13
|
+
</div>
|
|
5
14
|
<!-- 文件上传 -->
|
|
6
|
-
<label for="file-upload" class="file-upload-label"
|
|
7
|
-
上传 PDF
|
|
8
|
-
<input
|
|
9
|
-
id="file-upload"
|
|
10
|
-
type="file"
|
|
11
|
-
accept="application/pdf"
|
|
12
|
-
@change="handleFileUpload"
|
|
13
|
-
class="file-input"
|
|
14
|
-
|
|
15
|
-
</label
|
|
15
|
+
<!-- <label for="file-upload" class="file-upload-label">-->
|
|
16
|
+
<!-- 上传 PDF 文件-->
|
|
17
|
+
<!-- <input-->
|
|
18
|
+
<!-- id="file-upload"-->
|
|
19
|
+
<!-- type="file"-->
|
|
20
|
+
<!-- accept="application/pdf"-->
|
|
21
|
+
<!-- @change="handleFileUpload"-->
|
|
22
|
+
<!-- class="file-input"-->
|
|
23
|
+
<!-- />-->
|
|
24
|
+
<!-- </label>-->
|
|
16
25
|
|
|
17
26
|
<!-- <!– 跳转按钮(已有高亮) –>-->
|
|
18
27
|
<!-- <button @click="jumpToHighlight" class="action-button">-->
|
|
@@ -64,6 +73,8 @@ if(pdfjsLib) {
|
|
|
64
73
|
pdfjsLib.GlobalWorkerOptions.workerSrc = window['pdfjs-dist/build/pdf.worker']
|
|
65
74
|
}
|
|
66
75
|
const { TextLayerBuilder } = window['pdfjs-dist/web/pdf_viewer']
|
|
76
|
+
|
|
77
|
+
import Vue from 'vue';
|
|
67
78
|
export default {
|
|
68
79
|
name: "PdfViewer",
|
|
69
80
|
data() {
|
|
@@ -170,7 +181,7 @@ export default {
|
|
|
170
181
|
await this.initPdf();
|
|
171
182
|
this.initObserver();
|
|
172
183
|
},
|
|
173
|
-
initObserver() {
|
|
184
|
+
initObserver(type) {
|
|
174
185
|
if (this.observer) {
|
|
175
186
|
this.observer.disconnect();
|
|
176
187
|
}
|
|
@@ -203,15 +214,17 @@ export default {
|
|
|
203
214
|
}
|
|
204
215
|
});
|
|
205
216
|
},300)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
217
|
+
if (type !== 'changeScale' && type !== 'onResize'){
|
|
218
|
+
setTimeout(async () => {
|
|
219
|
+
let currentPage = this.split_paragraphs[0];
|
|
220
|
+
let page = 1;
|
|
221
|
+
if (currentPage){
|
|
222
|
+
page = currentPage.original_paragraph[0].page
|
|
223
|
+
}
|
|
224
|
+
await this.loadPage(page);
|
|
225
|
+
this.jumpToHighlight(0);
|
|
226
|
+
},1300)
|
|
227
|
+
}
|
|
215
228
|
});
|
|
216
229
|
},
|
|
217
230
|
async loadPage(number){
|
|
@@ -251,8 +264,9 @@ export default {
|
|
|
251
264
|
// await renderTask.promise;
|
|
252
265
|
let hasDoc = document.getElementById('textLayer' + pageNumber)
|
|
253
266
|
if (hasDoc){
|
|
254
|
-
|
|
255
|
-
|
|
267
|
+
hasDoc.parentNode.removeChild(hasDoc);
|
|
268
|
+
// await renderTask.promise;
|
|
269
|
+
// return
|
|
256
270
|
}
|
|
257
271
|
await renderTask.promise.then(() => {
|
|
258
272
|
return page.getTextContent()
|
|
@@ -457,7 +471,8 @@ export default {
|
|
|
457
471
|
this.reloadAllPages(currentScroll);
|
|
458
472
|
},
|
|
459
473
|
reloadAllPages(scrollPosition) {
|
|
460
|
-
this.pages
|
|
474
|
+
const pages = Vue.observable(this.pages)
|
|
475
|
+
pages.forEach((p) => {
|
|
461
476
|
p.loaded = false;
|
|
462
477
|
this.$set(p,'loading',false)
|
|
463
478
|
if (p.canvas) {
|
|
@@ -469,7 +484,7 @@ export default {
|
|
|
469
484
|
const container = this.$refs.pdfContainer;
|
|
470
485
|
this.$nextTick(() => {
|
|
471
486
|
container.scrollTop = scrollPosition;
|
|
472
|
-
this.initObserver();
|
|
487
|
+
this.initObserver('changeScale');
|
|
473
488
|
container.scrollTop = container.scrollTop + 1;
|
|
474
489
|
container.scrollTop = container.scrollTop - 1;
|
|
475
490
|
});
|
|
@@ -585,28 +600,27 @@ export default {
|
|
|
585
600
|
this.scrollToHighlight(this.searchHighlights[this.currentSearchIndex]);
|
|
586
601
|
},
|
|
587
602
|
onResize() {
|
|
588
|
-
this.
|
|
589
|
-
this.
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
// }, 300);
|
|
603
|
+
clearTimeout(this.resizeTimeout);
|
|
604
|
+
this.resizeTimeout = setTimeout(() => {
|
|
605
|
+
if (this.renderInProgress) return;
|
|
606
|
+
const container = this.$refs.pdfContainer;
|
|
607
|
+
const currentScroll = container.scrollTop;
|
|
608
|
+
const pages = Vue.observable(this.pages)
|
|
609
|
+
pages.forEach((p) => {
|
|
610
|
+
p.loaded = false;
|
|
611
|
+
this.$set(p,'loading',false)
|
|
612
|
+
if (p.canvas) {
|
|
613
|
+
const ctx = p.canvas.getContext('2d');
|
|
614
|
+
ctx.clearRect(0,0,p.canvas.width,p.canvas.height);
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
this.$nextTick(() => {
|
|
618
|
+
container.scrollTop = currentScroll;
|
|
619
|
+
this.initObserver('onResize');
|
|
620
|
+
container.scrollTop = container.scrollTop + 1;
|
|
621
|
+
container.scrollTop = container.scrollTop - 1;
|
|
622
|
+
});
|
|
623
|
+
}, 300);
|
|
610
624
|
},
|
|
611
625
|
},
|
|
612
626
|
async mounted() {
|
|
@@ -656,9 +670,9 @@ export default {
|
|
|
656
670
|
display: flex;
|
|
657
671
|
flex-direction: column;
|
|
658
672
|
gap: 10px;
|
|
659
|
-
height: 100
|
|
673
|
+
height: calc(100% - 30px);
|
|
660
674
|
overflow-y: auto;
|
|
661
|
-
overflow-x:
|
|
675
|
+
overflow-x: auto;
|
|
662
676
|
margin: 0 auto;
|
|
663
677
|
position: relative;
|
|
664
678
|
border-radius: 10px;
|
|
@@ -679,10 +693,12 @@ export default {
|
|
|
679
693
|
position: relative;
|
|
680
694
|
display: flex;
|
|
681
695
|
justify-content: center;
|
|
696
|
+
width: 100%;
|
|
682
697
|
}
|
|
683
698
|
|
|
684
699
|
.canvas-wrapper {
|
|
685
700
|
position: relative;
|
|
701
|
+
width: 100%;
|
|
686
702
|
}
|
|
687
703
|
|
|
688
704
|
/* 在loading时覆盖canvas显示加载动画 */
|
|
@@ -716,10 +732,39 @@ canvas {
|
|
|
716
732
|
|
|
717
733
|
.button-container {
|
|
718
734
|
display: flex;
|
|
719
|
-
flex-wrap: wrap;
|
|
720
|
-
gap: 10px;
|
|
721
|
-
margin: 10px 0;
|
|
722
735
|
justify-content: center;
|
|
736
|
+
.change_scale {
|
|
737
|
+
width: 100%;
|
|
738
|
+
//height: 50px;
|
|
739
|
+
//position: absolute;
|
|
740
|
+
//top: 50px;
|
|
741
|
+
margin-bottom: 10px;
|
|
742
|
+
left: 0;
|
|
743
|
+
background: #ffffff;
|
|
744
|
+
display: flex;
|
|
745
|
+
align-items: center;
|
|
746
|
+
//padding: 0 10px;
|
|
747
|
+
box-sizing: border-box;
|
|
748
|
+
|
|
749
|
+
section {
|
|
750
|
+
cursor: pointer;
|
|
751
|
+
width: 30px;
|
|
752
|
+
height: 30px;
|
|
753
|
+
margin-right: 5px;
|
|
754
|
+
border-radius: 5px;
|
|
755
|
+
display: flex;
|
|
756
|
+
align-items: center;
|
|
757
|
+
justify-content: center;
|
|
758
|
+
|
|
759
|
+
i {
|
|
760
|
+
font-weight: 900;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
section:hover {
|
|
765
|
+
background: rgba(221, 222, 223, 1);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
723
768
|
}
|
|
724
769
|
|
|
725
770
|
.search-nav {
|