askbot-dragon 1.7.56-beta → 1.7.61-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.
Files changed (95) hide show
  1. package/README.md +27 -27
  2. package/babel.config.js +6 -6
  3. package/dragon.iml +7 -7
  4. package/package.json +56 -68
  5. package/public/index.html +75 -73
  6. package/src/App.vue +31 -31
  7. package/src/api/index.js +1 -1
  8. package/src/api/mock.http +2 -2
  9. package/src/api/requestUrl.js +185 -185
  10. package/src/assets/js/AliyunlssUtil.js +117 -141
  11. package/src/assets/js/Base64Util.js +22 -22
  12. package/src/assets/js/common.js +252 -252
  13. package/src/assets/js/hammer.js +89 -100
  14. package/src/assets/js/script.js +36 -36
  15. package/src/assets/less/common.css +6773 -6773
  16. package/src/assets/less/converSationContainer/common.less +192 -199
  17. package/src/assets/less/converSationContainer/converSatonContainer.less +493 -493
  18. package/src/assets/less/iconfont.css +37 -37
  19. package/src/assets/less/ticketMessage.less +294 -294
  20. package/src/components/ActionAlertIframe.vue +155 -178
  21. package/src/components/AiGuide.vue +471 -434
  22. package/src/components/AnswerDocknowledge.vue +1128 -1104
  23. package/src/components/AnswerVoice.vue +285 -285
  24. package/src/components/AskIFrame.vue +15 -15
  25. package/src/components/ConversationContainer.vue +10873 -10764
  26. package/src/components/FileType.vue +86 -86
  27. package/src/components/Message.vue +27 -27
  28. package/src/components/MyEditor.vue +341 -342
  29. package/src/components/QwFeedback.vue +302 -302
  30. package/src/components/actionSatisfaction.vue +107 -107
  31. package/src/components/actionSendToBot.vue +62 -62
  32. package/src/components/answerDissatisfaction.vue +62 -62
  33. package/src/components/answerRadio.vue +213 -213
  34. package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
  35. package/src/components/ask-components/Msgloading.vue +37 -37
  36. package/src/components/ask-components/SatisfactionV2.vue +15 -15
  37. package/src/components/askVideo.vue +139 -162
  38. package/src/components/assetDetails.vue +378 -378
  39. package/src/components/assetMessage.vue +229 -229
  40. package/src/components/associationIntention.vue +374 -378
  41. package/src/components/attachmentPreview.vue +90 -90
  42. package/src/components/botActionSatisfactor.vue +68 -68
  43. package/src/components/chatContent.vue +513 -513
  44. package/src/components/feedBack.vue +136 -136
  45. package/src/components/fielListView.vue +351 -351
  46. package/src/components/file/AliyunOssComponents.vue +108 -108
  47. package/src/components/formTemplate.vue +3498 -3502
  48. package/src/components/imgView.vue +31 -31
  49. package/src/components/intelligentSummary.vue +230 -234
  50. package/src/components/kkview.vue +1138 -1138
  51. package/src/components/loadingProcess.vue +164 -164
  52. package/src/components/markDownText.vue +363 -198
  53. package/src/components/message/ActionAlertIframe.vue +112 -112
  54. package/src/components/message/ShopMessage.vue +164 -164
  55. package/src/components/message/TextMessage.vue +924 -928
  56. package/src/components/message/TicketMessage.vue +201 -201
  57. package/src/components/message/swiper/index.js +4 -4
  58. package/src/components/message/swiper/ticketSwiper.vue +503 -503
  59. package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
  60. package/src/components/msgLoading.vue +231 -231
  61. package/src/components/myPopup.vue +73 -73
  62. package/src/components/pdfPosition.vue +1343 -1523
  63. package/src/components/popup.vue +228 -228
  64. package/src/components/previewDoc.vue +248 -252
  65. package/src/components/previewPdf.vue +775 -1104
  66. package/src/components/receiverMessagePlatform.vue +69 -69
  67. package/src/components/recommend.vue +80 -80
  68. package/src/components/selector/hOption.vue +20 -20
  69. package/src/components/selector/hSelector.vue +199 -199
  70. package/src/components/selector/hWrapper.vue +216 -216
  71. package/src/components/senderMessagePlatform.vue +58 -58
  72. package/src/components/source/BotMessage.vue +24 -24
  73. package/src/components/source/CustomMessage.vue +24 -24
  74. package/src/components/test.vue +260 -260
  75. package/src/components/tree.vue +307 -307
  76. package/src/components/utils/AliyunIssUtil.js +103 -103
  77. package/src/components/utils/ckeditor.js +185 -185
  78. package/src/components/utils/format_date.js +25 -25
  79. package/src/components/utils/index.js +6 -6
  80. package/src/components/utils/math_utils.js +29 -29
  81. package/src/components/voiceComponent.vue +119 -119
  82. package/src/components/welcomeKnowledgeFile.vue +343 -347
  83. package/src/components/welcomeLlmCard.vue +140 -144
  84. package/src/components/welcomeSuggest.vue +97 -97
  85. package/src/locales/cn.json +61 -61
  86. package/src/locales/en.json +61 -61
  87. package/src/main.js +76 -76
  88. package/vue.config.js +54 -54
  89. package/src/components/newPdfPosition.vue +0 -878
  90. package/src/components/pagination.vue +0 -129
  91. package/src/components/preview/docView.vue +0 -114
  92. package/src/components/preview/excelView.vue +0 -187
  93. package/src/components/preview/newPositionPreview.vue +0 -370
  94. package/src/components/preview/pdfView.vue +0 -824
  95. package/src/locales/jp.json +0 -73
@@ -1,1104 +1,775 @@
1
-
2
- <!-- preview-pdf
3
- 组件主要负责 知识项目中 文件的预览,携带定位信息参数 tagIds tagId 的会解析文件增加定位功能
4
- 不携带定位信息的 也是走 kkview项目预览
5
- 另外增加了在知识项目中预览当前文件的一些功能
6
- -->
7
- <template>
8
- <el-drawer title="" :visible.sync="drawer" :with-header="false" :append-to-body="true" :destroy-on-close="true"
9
- :modal="false" :direction="previewShowPopup ? 'btt' : 'rtl'" :size="previewShowPopup ? '90%' : '65%'"
10
- custom-class="pdf-preview-drawer" v-if="drawer">
11
- <div class="drawer-header" :class="isLiBang ? 'libang_head' : ''" v-if="!isPc">
12
- <div class="header-btn btn_position">
13
- <div class="onload_btn" v-if="isDownload" @click="downLoad">
14
- {{ $t('dragonCommon.download') }}
15
- </div>
16
- <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun" v-if="isHasChat">
17
- <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
18
- <span>{{ $t('dragonCommon.smartSummary') }}</span>
19
- </div>
20
- <template v-if="isHasChat">
21
- <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
22
- <i class="iconfont guoran-wendapingjia"></i>
23
- {{ $t('dragonCommon.chat') }}
24
- </div>
25
- <div class="chat chat_active" @click="previewToDialog(false)" v-else>
26
- <i class="iconfont guoran-wendapingjia"></i>
27
- {{ $t('dragonCommon.chat') }}
28
- </div>
29
- </template>
30
- </div>
31
- <div class="header_title">
32
- <template v-if="isDownload || isHasChat">
33
- <div class="top-header">
34
- <div class="header-btn">
35
- <div class="onload_btn" v-if="isDownload" @click="downLoad">
36
- 下载
37
- </div>
38
- <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun" v-if="isHasChat">
39
- <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
40
- <span>智能摘要</span>
41
- </div>
42
- <template v-if="isHasChat">
43
- <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
44
- <i class="iconfont guoran-wendapingjia"></i>
45
- 聊一聊
46
- </div>
47
- <div class="chat chat_active" @click="previewToDialog(false)" v-else>
48
- <i class="iconfont guoran-wendapingjia"></i>
49
- 聊一聊
50
- </div>
51
- </template>
52
- </div>
53
- <section @click="close">
54
- <i class="iconfont guoran-shanchu"></i>
55
- </section>
56
- </div>
57
- <span class="title_left">
58
- {{ title ? title : $t('dragonCommon.viewDetails') }}
59
- </span>
60
- </template>
61
- <div class="header_close" v-else>
62
- <span class="title_left">
63
- {{ title ? title : '查看详情' }}
64
- </span>
65
- <section @click="close">
66
- <i class="iconfont guoran-shanchu"></i>
67
- </section>
68
- </div>
69
- <p v-if="folderName && isLiBang" class="header_floder" @click="clickFloder">
70
- <i class="iconfont guoran-tongyichicun-wenjianjia-zhankaizhuangtai--folderOpen"></i>
71
- {{ folderName }}
72
- <i v-if="folderUrl" class="iconfont guoran-tongyichicun-dianjichakantuli"></i>
73
- </p>
74
- </div>
75
- </div>
76
- <div class="drawer-header" :class="isLiBang && folderName ? 'libang_head' : ''" v-else>
77
- <div class="header_title">
78
- <div :class="isLiBang && folderName ? 'header_close' : 'header_top'">
79
- <span class="title_left">
80
- {{ title ? title : $t('dragonCommon.viewDetails') }}
81
- </span>
82
- <div class="header-btn">
83
- <div class="onload_btn" v-if="isDownload" @click="downLoad">
84
- {{ $t('dragonCommon.download') }}
85
- </div>
86
- <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun"
87
- v-if="isHasChat || formKnowledgeManagement">
88
- <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
89
- <span>{{ $t('dragonCommon.smartSummary') }}</span>
90
- </div>
91
- <template v-if="isHasChat">
92
- <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
93
- <i class="iconfont guoran-wendapingjia"></i>
94
- {{ $t('dragonCommon.chat') }}
95
- </div>
96
- <div class="chat chat_active" @click="previewToDialog(false)" v-else>
97
- <i class="iconfont guoran-wendapingjia"></i>
98
- {{ $t('dragonCommon.chat') }}
99
- </div>
100
- </template>
101
- <section @click="close">
102
- <i class="iconfont guoran-shanchu"></i>
103
- </section>
104
- </div>
105
- </div>
106
- <p v-if="folderName && isLiBang" class="header_floder" @click="clickFloder">
107
- <i class="iconfont guoran-tongyichicun-wenjianjia-zhankaizhuangtai--folderOpen"></i>
108
- {{ folderName }}
109
- <i v-if="folderUrl" class="iconfont guoran-tongyichicun-dianjichakantuli"></i>
110
- </p>
111
- </div>
112
- </div>
113
- <div id="drawer_content_pre" :class="isLiBang && folderName ? 'libang_content_pre' : ''">
114
- <intelligent-summary v-show="showSummary && isHasChat" :tagIds="tagIds" :knowledgeId="knowledgeId"
115
- @closeSummary="closeSummary" @recommendQues="recommendQues"
116
- @getSummarySuccess="getSummarySuccess"></intelligent-summary>
117
- <div class="pdf_positon" :style="pdfStyle" v-if="tagIds && tagIds.length != 0 && drawer && newVersion === false && newFileType !== 'PPT'">
118
- <pdfPosition :tagIds="tagIds" :isMessageRecord="isMessageRecord" :textWatermarkStr="textWatermarkStr">
119
- </pdfPosition>
120
- </div>
121
- <new-position-preview
122
- ref="newPositionPreview"
123
- v-else-if="tagIds && tagIds.length!= 0 && newVersion && newFileType !== 'PPT'"
124
- :knowledgeId="knowledgeId"
125
- :tagIds="tagIds"
126
- :url="previewHref"
127
- ></new-position-preview>
128
- <template v-else>
129
- <div v-if="fileType == 'VIDEO'" style="width: 100%;height: 100%">
130
- <video :src="url" controls width="100%;" height="98%"></video>
131
- </div>
132
- <div v-else-if="fileType == 'HTML'" style="width: 100%;">
133
- <div class="preview_iframe_html" style="text-align:left" v-html="fileText"></div>
134
- </div>
135
- <template v-else-if="url.includes('https://www') || url.includes('http://www')">
136
- <iframe class="preview_iframe" :src="url" width="100%" height="100%" scrolling="100%" frameborder="no"
137
- border="0"></iframe>
138
- </template>
139
- <template v-else>
140
- <iframe class="preview_iframe_kk" :src="previewUrl" style="border:none;"
141
- :style="{ height: iframeHeight }"></iframe>
142
- <template v-if="!loading && (newFileType === 'PPT' && pageChunkData.length > 1)">
143
- <div class="btn_footer" v-if="!isPc">
144
- <div class="prev" @click="prev">上一段</div>
145
- <div class="next" @click="next">下一段</div>
146
- </div>
147
- <div id="pagination" v-if="isPc">
148
- <el-pagination :current-page="currentPage + 1" @current-change="currentChange" @prev-click="prev"
149
- @next-click="next" layout="slot, prev, pager, next" :page-size="1" :total="pageChunkData.length">
150
- <span class="total-class">答案由{{ pageChunkData.length }}段内容生成</span>
151
- </el-pagination>
152
- </div>
153
- </template>
154
- </template>
155
- </template>
156
- </div>
157
- <div class="loading_img" v-show="loading">
158
- <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
159
- </div>
160
- <div id="text">
161
- {{ copy }}
162
- </div>
163
- </el-drawer>
164
- </template>
165
-
166
- <script>
167
- import pdfPosition from './pdfPosition.vue'
168
- import { zoomElement } from '../assets/js/hammer'
169
- import IntelligentSummary from "./intelligentSummary";
170
- import { isMobile } from "../assets/js/common";
171
- import { Toast } from 'vant';
172
- import NewPositionPreview from "./preview/newPositionPreview";
173
- export default {
174
- data() {
175
- return {
176
- previewShowPopup: false,
177
- fileText: '',
178
- fileType: "",
179
- isPc: false,
180
- drawer: false,
181
- tagIds: [],
182
- // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
183
- loading: true,
184
- fileName: '',
185
- previewKnowledgeId: "",
186
- showSummary: false,
187
- iframeHeight: "100%",
188
- isDownload: false,
189
- textWatermarkStr: "",
190
- copy: '',
191
- newVersion: '',
192
- previewHref: "",
193
- newFileType: "",
194
- numberPage: 0,
195
- pageChunkData: [],
196
- currentPage: 0
197
- }
198
- },
199
- mounted() {
200
- this.$i18n.locale = sessionStorage.getItem("systemLanguage") || 'cn';
201
- window.addEventListener('message', this.handleIframeMessage, false);
202
- this.isPcFun();
203
- },
204
- props: {
205
- url: {
206
- type: String,
207
- required: true,
208
- },
209
- officePreviewType: {
210
- type: String,
211
- default: ''
212
- },
213
- isMessageRecord: {
214
- type: Boolean,
215
- default: false,
216
- },
217
- sourceFileType: {
218
- type: String,
219
- default: '',
220
- },
221
- title: {
222
- type: String,
223
- default: ''
224
- },
225
- isHasChat: {
226
- type: Boolean,
227
- default: false
228
- },
229
- knowledgeId: {
230
- type: String,
231
- default: '',
232
- },
233
- previewOssPath: {
234
- type: String,
235
- default: '',
236
- },
237
- folderName: {
238
- type: String,
239
- default: '',
240
- },
241
- folderUrl: {
242
- type: String,
243
- default: '',
244
- },
245
- isLiBang: {
246
- type: Boolean,
247
- default: false
248
- },
249
- formKnowledgeManagement: {
250
- type: Boolean,
251
- default: false
252
- }
253
- },
254
- components: {
255
- NewPositionPreview,
256
- IntelligentSummary,
257
- pdfPosition
258
- },
259
- watch: {
260
- drawer(value) {
261
- if (value) {
262
- this.$emit('open')
263
- this.$nextTick(() => {
264
- if (this.tagIds && this.tagIds.length != 0) {
265
- zoomElement(document.getElementById('pdf_container_view'))
266
- }
267
- })
268
- } else {
269
- this.$emit('close')
270
- }
271
- setTimeout(() => {
272
- let previewIframe = document.getElementsByClassName('preview_iframe')
273
- Array.from(previewIframe).forEach(item => {
274
- item.onload = () => {
275
- console.debug('previewIframe 106', previewIframe, this.drawer)
276
- item.style.backgroundImage = 'none'
277
- }
278
- })
279
- })
280
- },
281
- showSummary: {
282
- handler(val) {
283
- // if (!val){
284
- // this.$nextTick(() => {
285
- // let preCon = document.querySelector('.pdf_view');
286
- // if (preCon){
287
- // preCon.style.height = 'calc(100% - ' + 50 + 'px)'
288
- // }
289
- // })
290
- // } else {
291
- // this.getSummarySuccess();
292
- // }
293
- if (val) {
294
- this.getSummarySuccess();
295
- }
296
- }
297
- },
298
- knowledgeId: {
299
- handler(val) {
300
- if (val) {
301
- this.getTextWatermark();
302
- }
303
- }
304
- }
305
- },
306
- computed: {
307
- pdfStyle() {
308
- return {
309
- paddingTop: this.isPc ? '30px' : '0', // 30px 是 加上外层的 20 流出 50的上边距展示 放大缩小操作栏
310
- paddingBottom: this.tagIds > 1 ? '60px' : '0',
311
- height: '100%'
312
- }
313
- },
314
- previewUrl() {
315
- console.debug('VUE_APP_ENV', process.env.VUE_APP_ENV)
316
- let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
317
- // if(this.url != '') {
318
- // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
319
- // url += btoa(encodeURIComponent(this.url))
320
- // } else {
321
- // url += btoa(this.url)
322
- // }
323
- // }
324
- url = url + this.url
325
- url += '&officePreviewType=pdf'
326
- if (this.watermark) {
327
- url = this.watermark.textWatermarkValue ? (url += '&textWatermarkValue=' + this.watermark.textWatermarkValue) : url
328
- url = this.watermark.visitorWatermarkValue ? (url += '&visitorWatermarkValue=' + this.watermark.visitorWatermarkValue) : url
329
- }
330
- console.log('textWatermarkStr 216', this.textWatermarkStr)
331
- if (this.textWatermarkStr) {
332
- url += '&textWatermarkValue=' + this.textWatermarkStr
333
- }
334
- return url
335
- },
336
- // fileType() {
337
- // const fileType = this.url.substring(this.url.lastIndexOf('.'));
338
- // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
339
- // return 'VIDEO'
340
- // } else {
341
- // return 'OTHER'
342
- // }
343
-
344
- // }
345
- },
346
- methods: {
347
- close() {
348
- setTimeout(() => {
349
- this.previewShowPopup = false;
350
- this.fileType = ''
351
- }, 300)
352
- this.drawer = false;
353
- this.showSummary = false;
354
- },
355
- loadIframe() {
356
-
357
- if (this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0 && this.newFileType !== 'PPT')) {
358
- this.loading = false
359
- } else {
360
- let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
361
- if (iframe) {
362
- iframe.onload = () => {
363
- this.loading = false;
364
- document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
365
- }
366
- }
367
- // let time = setInterval(() =>{
368
- //
369
- // if(iframe) {
370
- // this.loading = false
371
- // clearInterval(time)
372
- // }
373
- // }, 500)
374
- }
375
- },
376
- getBolb() {
377
- this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false', {
378
- fileInOssPath: this.url,
379
- templateId: ''
380
- }).then(res => {
381
- if (res.data.code == 0) {
382
- this.fileText = res.data.data
383
- this.loading = false
384
- }
385
- })
386
- },
387
- previewToDialog(flag) {
388
- this.$emit('previewToDialog', flag)
389
- },
390
- closeSummary() {
391
- this.showSummary = false;
392
- },
393
- recommendQues(item, knowledgeId) {
394
- console.log('recommendQues', item, knowledgeId);
395
- this.$emit('recommendQues', item, knowledgeId)
396
- },
397
- handleIframeMessage(res) {
398
- if (res.data.type == 'getViewerHeight') {
399
- let iframeHeight = this.iframeHeight.replace('px', '')
400
- if (res.data.data && iframeHeight != (res.data.data + 50)) {
401
- this.iframeHeight = res.data.data + 50 + 'px'
402
- }
403
- }
404
- if (res.data.type == 'getViewPage' && res.data.data) {
405
- this.numberPage = Number(res.data.data);
406
- if (this.pageChunkData.length > 0) {
407
- this.scrollPPTPage(this.pageChunkData[0])
408
- }
409
- }
410
- if (res.data.type == 'getViewerHeight' || res.data.type == 'getViewPage') {
411
- if (this.pageChunkData.length > 0) {
412
- this.scrollPPTPage(this.pageChunkData[0])
413
- }
414
- }
415
- },
416
- summaryFun() {
417
- this.showSummary = !this.showSummary;
418
- if (this.showSummary) {
419
- document.getElementById('drawer_content_pre').scrollTop = 0;
420
- }
421
- },
422
- getSummarySuccess() {
423
- this.$nextTick(() => {
424
- // if (this.tagIds.length > 0){
425
- // let intelligentSummary = document.getElementById('intelligentSummary');
426
- // let preCon = document.querySelector('.pdf_view')
427
- // if (intelligentSummary){
428
- // let height = intelligentSummary.offsetHeight + (this.isPc ? 100 : 50 );
429
- // if (preCon){
430
- // preCon.style.height = 'calc(100% - ' + height + 'px)'
431
- // }
432
- // console.log('height',height,preCon)
433
- // }
434
- // }
435
- // let intelligentSummary = document.getElementById('intelligentSummary');
436
- // let height = intelligentSummary.offsetHeight
437
- // this.pdfStyle.height = 'calc(100% - ' + height + 'px)'
438
- })
439
- },
440
- getTextWatermark() {
441
- let url = '/knowledge-api/open/knowledge/getPermissionInfo';
442
- let obj = {
443
- "knowledgeId": this.knowledgeId,
444
- "userId": sessionStorage.getItem('_currentUserId'),
445
- "mainId": sessionStorage.getItem('_mainId'),
446
- "corpId": sessionStorage.getItem('_corpid')
447
- }
448
- this.$http.post(url, obj).then(res => {
449
- console.log('getTextWatermark', res.data.data)
450
- if (res.data.data) {
451
- this.textWatermarkStr = res.data.data.textWatermarkStr;
452
- this.isDownload = res.data.data.showDownloadBtn;
453
- }
454
- })
455
- },
456
- downLoad() {
457
- if (this.formKnowledgeManagement) {
458
- this.$emit('downLoad', this.previewOssPath);
459
- return
460
- }
461
- let url = this.previewOssPath
462
- if (decodeURIComponent(url) != url) {
463
- url = decodeURIComponent(url)
464
- }
465
- const fileType = url.substring(url.lastIndexOf('.'));
466
- this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
467
- headers: {
468
- "Content-Type": "application/json",
469
- }
470
- }).then(res => {
471
- console.log('downLoad 341', res)
472
- if (res.data || res.bodyText) {
473
- if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
474
- this.copy = res.data
475
- if (isMobile()) {
476
- setTimeout(() => {
477
- const range = document.createRange();
478
- range.selectNode(document.getElementById('text'));
479
- const selection = window.getSelection();
480
- //移除之前选中内容
481
- if (selection.rangeCount > 0) selection.removeAllRanges();
482
- selection.addRange(range);
483
- document.execCommand('copy');
484
- selection.removeAllRanges()
485
- Toast(this.$t('dragonCommon.Safaridownload'));
486
- this.close()
487
- }, 100)
488
- } else {
489
- let a = document.createElement('a')
490
- a.href = res.data
491
- a.download = (this.title) + fileType
492
- a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
493
- }
494
- return
495
- } else {
496
- // setTimeout(() =>{
497
- // window.open(res.data,'下载', 'noopener')
498
- // }, 2000)
499
- // window.open(res.data,'下载', 'noopener')
500
- if (isMobile()) {
501
-
502
- const iframe = document.createElement("iframe");
503
- iframe.setAttribute("hidden", "hidden");
504
- iframe.onload = () => {
505
- if (iframe) {
506
- console.log("iframe onload....")
507
- iframe.setAttribute('src', 'about:blank');
508
- }
509
- };
510
- document.body.insertBefore(iframe, null);
511
- iframe.setAttribute("src", res.data);
512
- } else {
513
- let a = document.createElement('a')
514
- a.href = res.data
515
- a.download = (this.title) + fileType
516
- a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
517
- }
518
- this.close()
519
- }
520
- }
521
- })
522
- },
523
- isPcFun() {
524
- if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
525
- this.isPc = false
526
- } else {
527
- this.isPc = true
528
- }
529
- },
530
- clickFloder() {
531
- this.$emit('previewClickFloder')
532
- },
533
- getOssPath(url) {
534
- let httpUrl = '/knowledge-api/knowledge/getTemporaryCertificate';
535
- let type = this.getFileType(url)
536
- this.newFileType = type;
537
- if (type === 'VIDEO' || type === 'PDF' || type === 'EXCEL' || type === 'TXT' || type === 'DOC') {
538
- httpUrl += '?needEncrypt=false'
539
- } else {
540
- httpUrl += '?needEncrypt=true'
541
- }
542
- this.$http.post(httpUrl, {
543
- "fileInOssPath": url
544
- }).then(res => {
545
- console.log('getOssPath', res)
546
- if (res.data.code == '0') {
547
- this.previewHref = res.data.data;
548
- }
549
- })
550
- },
551
- getFileType(url) {
552
- let index = url.lastIndexOf('?')
553
- let newFileInOssPath = url.substring(0, url.indexOf("?"))
554
- if (index == -1) {
555
- newFileInOssPath = url
556
- }
557
- const fileType = newFileInOssPath.substring(newFileInOssPath.lastIndexOf('.'));
558
- if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.MOVC' || fileType === '.mov' || fileType === '.movc') {
559
- return 'VIDEO'
560
- } else if (fileType === '.html') {
561
- return 'HTML'
562
- } else if (fileType === '.png' || fileType === '.jpg' || fileType === '.jpeg' || fileType === '.PNG' || fileType === '.JPG' || fileType === '.JPEG') {
563
- return 'IMAGE'
564
- } else if (fileType === '.docx' || fileType === '.doc') {
565
- return 'DOC'
566
- } else if (fileType === '.ppt' || fileType === '.pptx') {
567
- return 'PPT'
568
- } else if (fileType === '.pdf') {
569
- return 'PDF'
570
- } else if (fileType === '.txt') {
571
- return 'TXT'
572
- } else {
573
- return 'OTHER'
574
- }
575
- },
576
- //判断是否使用新定位组件
577
- getLocationInfo() {
578
- this.newVersion = "";
579
- this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + this.tagIds.join(',')).then(res => {
580
- console.log('getLocationInfo', res)
581
- this.pageChunkData = [];
582
- if (res.data.code == 0) {
583
- if (res.data.data && res.data.data.length > 0 && res.data.data[0].extractVersion == 'v3') {
584
- this.newVersion = true;
585
- if (this.newFileType !== 'PPT') {
586
- this.loading = false;
587
- }
588
- for (let i = 0; i < res.data.data.length; i++) {
589
- if (res.data.data[i].paragraphChunkInfo && res.data.data[i].paragraphChunkInfo.pageChunkData) {
590
- this.pageChunkData.push(res.data.data[i].paragraphChunkInfo.pageChunkData.page_number)
591
- }
592
- }
593
- if (this.pageChunkData.length > 1) {
594
- let iframe = document.getElementsByClassName('preview_iframe_kk')
595
- if (iframe && iframe.length > 0) {
596
- iframe[0].style.paddingBottom = '50px'
597
- }
598
- }
599
- } else {
600
- this.newVersion = false;
601
- }
602
- }
603
- })
604
- },
605
- currentChange(value) {
606
- this.currentPage = value - 1;
607
- this.scrollPPTPage()
608
- },
609
- prev() {
610
- if (this.currentPage == 0) {
611
- return
612
- }
613
- this.currentPage--;
614
- this.scrollPPTPage()
615
- },
616
- next() {
617
- if (this.currentPage === (this.pageChunkData.length - 1)) {
618
- return;
619
- }
620
- this.currentPage++;
621
- this.scrollPPTPage()
622
- },
623
- scrollPPTPage() {
624
- if (this.numberPage > 0) {
625
- let pageNumber = this.pageChunkData[this.currentPage];
626
- let height = Math.floor(Number(this.iframeHeight.replace('px', "")));
627
- let pageHeight = Math.floor(height / this.numberPage);
628
- let scrollHeight = (pageNumber - 1) * pageHeight;
629
- let dom = document.getElementById('drawer_content_pre');
630
- if (dom) {
631
- dom.scrollTo(0, scrollHeight)
632
- }
633
- }
634
- }
635
- },
636
- beforeDestroy() {
637
- window.removeEventListener('message', this.handleIframeMessage);
638
- }
639
- }
640
- </script>
641
-
642
- <style lang="less" scoped>
643
- #drawer_content_pre {
644
- padding: 20px;
645
- scroll-behavior: smooth;
646
-
647
- .mobile_onload_btn {
648
- position: absolute;
649
- right: 0;
650
- bottom: 10%;
651
- width: 20px;
652
- height: 60px;
653
- display: flex;
654
- align-items: center;
655
- justify-content: center;
656
- cursor: pointer;
657
- border-top-left-radius: 10px;
658
- border-bottom-left-radius: 10px;
659
- color: #366aff;
660
- background: #ffffff;
661
- border: 1px solid #a1b9ff;
662
- font-size: 12px;
663
- border-right: none;
664
- text-align: center;
665
- }
666
-
667
- .pdf_positon {
668
- width: 100%;
669
- box-sizing: border-box;
670
- }
671
- }
672
-
673
- .onload_btn {
674
- width: 76px;
675
- height: 26px;
676
- display: flex;
677
- align-items: center;
678
- justify-content: center;
679
- cursor: pointer;
680
- margin-right: 10px;
681
- border-radius: 15px;
682
- color: #366aff;
683
- background: #ffffff;
684
- border: 1px solid #a1b9ff;
685
- box-sizing: border-box;
686
- }
687
-
688
- .preview_iframe {
689
- width: 100%;
690
- height: 100%;
691
- box-sizing: border-box;
692
- background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
693
- background-position: center;
694
- background-size: 50px;
695
- background-repeat: no-repeat;
696
- }
697
-
698
- .preview_iframe_kk {
699
- width: 100%;
700
- height: 100%;
701
- }
702
- .btn_footer {
703
- width: 100%;
704
- height: 60px;
705
- display: flex;
706
- align-items: center;
707
- justify-content: space-around;
708
- position: absolute;
709
- bottom: 0px;
710
- left: 0;
711
- z-index: 999;
712
- background: #ffffff;
713
-
714
- .prev,
715
- .next {
716
- width: 35%;
717
- height: 40px;
718
- display: flex;
719
- align-items: center;
720
- justify-content: center;
721
- border-radius: 50px;
722
- cursor: pointer;
723
- }
724
-
725
- .prev {
726
- background: #F2F5FA;
727
- color: #000;
728
- }
729
-
730
- .next {
731
- background: #366aff;
732
- color: #ffffff;
733
- }
734
- }
735
- #pagination {
736
- .total-class {
737
- margin-right: 13px;
738
- font-weight: 400;
739
- }
740
-
741
- position: absolute;
742
- bottom: 0px;
743
- right: 0;
744
- width: 100%;
745
- display: flex;
746
- align-items: center;
747
- justify-content: center;
748
- height: 50px;
749
- background-color: white;
750
- box-shadow: 0px 0px 18px 0px rgba(29, 55, 129, 0.07);
751
- border-radius: 5px;
752
- z-index: 1000;
753
-
754
-
755
-
756
- /deep/.el-pagination {
757
- margin-right: 110px;
758
- }
759
-
760
- /deep/.el-pager {
761
- background: #EDF0F6;
762
- border-radius: 15px;
763
- }
764
-
765
- /deep/.el-pagination.is-background .btn-next {
766
- width: 30px;
767
- height: 30px;
768
- background: #EDF0F6;
769
- border-radius: 50%;
770
- }
771
-
772
- /deep/.el-pagination .btn-next {
773
- width: 30px;
774
- height: 30px;
775
- background: #EDF0F6;
776
- border-radius: 50%;
777
- padding-left: 0;
778
- margin-left: 5px;
779
- }
780
-
781
- /deep/.el-pagination .btn-prev {
782
- width: 30px;
783
- height: 30px;
784
- background: #EDF0F6;
785
- border-radius: 50%;
786
- padding-right: 0;
787
- margin-right: 5px;
788
- }
789
-
790
- /deep/.el-pagination button {
791
- padding: 0;
792
- min-width: 30px;
793
- }
794
-
795
- /deep/.el-pager li {
796
- background: #EDF0F6;
797
- height: 30px;
798
- min-width: 30px;
799
- line-height: 30px;
800
- font-size: 12px;
801
- color: #717b90;
802
- }
803
-
804
- /deep/.el-pager li:first-child {
805
- border-bottom-left-radius: 15px !important;
806
- border-top-left-radius: 15px !important;
807
- }
808
-
809
- /deep/.el-pager li:last-child {
810
- border-top-right-radius: 15px !important;
811
- border-bottom-right-radius: 15px !important;
812
- }
813
-
814
- /deep/.el-pager li.active {
815
- width: 30px;
816
- height: 30px;
817
- min-width: 30px;
818
- background: #366AFF;
819
- border: 3px solid #A1B9FF;
820
- border-radius: 50%;
821
- line-height: 24px;
822
- color: white;
823
- }
824
-
825
- /deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
826
- background: #366AFF;
827
- }
828
- }
829
- .preview_iframe_html {
830
- width: 100%;
831
- height: 100%;
832
- overflow-y: scroll;
833
- text-align: left;
834
- box-sizing: border-box;
835
- padding: 16px;
836
-
837
- /deep/.lake-content {
838
- margin-left: 10px;
839
- }
840
-
841
- /deep/a:link {
842
- color: #0000ee !important;
843
- }
844
-
845
- /deep/a:visited {
846
- color: #0000ee !important;
847
- }
848
-
849
- /deep/a:hover {
850
- color: #0000ee !important;
851
- }
852
-
853
- /deep/a:active {
854
- color: #0000ee !important;
855
- }
856
-
857
- /deep/li:not(.rich-text-li),
858
- ol:not(.list-paddingleft-2),
859
- ul:not(.list-paddingleft-2) {
860
- list-style-type: auto !important;
861
- }
862
-
863
- /deep/img {
864
- width: 100%;
865
- }
866
-
867
- /deep/.ne-table {
868
- width: 100% !important;
869
- }
870
- }
871
-
872
- .footer {
873
- width: calc(100% - 40px);
874
- height: 50px;
875
- display: flex;
876
- align-items: center;
877
- justify-content: space-between;
878
- cursor: pointer;
879
- padding: 0 20px;
880
- border-bottom: 1px solid #cccccc;
881
- }
882
-
883
- .loading_img {
884
- display: flex;
885
- align-items: center;
886
- justify-content: center;
887
- width: 100%;
888
- height: 100%;
889
- position: absolute;
890
- top: 0;
891
- left: 0;
892
- background: #FFF;
893
-
894
- img {
895
- width: 50px;
896
- height: 50px;
897
- }
898
- }
899
-
900
- .libang_head {
901
- height: 64px !important;
902
- }
903
- .has_btn_libang_head{
904
- height: 85px!important;
905
- }
906
- .has_btn_head{
907
- height: 60px!important;
908
- }
909
- .drawer-header {
910
- width: 100%;
911
- height: 50px;
912
- cursor: pointer;
913
- padding: 6px 20px;
914
- border-bottom: 1px solid #cccccc;
915
- .btn_position {
916
- position: absolute;
917
- top: -34px;
918
- left: 12px;
919
- }
920
-
921
- .header-btn {
922
- display: flex;
923
- align-items: center;
924
- justify-content: space-between;
925
-
926
- .header-right {
927
- display: flex;
928
- }
929
-
930
- .summaryBtn {
931
- flex: none;
932
- //width: 95px;
933
- height: 26px;
934
- padding: 0 8px;
935
- background: #ffffff;
936
- display: flex;
937
- align-items: center;
938
- justify-content: center;
939
- box-sizing: border-box;
940
- border: 1px solid #a1b9ff;
941
- border-radius: 15px;
942
- cursor: pointer;
943
- color: #366aff;
944
- margin-right: 10px;
945
- font-size: 14px;
946
-
947
- i {
948
- font-size: 14px;
949
- margin-right: 5px;
950
- }
951
- }
952
-
953
- .summaryActiveBtn {
954
- background: #366aff !important;
955
- color: #ffffff !important;
956
- }
957
-
958
- .chat {
959
- flex: none;
960
- height: 26px;
961
- padding: 0 8px;
962
- background: #ffffff;
963
- display: flex;
964
- align-items: center;
965
- justify-content: center;
966
- box-sizing: border-box;
967
- border: 1px solid #a1b9ff;
968
- border-radius: 15px 0px 15px 15px;
969
- cursor: pointer;
970
- color: #366aff;
971
- margin-right: 10px;
972
- font-size: 14px;
973
-
974
- i {
975
- font-size: 14px;
976
- margin-right: 5px;
977
- margin-top: 2px;
978
- }
979
- }
980
-
981
- .chat_active {
982
- background: #366aff !important;
983
- color: #FFFFFF !important;
984
- }
985
- }
986
-
987
- .header_title {
988
- font-size: 14px;
989
- height: 100%;
990
- .header_close {
991
- display: flex;
992
- align-items: center;
993
- justify-content: space-between;
994
- line-height: 26px;
995
- }
996
- .title_left {
997
- white-space: nowrap; /* 确保文本不会换行 */
998
- overflow: hidden; /* 隐藏超出容器的文本 */
999
- text-overflow: ellipsis; /* 当文本超出容器时显示省略号 */
1000
- margin-right: 8px;
1001
- text-align: left;
1002
- }
1003
- .top-header{
1004
- display: flex;
1005
- align-items: center;
1006
- justify-content: flex-end;
1007
- margin-bottom: 6px;
1008
- }
1009
- .header_floder {
1010
- display: flex;
1011
- align-items: center;
1012
- line-height: 26px;
1013
- text-align: left;
1014
- i {
1015
- margin: 0 5px;
1016
- color: #366aff;
1017
- }
1018
- }
1019
- .header_top {
1020
- height: 100%;
1021
- display: flex;
1022
- align-items: center;
1023
- justify-content: space-between;
1024
- }
1025
- }
1026
- }
1027
-
1028
- @media screen and (max-width: 767px) {
1029
-
1030
- /* 这里是针对移动设备的css样式设置 */
1031
- /deep/.el-drawer__body {
1032
- height: 100%;
1033
- }
1034
-
1035
- #drawer_content_pre {
1036
- overflow: auto;
1037
- height: calc(100% - 50px);
1038
- background: #FFF;
1039
- }
1040
-
1041
- .libang_content_pre {
1042
- height: calc(100% - 64px) !important;
1043
- }
1044
- }
1045
-
1046
- @media screen and (min-width: 768px) {
1047
-
1048
- /* 这里是针对pc设备的css样式设置 */
1049
- /deep/.el-drawer__body {
1050
- height: 100%;
1051
- }
1052
-
1053
- #drawer_content_pre {
1054
- overflow: auto;
1055
- height: calc(100% - 50px);
1056
- background: #FFF;
1057
- }
1058
-
1059
- .libang_content_pre {
1060
- height: calc(100% - 64px) !important;
1061
- }
1062
- }
1063
-
1064
- @media screen and (min-width: 1200px) {
1065
-
1066
- /* 这里是针对pc设备的css样式设置 */
1067
- .el-drawer__wrapper {
1068
- width: 55%;
1069
- left: calc(100vw - 55%);
1070
- right: 0;
1071
-
1072
- /deep/.pdf-preview-drawer {
1073
- width: 100% !important;
1074
- }
1075
- }
1076
-
1077
- /deep/.el-drawer__body {
1078
- height: 100%;
1079
- }
1080
-
1081
- #drawer_content_pre {
1082
- overflow: auto;
1083
- height: calc(100% - 50px);
1084
- background: #FFF;
1085
- }
1086
-
1087
- .libang_content_pre {
1088
- height: calc(100% - 64px) !important;
1089
- }
1090
- }
1091
- </style>
1092
- <style lang="less">
1093
- .pdf-preview-drawer {
1094
- overflow: visible !important;
1095
- }
1096
- .libang_content_pre {
1097
- .change_scale {
1098
- top: 64px !important;
1099
- }
1100
- .float_intelligentSummary {
1101
- top: 74px !important;
1102
- }
1103
- }
1104
- </style>
1
+
2
+ <!-- preview-pdf
3
+ 组件主要负责 知识项目中 文件的预览,携带定位信息参数 tagIds tagId 的会解析文件增加定位功能
4
+ 不携带定位信息的 也是走 kkview项目预览
5
+ 另外增加了在知识项目中预览当前文件的一些功能
6
+ -->
7
+ <template>
8
+ <el-drawer title="" :visible.sync="drawer" :with-header="false" :append-to-body="true" :destroy-on-close="true"
9
+ :modal="false" :direction="previewShowPopup ? 'btt' : 'rtl'" :size="previewShowPopup ? '90%' : '65%'"
10
+ custom-class="pdf-preview-drawer" v-if="drawer">
11
+ <div class="drawer-header" :class="isLiBang ? 'libang_head' : ''" v-if="!isPc">
12
+ <div class="header-btn btn_position">
13
+ <div class="onload_btn" v-if="isDownload" @click="downLoad">
14
+ {{ $t('dragonCommon.download') }}
15
+ </div>
16
+ <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun" v-if="isHasChat">
17
+ <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
18
+ <span>{{ $t('dragonCommon.smartSummary') }}</span>
19
+ </div>
20
+ <template v-if="isHasChat">
21
+ <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
22
+ <i class="iconfont guoran-wendapingjia"></i>
23
+ {{ $t('dragonCommon.chat') }}
24
+ </div>
25
+ <div class="chat chat_active" @click="previewToDialog(false)" v-else>
26
+ <i class="iconfont guoran-wendapingjia"></i>
27
+ {{ $t('dragonCommon.chat') }}
28
+ </div>
29
+ </template>
30
+ </div>
31
+ <div class="header_title">
32
+ <div class="header_close">
33
+ <span class="title_left">
34
+ {{ title ? title : $t('dragonCommon.viewDetails') }}
35
+ </span>
36
+ <section @click="close">
37
+ <i class="iconfont guoran-shanchu"></i>
38
+ </section>
39
+ </div>
40
+ <p v-if="folderName && isLiBang" class="header_floder" @click="clickFloder">
41
+ <i class="iconfont guoran-tongyichicun-wenjianjia-zhankaizhuangtai--folderOpen"></i>
42
+ {{ folderName }}
43
+ <i v-if="folderUrl" class="iconfont guoran-tongyichicun-dianjichakantuli"></i>
44
+ </p>
45
+ </div>
46
+ </div>
47
+ <div class="drawer-header" :class="isLiBang && folderName ? 'libang_head' : ''" v-else>
48
+ <div class="header_title">
49
+ <div :class="isLiBang && folderName ? 'header_close' : 'header_top'">
50
+ <span class="title_left">
51
+ {{ title ? title : $t('dragonCommon.viewDetails') }}
52
+ </span>
53
+ <div class="header-btn">
54
+ <div class="onload_btn" v-if="isDownload" @click="downLoad">
55
+ {{ $t('dragonCommon.download') }}
56
+ </div>
57
+ <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun"
58
+ v-if="isHasChat">
59
+ <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
60
+ <span>{{ $t('dragonCommon.smartSummary') }}</span>
61
+ </div>
62
+ <template v-if="isHasChat">
63
+ <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
64
+ <i class="iconfont guoran-wendapingjia"></i>
65
+ {{ $t('dragonCommon.chat') }}
66
+ </div>
67
+ <div class="chat chat_active" @click="previewToDialog(false)" v-else>
68
+ <i class="iconfont guoran-wendapingjia"></i>
69
+ {{ $t('dragonCommon.chat') }}
70
+ </div>
71
+ </template>
72
+ <section @click="close">
73
+ <i class="iconfont guoran-shanchu"></i>
74
+ </section>
75
+ </div>
76
+ </div>
77
+ <p v-if="folderName && isLiBang" class="header_floder" @click="clickFloder">
78
+ <i class="iconfont guoran-tongyichicun-wenjianjia-zhankaizhuangtai--folderOpen"></i>
79
+ {{ folderName }}
80
+ <i v-if="folderUrl" class="iconfont guoran-tongyichicun-dianjichakantuli"></i>
81
+ </p>
82
+ </div>
83
+ </div>
84
+ <div id="drawer_content_pre" :class="isLiBang && folderName ? 'libang_content_pre' : ''">
85
+ <intelligent-summary v-show="showSummary && isHasChat" :tagIds="tagIds" :knowledgeId="knowledgeId"
86
+ @closeSummary="closeSummary" @recommendQues="recommendQues"
87
+ @getSummarySuccess="getSummarySuccess"></intelligent-summary>
88
+ <div class="pdf_positon" :style="pdfStyle" v-if="tagIds && tagIds.length != 0 && drawer">
89
+ <pdfPosition :tagIds="tagIds" :isMessageRecord="isMessageRecord" :textWatermarkStr="textWatermarkStr">
90
+ </pdfPosition>
91
+ </div>
92
+ <template v-else>
93
+ <div v-if="fileType == 'VIDEO'" style="width: 100%;">
94
+ <video :src="url" controls width="100%;" height="98%"></video>
95
+ </div>
96
+ <div v-else-if="fileType == 'HTML'" style="width: 100%;">
97
+ <div class="preview_iframe_html" style="text-align:left" v-html="fileText"></div>
98
+ </div>
99
+ <template v-else-if="url.includes('https://www') || url.includes('http://www')">
100
+ <iframe class="preview_iframe" :src="url" width="100%" height="100%" scrolling="100%" frameborder="no"
101
+ border="0"></iframe>
102
+ </template>
103
+ <template v-else>
104
+ <iframe class="preview_iframe_kk" :src="previewUrl" style="border:none;"
105
+ :style="{ height: iframeHeight }"></iframe>
106
+ </template>
107
+ </template>
108
+ </div>
109
+ <div class="loading_img" v-show="loading">
110
+ <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
111
+ </div>
112
+ <div id="text">
113
+ {{ copy }}
114
+ </div>
115
+ </el-drawer>
116
+ </template>
117
+
118
+ <script>
119
+ import pdfPosition from './pdfPosition.vue'
120
+ import { zoomElement } from '../assets/js/hammer'
121
+ import IntelligentSummary from "./intelligentSummary";
122
+ import { isMobile } from "../assets/js/common";
123
+ import { Toast } from 'vant';
124
+ export default {
125
+ data () {
126
+ return {
127
+ previewShowPopup: false,
128
+ fileText: '',
129
+ fileType: "",
130
+ isPc: false,
131
+ drawer: false,
132
+ tagIds: [],
133
+ // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
134
+ loading: true,
135
+ previewKnowledgeId: "",
136
+ showSummary: true,
137
+ iframeHeight: "100%",
138
+ isDownload: false,
139
+ textWatermarkStr: "",
140
+ copy:''
141
+ }
142
+ },
143
+ mounted () {
144
+ this.$i18n.locale = sessionStorage.getItem("systemLanguage") || 'cn';
145
+ window.addEventListener('message', this.handleIframeMessage, false);
146
+ this.isPcFun();
147
+ },
148
+ props: {
149
+ url: {
150
+ type: String,
151
+ required: true,
152
+ },
153
+ officePreviewType: {
154
+ type: String,
155
+ default: ''
156
+ },
157
+ isMessageRecord: {
158
+ type: Boolean,
159
+ default: false,
160
+ },
161
+ sourceFileType: {
162
+ type: String,
163
+ default: '',
164
+ },
165
+ title: {
166
+ type: String,
167
+ default: ''
168
+ },
169
+ isHasChat: {
170
+ type: Boolean,
171
+ default: false
172
+ },
173
+ knowledgeId: {
174
+ type: String,
175
+ default: '',
176
+ },
177
+ previewOssPath: {
178
+ type: String,
179
+ default: '',
180
+ },
181
+ folderName: {
182
+ type: String,
183
+ default: '',
184
+ },
185
+ folderUrl: {
186
+ type: String,
187
+ default: '',
188
+ },
189
+ isLiBang: {
190
+ type: Boolean,
191
+ default: false
192
+ }},
193
+ components: {
194
+ IntelligentSummary,
195
+ pdfPosition
196
+ },
197
+ watch: {
198
+ drawer (value) {
199
+ if (value) {
200
+ this.$emit('open')
201
+ this.$nextTick(() => {
202
+ zoomElement(document.getElementById('drawer_content_pre'))
203
+ })
204
+ } else {
205
+ this.$emit('close')
206
+ }
207
+ },
208
+ showSummary: {
209
+ handler (val) {
210
+ // if (!val){
211
+ // this.$nextTick(() => {
212
+ // let preCon = document.querySelector('.pdf_view');
213
+ // if (preCon){
214
+ // preCon.style.height = 'calc(100% - ' + 50 + 'px)'
215
+ // }
216
+ // })
217
+ // } else {
218
+ // this.getSummarySuccess();
219
+ // }
220
+ if (val) {
221
+ this.getSummarySuccess();
222
+ }
223
+ }
224
+ },
225
+ knowledgeId: {
226
+ handler (val) {
227
+ if (val) {
228
+ this.getTextWatermark();
229
+ }
230
+ }
231
+ }
232
+ },
233
+ computed: {
234
+ pdfStyle () {
235
+ return {
236
+ paddingTop: this.isPc ? '30px' : '0', // 30px 是 加上外层的 20 流出 50的上边距展示 放大缩小操作栏
237
+ paddingBottom: this.tagIds > 1 ? '60px' : '0',
238
+ height: '100%'
239
+ }
240
+ },
241
+ previewUrl () {
242
+ console.debug('VUE_APP_ENV', process.env.VUE_APP_ENV)
243
+ let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
244
+ // if(this.url != '') {
245
+ // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
246
+ // url += btoa(encodeURIComponent(this.url))
247
+ // } else {
248
+ // url += btoa(this.url)
249
+ // }
250
+ // }
251
+ url = url + this.url
252
+ if (this.sourceFileType == '.ppt' || this.sourceFileType == '.pptx' || this.sourceFileType == '.pdf') {
253
+ url += '&officePreviewType=pdf'
254
+ }
255
+ console.log('textWatermarkStr 216', this.textWatermarkStr)
256
+ if (this.textWatermarkStr) {
257
+ url += '&textWatermarkValue=' + this.textWatermarkStr
258
+ }
259
+ return url
260
+ },
261
+ // fileType() {
262
+ // const fileType = this.url.substring(this.url.lastIndexOf('.'));
263
+ // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
264
+ // return 'VIDEO'
265
+ // } else {
266
+ // return 'OTHER'
267
+ // }
268
+
269
+ // }
270
+ },
271
+ methods: {
272
+ close () {
273
+ setTimeout(() => {
274
+ this.previewShowPopup = false;
275
+ this.fileType = ''
276
+ }, 300)
277
+ this.drawer = false;
278
+ this.showSummary = false;
279
+ },
280
+ loadIframe () {
281
+
282
+ if (this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0)) {
283
+ this.loading = false
284
+ } else {
285
+ let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
286
+ if (iframe) {
287
+ iframe.onload = () => {
288
+ this.loading = false;
289
+ document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
290
+ }
291
+ }
292
+ // let time = setInterval(() =>{
293
+ //
294
+ // if(iframe) {
295
+ // this.loading = false
296
+ // clearInterval(time)
297
+ // }
298
+ // }, 500)
299
+ }
300
+ },
301
+ getBolb () {
302
+ this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false', {
303
+ fileInOssPath: this.url,
304
+ templateId: ''
305
+ }).then(res => {
306
+ if (res.data.code == 0) {
307
+ this.fileText = res.data.data
308
+ this.loading = false
309
+ }
310
+ })
311
+ },
312
+ previewToDialog (flag) {
313
+ this.$emit('previewToDialog', flag)
314
+ },
315
+ closeSummary () {
316
+ this.showSummary = false;
317
+ },
318
+ recommendQues (item, knowledgeId) {
319
+ console.log('recommendQues', item, knowledgeId);
320
+ this.$emit('recommendQues', item, knowledgeId)
321
+ },
322
+ handleIframeMessage (res) {
323
+ console.log('handleIframeMessage', res)
324
+ if (res.data.type == 'getViewerHeight') {
325
+ let iframeHeight = this.iframeHeight.replace('px', '')
326
+ if (res.data.data && iframeHeight != (res.data.data + 50)) {
327
+ this.iframeHeight = res.data.data + 50 + 'px'
328
+ }
329
+ }
330
+ },
331
+ summaryFun () {
332
+ this.showSummary = !this.showSummary;
333
+ if (this.showSummary) {
334
+ document.getElementById('drawer_content_pre').scrollTop = 0;
335
+ }
336
+ },
337
+ getSummarySuccess () {
338
+ this.$nextTick(() => {
339
+ // if (this.tagIds.length > 0){
340
+ // let intelligentSummary = document.getElementById('intelligentSummary');
341
+ // let preCon = document.querySelector('.pdf_view')
342
+ // if (intelligentSummary){
343
+ // let height = intelligentSummary.offsetHeight + (this.isPc ? 100 : 50 );
344
+ // if (preCon){
345
+ // preCon.style.height = 'calc(100% - ' + height + 'px)'
346
+ // }
347
+ // console.log('height',height,preCon)
348
+ // }
349
+ // }
350
+ // let intelligentSummary = document.getElementById('intelligentSummary');
351
+ // let height = intelligentSummary.offsetHeight
352
+ // this.pdfStyle.height = 'calc(100% - ' + height + 'px)'
353
+ })
354
+ },
355
+ getTextWatermark () {
356
+ let url = '/knowledge-api/open/knowledge/getPermissionInfo';
357
+ let obj = {
358
+ "knowledgeId": this.knowledgeId,
359
+ "userId": sessionStorage.getItem('_currentUserId'),
360
+ "mainId": sessionStorage.getItem('_mainId'),
361
+ "corpId": sessionStorage.getItem('_corpid')
362
+ }
363
+ this.$http.post(url, obj).then(res => {
364
+ console.log('getTextWatermark', res.data.data)
365
+ if (res.data.data) {
366
+ this.textWatermarkStr = res.data.data.textWatermarkStr;
367
+ this.isDownload = res.data.data.showDownloadBtn;
368
+ }
369
+ })
370
+ },
371
+ downLoad () {
372
+ let url = this.previewOssPath
373
+ if (decodeURIComponent(url) != url) {
374
+ url = decodeURIComponent(url)
375
+ }
376
+ const fileType = url.substring(url.lastIndexOf('.'));
377
+ this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
378
+ headers: {
379
+ "Content-Type": "application/json",
380
+ }
381
+ }).then(res => {
382
+ console.log('downLoad 341', res)
383
+ if (res.data || res.bodyText) {
384
+ if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
385
+ this.copy = res.data
386
+ if (isMobile()) {
387
+ setTimeout(() =>{
388
+ const range = document.createRange();
389
+ range.selectNode(document.getElementById('text'));
390
+ const selection = window.getSelection();
391
+ //移除之前选中内容
392
+ if (selection.rangeCount > 0) selection.removeAllRanges();
393
+ selection.addRange(range);
394
+ document.execCommand('copy');
395
+ selection.removeAllRanges()
396
+ Toast(this.$t('dragonCommon.Safaridownload'));
397
+ this.close()
398
+ },100)
399
+ } else {
400
+ let a = document.createElement('a')
401
+ a.href = res.data
402
+ a.download = (this.title) + fileType
403
+ a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
404
+ }
405
+ return
406
+ } else {
407
+ // setTimeout(() =>{
408
+ // window.open(res.data,'下载', 'noopener')
409
+ // }, 2000)
410
+ // window.open(res.data,'下载', 'noopener')
411
+ if (isMobile()) {
412
+ const iframe = document.createElement("iframe");
413
+ iframe.setAttribute("hidden", "hidden");
414
+ iframe.onload = () => {
415
+ if (iframe) {
416
+ console.log("iframe onload....")
417
+ iframe.setAttribute('src', 'about:blank');
418
+ }
419
+ };
420
+ document.body.insertBefore(iframe, null);
421
+ iframe.setAttribute("src", res.data);
422
+ } else {
423
+ let a = document.createElement('a')
424
+ a.href = res.data
425
+ a.download = (this.title) + fileType
426
+ a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
427
+ }
428
+ this.close()
429
+ }
430
+ }
431
+ })
432
+ },
433
+ isPcFun () {
434
+ if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
435
+ this.isPc = false
436
+ } else {
437
+ this.isPc = true
438
+ }
439
+ },
440
+ clickFloder() {
441
+ this.$emit('previewClickFloder')
442
+ }},
443
+ beforeDestroy () {
444
+ window.removeEventListener('message', this.handleIframeMessage);
445
+ }
446
+ }
447
+ </script>
448
+
449
+ <style lang="less" scoped>
450
+ #drawer_content_pre {
451
+ padding: 20px;
452
+ scroll-behavior: smooth;
453
+
454
+ .mobile_onload_btn {
455
+ position: absolute;
456
+ right: 0;
457
+ bottom: 10%;
458
+ width: 20px;
459
+ height: 60px;
460
+ display: flex;
461
+ align-items: center;
462
+ justify-content: center;
463
+ cursor: pointer;
464
+ border-top-left-radius: 10px;
465
+ border-bottom-left-radius: 10px;
466
+ color: #366aff;
467
+ background: #ffffff;
468
+ border: 1px solid #a1b9ff;
469
+ font-size: 12px;
470
+ border-right: none;
471
+ text-align: center;
472
+ }
473
+
474
+ .pdf_positon {
475
+ width: 100%;
476
+ box-sizing: border-box;
477
+ }
478
+ }
479
+
480
+ .onload_btn {
481
+ width: 76px;
482
+ height: 26px;
483
+ display: flex;
484
+ align-items: center;
485
+ justify-content: center;
486
+ cursor: pointer;
487
+ margin-right: 10px;
488
+ border-radius: 15px;
489
+ color: #366aff;
490
+ background: #ffffff;
491
+ border: 1px solid #a1b9ff;
492
+ box-sizing: border-box;
493
+ }
494
+
495
+ .preview_iframe {
496
+ width: 100%;
497
+ height: 100%;
498
+ box-sizing: border-box;
499
+ background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
500
+ background-position: center;
501
+ background-size: 50px;
502
+ background-repeat: no-repeat;
503
+ }
504
+
505
+ .preview_iframe_kk {
506
+ width: 100%;
507
+ height: 100%;
508
+ }
509
+
510
+ .preview_iframe_html {
511
+ width: 100%;
512
+ height: 100%;
513
+ overflow-y: scroll;
514
+ text-align: left;
515
+ box-sizing: border-box;
516
+ padding: 16px;
517
+
518
+ /deep/.lake-content {
519
+ margin-left: 10px;
520
+ }
521
+
522
+ /deep/a:link {
523
+ color: #0000ee !important;
524
+ }
525
+
526
+ /deep/a:visited {
527
+ color: #0000ee !important;
528
+ }
529
+
530
+ /deep/a:hover {
531
+ color: #0000ee !important;
532
+ }
533
+
534
+ /deep/a:active {
535
+ color: #0000ee !important;
536
+ }
537
+
538
+ /deep/li:not(.rich-text-li),
539
+ ol:not(.list-paddingleft-2),
540
+ ul:not(.list-paddingleft-2) {
541
+ list-style-type: auto !important;
542
+ }
543
+
544
+ /deep/img {
545
+ width: 100%;
546
+ }
547
+
548
+ /deep/.ne-table {
549
+ width: 100% !important;
550
+ }
551
+ }
552
+
553
+ .footer {
554
+ width: calc(100% - 40px);
555
+ height: 50px;
556
+ display: flex;
557
+ align-items: center;
558
+ justify-content: space-between;
559
+ cursor: pointer;
560
+ padding: 0 20px;
561
+ border-bottom: 1px solid #cccccc;
562
+ }
563
+
564
+ .loading_img {
565
+ display: flex;
566
+ align-items: center;
567
+ justify-content: center;
568
+ width: 100%;
569
+ height: 100%;
570
+ position: absolute;
571
+ top: 0;
572
+ left: 0;
573
+ background: #FFF;
574
+
575
+ img {
576
+ width: 50px;
577
+ height: 50px;
578
+ }
579
+ }
580
+
581
+ .libang_head {
582
+ height: 64px !important;
583
+ }
584
+
585
+ .drawer-header {
586
+ width: 100%;
587
+ height: 50px;
588
+ cursor: pointer;
589
+ padding: 6px 20px;
590
+ border-bottom: 1px solid #cccccc;
591
+ .btn_position {
592
+ position: absolute;
593
+ top: -34px;
594
+ left: 12px;
595
+ }
596
+
597
+ .header-btn {
598
+ display: flex;
599
+ align-items: center;
600
+ justify-content: space-between;
601
+
602
+ .header-right {
603
+ display: flex;
604
+ }
605
+ .summaryBtn {
606
+ flex: none;
607
+ //width: 95px;
608
+ height: 26px;
609
+ padding: 0 8px;
610
+ background: #ffffff;
611
+ display: flex;
612
+ align-items: center;
613
+ justify-content: center;
614
+ box-sizing: border-box;
615
+ border: 1px solid #a1b9ff;
616
+ border-radius: 15px;
617
+ cursor: pointer;
618
+ color: #366aff;
619
+ margin-right: 10px;
620
+ font-size: 14px;
621
+
622
+ i {
623
+ font-size: 14px;
624
+ margin-right: 5px;
625
+ }
626
+ }
627
+
628
+ .summaryActiveBtn {
629
+ background: #366aff !important;
630
+ color: #ffffff !important;
631
+ }
632
+
633
+ .chat {
634
+ flex: none;
635
+ height: 26px;
636
+ padding: 0 8px;
637
+ background: #ffffff;
638
+ display: flex;
639
+ align-items: center;
640
+ justify-content: center;
641
+ box-sizing: border-box;
642
+ border: 1px solid #a1b9ff;
643
+ border-radius: 15px 0px 15px 15px;
644
+ cursor: pointer;
645
+ color: #366aff;
646
+ margin-right: 10px;
647
+ font-size: 14px;
648
+
649
+ i {
650
+ font-size: 14px;
651
+ margin-right: 5px;
652
+ margin-top: 2px;
653
+ }
654
+ }
655
+
656
+ .chat_active {
657
+ background: #366aff !important;
658
+ color: #FFFFFF !important;
659
+ }
660
+ }
661
+
662
+ .header_title {
663
+ font-size: 14px;
664
+ height: 100%;
665
+ .header_close {
666
+ display: flex;
667
+ align-items: center;
668
+ justify-content: space-between;
669
+ line-height: 26px;
670
+ .title_left {
671
+ white-space: nowrap; /* 确保文本不会换行 */
672
+ overflow: hidden; /* 隐藏超出容器的文本 */
673
+ text-overflow: ellipsis; /* 当文本超出容器时显示省略号 */
674
+ margin-right: 8px;
675
+ }
676
+ }
677
+ .header_floder {
678
+ display: flex;
679
+ align-items: center;
680
+ line-height: 26px;
681
+ i {
682
+ margin: 0 5px;
683
+ color: #366aff;
684
+ }
685
+ }
686
+ .header_top {
687
+ height: 100%;
688
+ display: flex;
689
+ align-items: center;
690
+ justify-content: space-between;
691
+ }
692
+ }
693
+ }
694
+
695
+ @media screen and (max-width: 767px) {
696
+
697
+ /* 这里是针对移动设备的css样式设置 */
698
+ /deep/.el-drawer__body {
699
+ height: 100%;
700
+ }
701
+
702
+ #drawer_content_pre {
703
+ overflow: auto;
704
+ height: calc(100% - 50px);
705
+ background: #FFF;
706
+ background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
707
+ background-position: center;
708
+ background-size: 50px;
709
+ background-repeat: no-repeat;
710
+ }
711
+
712
+ .libang_content_pre {
713
+ height: calc(100% - 64px) !important;
714
+ }
715
+ }
716
+
717
+ @media screen and (min-width: 768px) {
718
+
719
+ /* 这里是针对pc设备的css样式设置 */
720
+ /deep/.el-drawer__body {
721
+ height: 100%;
722
+ }
723
+
724
+ #drawer_content_pre {
725
+ overflow: auto;
726
+ height: calc(100% - 50px);
727
+ background: #FFF;
728
+ }
729
+
730
+ .libang_content_pre {
731
+ height: calc(100% - 64px) !important;
732
+ }
733
+ }
734
+
735
+ @media screen and (min-width: 1200px) {
736
+
737
+ /* 这里是针对pc设备的css样式设置 */
738
+ .el-drawer__wrapper {
739
+ width: 55%;
740
+ left: calc(100vw - 55%);
741
+ right: 0;
742
+
743
+ /deep/.pdf-preview-drawer {
744
+ width: 100% !important;
745
+ }
746
+ }
747
+
748
+ /deep/.el-drawer__body {
749
+ height: 100%;
750
+ }
751
+
752
+ #drawer_content_pre {
753
+ overflow: auto;
754
+ height: calc(100% - 50px);
755
+ background: #FFF;
756
+ }
757
+
758
+ .libang_content_pre {
759
+ height: calc(100% - 64px) !important;
760
+ }
761
+ }
762
+ </style>
763
+ <style lang="less">
764
+ .pdf-preview-drawer {
765
+ overflow: visible !important;
766
+ }
767
+ .libang_content_pre {
768
+ .change_scale {
769
+ top: 64px !important;
770
+ }
771
+ .float_intelligentSummary {
772
+ top: 74px !important;
773
+ }
774
+ }
775
+ </style>