askbot-dragon 1.3.18 → 1.3.19
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/README.md +27 -27
- package/babel.config.js +6 -6
- package/dragon.iml +7 -7
- package/package.json +57 -56
- package/public/index.html +43 -43
- package/src/App.vue +31 -31
- package/src/api/index.js +1 -1
- package/src/api/mock.http +2 -2
- package/src/api/requestUrl.js +185 -185
- package/src/assets/js/AliyunlssUtil.js +92 -92
- package/src/assets/js/Base64Util.js +22 -22
- package/src/assets/js/common.js +11 -11
- package/src/assets/js/script.js +36 -36
- package/src/assets/less/common.css +6773 -6773
- package/src/assets/less/converSationContainer/common.less +191 -191
- package/src/assets/less/converSationContainer/converSatonContainer.less +493 -493
- package/src/assets/less/iconfont.css +37 -37
- package/src/assets/less/ticketMessage.less +211 -211
- package/src/components/ActionAlertIframe.vue +112 -112
- package/src/components/AiGuide.vue +467 -467
- package/src/components/AnswerDocknowledge.vue +367 -363
- package/src/components/AskIFrame.vue +15 -15
- package/src/components/ConversationContainer.vue +4011 -4011
- package/src/components/FileType.vue +86 -86
- package/src/components/Message.vue +27 -27
- package/src/components/actionSatisfaction.vue +107 -107
- package/src/components/actionSendToBot.vue +62 -62
- package/src/components/answerDissatisfaction.vue +62 -62
- package/src/components/answerRadio.vue +76 -76
- package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
- package/src/components/ask-components/Msgloading.vue +37 -37
- package/src/components/ask-components/SatisfactionV2.vue +15 -15
- package/src/components/askVideo.vue +138 -138
- package/src/components/assetDetails.vue +370 -370
- package/src/components/assetMessage.vue +228 -228
- package/src/components/associationIntention.vue +328 -328
- package/src/components/attachmentPreview.vue +90 -90
- package/src/components/botActionSatisfactor.vue +68 -68
- package/src/components/chatContent.vue +513 -513
- package/src/components/feedBack.vue +136 -136
- package/src/components/fielListView.vue +347 -347
- package/src/components/file/AliyunOssComponents.vue +108 -108
- package/src/components/formTemplate.vue +3363 -3363
- package/src/components/loadingProcess.vue +164 -164
- package/src/components/message/ActionAlertIframe.vue +112 -112
- package/src/components/message/ShopMessage.vue +164 -164
- package/src/components/message/TextMessage.vue +924 -924
- package/src/components/message/TicketMessage.vue +177 -177
- package/src/components/message/swiper/index.js +4 -4
- package/src/components/message/swiper/ticketSwiper.vue +503 -503
- package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
- package/src/components/msgLoading.vue +231 -231
- package/src/components/myPopup.vue +70 -70
- package/src/components/pdfPosition.vue +371 -0
- package/src/components/popup.vue +227 -227
- package/src/components/previewDoc.vue +112 -112
- package/src/components/previewPdf.vue +215 -205
- package/src/components/receiverMessagePlatform.vue +65 -65
- package/src/components/recommend.vue +89 -89
- package/src/components/selector/hOption.vue +20 -20
- package/src/components/selector/hSelector.vue +199 -199
- package/src/components/selector/hWrapper.vue +216 -216
- package/src/components/senderMessagePlatform.vue +50 -50
- package/src/components/source/BotMessage.vue +24 -24
- package/src/components/source/CustomMessage.vue +24 -24
- package/src/components/test.vue +260 -260
- package/src/components/tree.vue +294 -294
- package/src/components/utils/AliyunIssUtil.js +72 -72
- package/src/components/utils/ckeditor.js +155 -155
- package/src/components/utils/ckeditorImageUpload/command.js +109 -109
- package/src/components/utils/ckeditorImageUpload/editing.js +11 -11
- package/src/components/utils/ckeditorImageUpload/plugin-image.js +11 -11
- package/src/components/utils/ckeditorImageUpload/toolbar-ui.js +40 -40
- package/src/components/utils/ckeditorfileUpload/common.js +111 -111
- package/src/components/utils/ckeditorfileUpload/editing.js +11 -11
- package/src/components/utils/ckeditorfileUpload/plugin_file.js +11 -11
- package/src/components/utils/ckeditorfileUpload/toolbar_ui.js +34 -34
- package/src/components/utils/format_date.js +25 -25
- package/src/components/utils/index.js +6 -6
- package/src/components/utils/math_utils.js +29 -29
- package/src/components/voiceComponent.vue +119 -119
- package/src/main.js +60 -60
- package/vue.config.js +55 -55
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="container">
|
|
3
|
-
<div class="top-container">
|
|
4
|
-
<div class="close">取消</div>
|
|
5
|
-
<div class="sure">确定</div>
|
|
6
|
-
</div>
|
|
7
|
-
<van-list v-model="loading" :finished="finished" finished-text="没有更多了" :offset="1" @load="onload" class="list-container">
|
|
8
|
-
<van-cell v-for="item in list" :key="item.id" :title="item.name" />
|
|
9
|
-
<!-- <van-cell title="123" />
|
|
10
|
-
<van-cell title="asdasd" />
|
|
11
|
-
<van-cell title="adszx" />
|
|
12
|
-
<van-cell title="zxc zc" />
|
|
13
|
-
<van-cell title="asdasd" />
|
|
14
|
-
<van-cell title="wqeqweqwe" />
|
|
15
|
-
<van-cell title="icvbncvbn" /> -->
|
|
16
|
-
</van-list>
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
19
|
-
<script>
|
|
20
|
-
export default {
|
|
21
|
-
props: {
|
|
22
|
-
finished:{
|
|
23
|
-
type: Boolean,
|
|
24
|
-
default: false
|
|
25
|
-
},
|
|
26
|
-
list:{
|
|
27
|
-
type:Array,
|
|
28
|
-
default:() =>{
|
|
29
|
-
return []
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
data() {
|
|
34
|
-
return {
|
|
35
|
-
show: false,
|
|
36
|
-
loading: false
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
methods: {
|
|
40
|
-
onload() {
|
|
41
|
-
this.$emit('onload')
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
</script>
|
|
46
|
-
|
|
47
|
-
<style lang="less" scoped>
|
|
48
|
-
.container {
|
|
49
|
-
width: 100%;
|
|
50
|
-
height: 100%;
|
|
51
|
-
.top-container {
|
|
52
|
-
width: 100%;
|
|
53
|
-
height: 50px;
|
|
54
|
-
display: flex;
|
|
55
|
-
align-items: center;
|
|
56
|
-
justify-content: space-between;
|
|
57
|
-
padding: 0 20px;
|
|
58
|
-
box-sizing: border-box;
|
|
59
|
-
.sure {
|
|
60
|
-
color: #366aff;
|
|
61
|
-
}
|
|
62
|
-
.close {
|
|
63
|
-
color: #cccccc;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
.list-container {
|
|
67
|
-
width: 100%;
|
|
68
|
-
height: calc(100% - 50px);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="container">
|
|
3
|
+
<div class="top-container">
|
|
4
|
+
<div class="close">取消</div>
|
|
5
|
+
<div class="sure">确定</div>
|
|
6
|
+
</div>
|
|
7
|
+
<van-list v-model="loading" :finished="finished" finished-text="没有更多了" :offset="1" @load="onload" class="list-container">
|
|
8
|
+
<van-cell v-for="item in list" :key="item.id" :title="item.name" />
|
|
9
|
+
<!-- <van-cell title="123" />
|
|
10
|
+
<van-cell title="asdasd" />
|
|
11
|
+
<van-cell title="adszx" />
|
|
12
|
+
<van-cell title="zxc zc" />
|
|
13
|
+
<van-cell title="asdasd" />
|
|
14
|
+
<van-cell title="wqeqweqwe" />
|
|
15
|
+
<van-cell title="icvbncvbn" /> -->
|
|
16
|
+
</van-list>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
props: {
|
|
22
|
+
finished:{
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false
|
|
25
|
+
},
|
|
26
|
+
list:{
|
|
27
|
+
type:Array,
|
|
28
|
+
default:() =>{
|
|
29
|
+
return []
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
data() {
|
|
34
|
+
return {
|
|
35
|
+
show: false,
|
|
36
|
+
loading: false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
methods: {
|
|
40
|
+
onload() {
|
|
41
|
+
this.$emit('onload')
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<style lang="less" scoped>
|
|
48
|
+
.container {
|
|
49
|
+
width: 100%;
|
|
50
|
+
height: 100%;
|
|
51
|
+
.top-container {
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 50px;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: space-between;
|
|
57
|
+
padding: 0 20px;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
.sure {
|
|
60
|
+
color: #366aff;
|
|
61
|
+
}
|
|
62
|
+
.close {
|
|
63
|
+
color: #cccccc;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
.list-container {
|
|
67
|
+
width: 100%;
|
|
68
|
+
height: calc(100% - 50px);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
71
|
</style>
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="pdf_view" ref="pdfView" @scroll="pdfScroll">
|
|
3
|
+
</div>
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script>
|
|
7
|
+
import _ from 'lodash'
|
|
8
|
+
import * as pdfjsLib from 'pdfjs-dist'
|
|
9
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = 'pdfjs-dist/build/pdf.worker';
|
|
10
|
+
import { TextLayerBuilder } from "pdfjs-dist/web/pdf_viewer";
|
|
11
|
+
// EventBus pdf_viewer 支持绑定自定义事件,一版不做
|
|
12
|
+
import 'pdfjs-dist/web/pdf_viewer.css'
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
name: 'pdfView',
|
|
16
|
+
props:['tagId'],
|
|
17
|
+
data() {
|
|
18
|
+
return {
|
|
19
|
+
url:'',
|
|
20
|
+
pages:[],
|
|
21
|
+
pageLoadStatus:{
|
|
22
|
+
WAIT: 0,
|
|
23
|
+
LOADED:1,
|
|
24
|
+
},
|
|
25
|
+
scale: 1,
|
|
26
|
+
rotation:0,
|
|
27
|
+
pageSize: {},
|
|
28
|
+
PAGE_INTVERVAL: 15,
|
|
29
|
+
SLICE_COUNT:5,
|
|
30
|
+
contentView:null,
|
|
31
|
+
fisrtLoad:true,
|
|
32
|
+
TextLayerBuilder:null,
|
|
33
|
+
totalPageCount: 0,
|
|
34
|
+
identifyTextPostion:{
|
|
35
|
+
top: 0,
|
|
36
|
+
left: 0 ,
|
|
37
|
+
width: 100,
|
|
38
|
+
height: 0,
|
|
39
|
+
page: 1,
|
|
40
|
+
pageHeight:0,
|
|
41
|
+
pageWidth:0,
|
|
42
|
+
extractInfo:{}
|
|
43
|
+
},
|
|
44
|
+
pdfUrl:''
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
methods:{
|
|
48
|
+
async loadPdfData(loadPage) {
|
|
49
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = require("pdfjs-dist/legacy/build/pdf.worker.entry.js");
|
|
50
|
+
// 拿到第一个分片
|
|
51
|
+
const { startPage, url } = await this.fetchPdfFragment(loadPage);
|
|
52
|
+
|
|
53
|
+
let loadingTask = pdfjsLib.getDocument(url)
|
|
54
|
+
loadingTask.promise.then((pdfDoc) => {
|
|
55
|
+
// 将已经下载的分片保存到 pages 数组中
|
|
56
|
+
for (let i = 0; i < pdfDoc.numPages; i += 1) {
|
|
57
|
+
const pageIndex = startPage + i;
|
|
58
|
+
const page = this.pages[pageIndex - 1];
|
|
59
|
+
if (page.loadStatus !== this.pageLoadStatus.LOADED) {
|
|
60
|
+
pdfDoc.getPage(i + 1).then((pdfPage) => {
|
|
61
|
+
page.pdfPage = pdfPage;
|
|
62
|
+
page.loadStatus = this.pageLoadStatus.LOADED;
|
|
63
|
+
// 通知可以进行渲染了
|
|
64
|
+
this.startRenderPages(pdfPage, page, pageIndex)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
initPages(totalPage) {
|
|
71
|
+
// const pages = [];
|
|
72
|
+
this.totalPageCount = totalPage
|
|
73
|
+
for (let i = 0; i < totalPage; i += 1) {
|
|
74
|
+
this.pages.push({
|
|
75
|
+
pageNo: i + 1,
|
|
76
|
+
loadStatus: this.pageLoadStatus.WAIT,
|
|
77
|
+
pdfPage: null,
|
|
78
|
+
dom: null
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
async fetchPdfFragment(pageIndex) {
|
|
83
|
+
// 置换加签后的文件地址。
|
|
84
|
+
let obj = {}
|
|
85
|
+
await this.$http.post(
|
|
86
|
+
'/knowledge-api/temporary-certificate/or-origin?expired=30',
|
|
87
|
+
this.pdfUrl + pageIndex + '.pdf',
|
|
88
|
+
{
|
|
89
|
+
headers: {
|
|
90
|
+
"Content-Type": "application/json",
|
|
91
|
+
},
|
|
92
|
+
}).then(async res =>{
|
|
93
|
+
if(res.data) {
|
|
94
|
+
// 最后返回一个 包含这4个参数的对象
|
|
95
|
+
obj = await {
|
|
96
|
+
"startPage": pageIndex, // 分片的开始页码
|
|
97
|
+
"endPage": pageIndex + 5, // 分片结束页码
|
|
98
|
+
"totalPage": this.totalPageCount, // pdf 总页数
|
|
99
|
+
"url": res.data // 分片内容下载地址
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
return obj
|
|
104
|
+
},
|
|
105
|
+
startRenderPages(pdfPage, page , pageIndex) {
|
|
106
|
+
const viewport = pdfPage.getViewport({
|
|
107
|
+
scale: this.scale, // 缩放的比例
|
|
108
|
+
rotation: this.rotation, // 旋转的角度
|
|
109
|
+
});
|
|
110
|
+
// 记录pdf页面高度
|
|
111
|
+
const pageSize = {
|
|
112
|
+
width: viewport.width,
|
|
113
|
+
height: viewport.height,
|
|
114
|
+
}
|
|
115
|
+
this.pageSize = pageSize
|
|
116
|
+
// 创建内容绘制区,并设置大小
|
|
117
|
+
this.contentView.style.width = `${ pageSize.width }px`;
|
|
118
|
+
this.contentView.style.height = `${( this.totalPageCount * (pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
|
|
119
|
+
this.contentView.style.margin = '0 auto 0'
|
|
120
|
+
this.contentView.style.position = 'relative'
|
|
121
|
+
// contentView.style.overflowY = 'auto'
|
|
122
|
+
this.$refs.pdfView.appendChild(this.contentView);
|
|
123
|
+
this.renderPages(pageIndex)
|
|
124
|
+
},
|
|
125
|
+
renderPageContent(page, pageIndex) {
|
|
126
|
+
const { pdfPage, pageNo, dom } = page;
|
|
127
|
+
// dom 元素已存在,无须重新渲染,直接返回
|
|
128
|
+
if (dom && dom.children.length != 0) {
|
|
129
|
+
// console.log(dom.children, 'length');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const viewport = pdfPage.getViewport({
|
|
133
|
+
scale: this.scale,
|
|
134
|
+
rotation: this.rotation,
|
|
135
|
+
});
|
|
136
|
+
// 创建新的canvas
|
|
137
|
+
const canvas = document.createElement('canvas');
|
|
138
|
+
const context = canvas.getContext('2d');
|
|
139
|
+
canvas.height = this.pageSize.height;
|
|
140
|
+
canvas.width = this.pageSize.width;
|
|
141
|
+
// 创建渲染的dom
|
|
142
|
+
const pageDom = document.createElement('div');
|
|
143
|
+
pageDom.style.position = 'absolute';
|
|
144
|
+
pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
|
|
145
|
+
pageDom.style.width = `${this.pageSize.width}px`;
|
|
146
|
+
pageDom.style.height = `${this.pageSize.height}px`;
|
|
147
|
+
pageDom.appendChild(canvas);
|
|
148
|
+
// 渲染内容
|
|
149
|
+
// console.log(pdfPage.render({
|
|
150
|
+
// canvasContext: context,
|
|
151
|
+
// viewport,
|
|
152
|
+
// }));
|
|
153
|
+
let renderContext = {
|
|
154
|
+
canvasContext: context,
|
|
155
|
+
viewport:viewport,
|
|
156
|
+
}
|
|
157
|
+
pdfPage.render(renderContext).promise.then(() =>{
|
|
158
|
+
console.log(pdfPage.getTextContent(),'getTextContent');
|
|
159
|
+
return pdfPage.getTextContent()
|
|
160
|
+
}).then((textContent) =>{
|
|
161
|
+
const textLayerDiv = document.createElement('div');
|
|
162
|
+
textLayerDiv.setAttribute('class', 'textLayer');
|
|
163
|
+
// 将文本图层div添加至每页pdf的div中
|
|
164
|
+
// 创建新的TextLayerBuilder实例
|
|
165
|
+
let textLayer = new TextLayerBuilder({
|
|
166
|
+
textLayerDiv:textLayerDiv,
|
|
167
|
+
pageIndex: pdfPage._pageIndex,
|
|
168
|
+
viewport: viewport,
|
|
169
|
+
});
|
|
170
|
+
textLayer.setTextContentSource(textContent);
|
|
171
|
+
textLayer.render(viewport)
|
|
172
|
+
pageDom.appendChild(textLayer.div);
|
|
173
|
+
})
|
|
174
|
+
page.dom = pageDom;
|
|
175
|
+
if(pageIndex == this.identifyTextPostion.page) {
|
|
176
|
+
let div = document.createElement('div')
|
|
177
|
+
div.style.position = 'absolute';
|
|
178
|
+
let lineHeightScaleWidth = this.pageSize.width / this.identifyTextPostion.pageWidth
|
|
179
|
+
let lineHeightScaleHeight = this.pageSize.height / this.identifyTextPostion.pageHeight
|
|
180
|
+
|
|
181
|
+
div.style.left = this.identifyTextPostion.left * lineHeightScaleWidth + 'px',
|
|
182
|
+
div.style.top = this.identifyTextPostion.top * lineHeightScaleHeight + 'px'
|
|
183
|
+
div.style.height = this.identifyTextPostion.height * lineHeightScaleHeight + 'px' ;
|
|
184
|
+
div.style.width = this.identifyTextPostion.width * lineHeightScaleWidth + 'px'
|
|
185
|
+
div.style.backgroundColor = 'rgb(191, 185, 255, 0.5)'
|
|
186
|
+
pageDom.appendChild(div)
|
|
187
|
+
}
|
|
188
|
+
this.contentView.appendChild(pageDom);
|
|
189
|
+
if(this.fisrtLoad) {
|
|
190
|
+
setTimeout(() =>{
|
|
191
|
+
this.$refs.pdfView.scrollTop = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL))}`
|
|
192
|
+
}, 100)
|
|
193
|
+
this.fisrtLoad = false
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
},
|
|
197
|
+
// 监听容器的滚动事件,触发 scrollPdf 方法
|
|
198
|
+
// 这里加了防抖保证不会一次产生过多请求
|
|
199
|
+
scrollPdf: _.debounce(function(e, that) {
|
|
200
|
+
const scrollTop = e.target.scrollTop;
|
|
201
|
+
const height = e.target.clientHeight;
|
|
202
|
+
// 根据内容可视区域中心点计算页码, 没有滚动时,指向第一页
|
|
203
|
+
const pageIndex = scrollTop > 0 ?
|
|
204
|
+
Math.ceil((scrollTop + (height / 2)) / (that.pageSize.height + that.PAGE_INTVERVAL)) :
|
|
205
|
+
1;
|
|
206
|
+
// that.loadBefore(pageIndex);
|
|
207
|
+
// that.loadAfter(pageIndex);
|
|
208
|
+
this.loadPdfData(pageIndex)
|
|
209
|
+
}, 500),
|
|
210
|
+
pdfScroll(e) {
|
|
211
|
+
// console.log(e);
|
|
212
|
+
this.scrollPdf(e,this)
|
|
213
|
+
},
|
|
214
|
+
// 分片每次只做一次处理,所以不考虑多片情况
|
|
215
|
+
loadBefore(pageIndex) {
|
|
216
|
+
this.loadPdfData(pageIndex)
|
|
217
|
+
// const start = (Math.floor(pageIndex / this.SLICE_COUNT) * this.SLICE_COUNT) - (this.SLICE_COUNT - 1);
|
|
218
|
+
// if (start > 0) {
|
|
219
|
+
// // const prevPage = this.pages[start - 1] || {};
|
|
220
|
+
// this.loadPdfData(start)
|
|
221
|
+
// // prevPage.loadStatus === this.pageLoadStatus.WAIT && this.loadPdfData(start);
|
|
222
|
+
// }
|
|
223
|
+
},
|
|
224
|
+
loadAfter(pageIndex) {
|
|
225
|
+
this.loadPdfData(pageIndex)
|
|
226
|
+
// const start = (Math.floor(pageIndex / this.SLICE_COUNT) * this.SLICE_COUNT) + 1;
|
|
227
|
+
// if (start <= this.pages.length) {
|
|
228
|
+
// // const nextPage = this.pages[start - 1] || {};
|
|
229
|
+
// this.loadPdfData(start)
|
|
230
|
+
// // nextPage.loadStatus === this.pageLoadStatus.WAIT && this.loadPdfData(start);
|
|
231
|
+
// }
|
|
232
|
+
},
|
|
233
|
+
// 首先我们获取到需要渲染的范围
|
|
234
|
+
// 根据当前的可视范围内的页码,我们前后只保留 8 页
|
|
235
|
+
getRenderScope (pageIndex) {
|
|
236
|
+
const pagesToRender = [];
|
|
237
|
+
let i = pageIndex - 1;
|
|
238
|
+
let j = pageIndex + 1;
|
|
239
|
+
// pageIndex - 1 表示当前页码数 对应的下标位置
|
|
240
|
+
pagesToRender.push(this.pages[pageIndex - 1]);
|
|
241
|
+
while (pagesToRender.length < 8 && pagesToRender.length < this.pages.length) {
|
|
242
|
+
if (i > 0) {
|
|
243
|
+
pagesToRender.push(this.pages[i - 1]);
|
|
244
|
+
i -= 1;
|
|
245
|
+
}
|
|
246
|
+
if (pagesToRender.length >= 8) {
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
if (j <= this.pages.length) {
|
|
250
|
+
pagesToRender.push(this.pages[j - 1]);
|
|
251
|
+
j += 1;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return pagesToRender;
|
|
255
|
+
},
|
|
256
|
+
// 渲染需要展示的页面,不需展示的页码将其清除
|
|
257
|
+
renderPages (pageIndex) {
|
|
258
|
+
const pagesToRender = this.getRenderScope(pageIndex);
|
|
259
|
+
for (const i of this.pages) {
|
|
260
|
+
if (pagesToRender.includes(i)) {
|
|
261
|
+
i.loadStatus === this.pageLoadStatus.LOADED ?
|
|
262
|
+
this.renderPageContent(i, pageIndex) :
|
|
263
|
+
this.renderPageLoading(i);
|
|
264
|
+
} else {
|
|
265
|
+
this.clearPage(i);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
// 清除页面 dom
|
|
270
|
+
clearPage (page) {
|
|
271
|
+
if (page.dom) {
|
|
272
|
+
this.contentView.removeChild(page.dom);
|
|
273
|
+
page.loadStatus = 0
|
|
274
|
+
page.dom = undefined;
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
// 页面正在下载时渲染loading视图
|
|
278
|
+
renderPageLoading (page) {
|
|
279
|
+
const { pageNo, dom } = page;
|
|
280
|
+
if (dom && dom.children.length != 0) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const pageDom = document.createElement('div');
|
|
284
|
+
pageDom.style.width = `${this.pageSize.width}px`;
|
|
285
|
+
pageDom.style.height = `${this.pageSize.height}px`;
|
|
286
|
+
pageDom.style.position = 'absolute';
|
|
287
|
+
pageDom.style.top = `${
|
|
288
|
+
((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL
|
|
289
|
+
}px`;
|
|
290
|
+
pageDom.style.backgroundImage = `url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif')`
|
|
291
|
+
pageDom.style.backgroundPosition = 'center'
|
|
292
|
+
pageDom.style.backgroundRepeat = 'no-repeat'
|
|
293
|
+
pageDom.style.backgroundColor = '#FFF'
|
|
294
|
+
page.dom = pageDom;
|
|
295
|
+
this.contentView.appendChild(pageDom);
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
computed:{
|
|
299
|
+
perviewUrl() {
|
|
300
|
+
return '/web/viewer.html?file=' + '/pdflist/pdf4split-1.pdf'
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
watch:{
|
|
304
|
+
tagId: {
|
|
305
|
+
handler(value) {
|
|
306
|
+
if(value) {
|
|
307
|
+
// 在 pdf_view 下创建 所有canvs的容器
|
|
308
|
+
this.contentView = document.createElement('div')
|
|
309
|
+
this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/' + value).then(res =>{
|
|
310
|
+
if(res.data.code == 0) {
|
|
311
|
+
let pdfResloute = res.data.data
|
|
312
|
+
// 根据当前页面宽度设置缩放比例
|
|
313
|
+
this.scale = this.$refs.pdfView.clientWidth / pdfResloute.pageWidth
|
|
314
|
+
// this.scale = 1
|
|
315
|
+
// 从后端获取到当前分片后所有的pdf页码,初始化数组,数组下{} 对应每页pdf文件
|
|
316
|
+
this.pdfUrl = pdfResloute.publicPageFileUrl.substring(0, pdfResloute.publicPageFileUrl.lastIndexOf('/') + 1)
|
|
317
|
+
this.identifyTextPostion.extractInfo = pdfResloute.extractInfo
|
|
318
|
+
this.identifyTextPostion.left = pdfResloute.extractInfo.location[0]
|
|
319
|
+
this.identifyTextPostion.top = pdfResloute.extractInfo.location[1]
|
|
320
|
+
this.identifyTextPostion.width = pdfResloute.extractInfo.location[2]
|
|
321
|
+
this.identifyTextPostion.height = pdfResloute.extractInfo.location[3]
|
|
322
|
+
this.identifyTextPostion.page = pdfResloute.page
|
|
323
|
+
this.identifyTextPostion.pageHeight = pdfResloute.pageHeight
|
|
324
|
+
this.identifyTextPostion.pageWidth = pdfResloute.pageWidth
|
|
325
|
+
this.initPages(pdfResloute.total)
|
|
326
|
+
// 定位功能,加载对应页码位置
|
|
327
|
+
this.loadPdfData(pdfResloute.page)
|
|
328
|
+
} else {
|
|
329
|
+
let div = document.createElement('div')
|
|
330
|
+
div.innerText = '文件加载异常'
|
|
331
|
+
this.contentView.appendChild(div)
|
|
332
|
+
this.$refs.pdfView.appendChild(this.contentView)
|
|
333
|
+
}
|
|
334
|
+
})
|
|
335
|
+
}
|
|
336
|
+
console.log(value);
|
|
337
|
+
},
|
|
338
|
+
deep:true,
|
|
339
|
+
immediate:true
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
mounted() {
|
|
343
|
+
// 在 pdf_view 下创建 所有canvs的容器
|
|
344
|
+
// this.contentView = document.createElement('div')
|
|
345
|
+
// // 从后端获取到当前分片后所有的pdf页码,初始化数组,数组下{} 对应每页pdf文件
|
|
346
|
+
// this.initPages(8);
|
|
347
|
+
// // 定位功能,加载对应页码位置
|
|
348
|
+
// this.loadPdfData(1)
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
</script>
|
|
352
|
+
|
|
353
|
+
<style lang="less" scoped>
|
|
354
|
+
.pdf_view {
|
|
355
|
+
width: 100%;
|
|
356
|
+
height: 100%;
|
|
357
|
+
overflow: auto;
|
|
358
|
+
background-color: #f5f7fb;
|
|
359
|
+
// > div {
|
|
360
|
+
// width: 100%;
|
|
361
|
+
// height: 100%;
|
|
362
|
+
// overflow: hidden;
|
|
363
|
+
// overflow-y: auto;
|
|
364
|
+
// position: relative;
|
|
365
|
+
// }
|
|
366
|
+
> iframe {
|
|
367
|
+
width: 100%;
|
|
368
|
+
height: 100%;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
</style>
|