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