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