askbot-dragon 1.6.57-beta → 1.6.59-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 (84) 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 +54 -54
  5. package/public/index.html +72 -72
  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 +92 -92
  11. package/src/assets/js/Base64Util.js +22 -22
  12. package/src/assets/js/common.js +252 -250
  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 +466 -466
  22. package/src/components/AnswerDocknowledge.vue +701 -693
  23. package/src/components/AnswerVoice.vue +285 -285
  24. package/src/components/AskIFrame.vue +15 -15
  25. package/src/components/ConversationContainer.vue +5130 -5317
  26. package/src/components/FileType.vue +86 -86
  27. package/src/components/Message.vue +27 -27
  28. package/src/components/MyEditor.vue +350 -350
  29. package/src/components/actionSatisfaction.vue +107 -107
  30. package/src/components/actionSendToBot.vue +62 -62
  31. package/src/components/answerDissatisfaction.vue +62 -62
  32. package/src/components/answerRadio.vue +186 -186
  33. package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
  34. package/src/components/ask-components/Msgloading.vue +37 -37
  35. package/src/components/ask-components/SatisfactionV2.vue +15 -15
  36. package/src/components/askVideo.vue +162 -162
  37. package/src/components/assetDetails.vue +378 -378
  38. package/src/components/assetMessage.vue +228 -228
  39. package/src/components/associationIntention.vue +355 -355
  40. package/src/components/attachmentPreview.vue +90 -90
  41. package/src/components/botActionSatisfactor.vue +68 -68
  42. package/src/components/chatContent.vue +513 -513
  43. package/src/components/feedBack.vue +136 -136
  44. package/src/components/fielListView.vue +351 -351
  45. package/src/components/file/AliyunOssComponents.vue +108 -108
  46. package/src/components/formTemplate.vue +3572 -3572
  47. package/src/components/intelligentSummary.vue +209 -209
  48. package/src/components/kkview.vue +1138 -1138
  49. package/src/components/loadingProcess.vue +164 -164
  50. package/src/components/message/ActionAlertIframe.vue +112 -112
  51. package/src/components/message/ShopMessage.vue +164 -164
  52. package/src/components/message/TextMessage.vue +924 -924
  53. package/src/components/message/TicketMessage.vue +201 -201
  54. package/src/components/message/swiper/index.js +4 -4
  55. package/src/components/message/swiper/ticketSwiper.vue +503 -503
  56. package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
  57. package/src/components/msgLoading.vue +231 -231
  58. package/src/components/myPopup.vue +70 -70
  59. package/src/components/newPdfPosition.vue +877 -877
  60. package/src/components/pdfPosition.vue +1509 -1509
  61. package/src/components/popup.vue +227 -227
  62. package/src/components/previewDoc.vue +247 -247
  63. package/src/components/previewPdf.vue +653 -599
  64. package/src/components/receiverMessagePlatform.vue +65 -65
  65. package/src/components/recommend.vue +80 -80
  66. package/src/components/selector/hOption.vue +20 -20
  67. package/src/components/selector/hSelector.vue +199 -199
  68. package/src/components/selector/hWrapper.vue +216 -216
  69. package/src/components/senderMessagePlatform.vue +50 -50
  70. package/src/components/source/BotMessage.vue +24 -24
  71. package/src/components/source/CustomMessage.vue +24 -24
  72. package/src/components/test.vue +260 -260
  73. package/src/components/tree.vue +294 -294
  74. package/src/components/utils/AliyunIssUtil.js +81 -81
  75. package/src/components/utils/ckeditor.js +174 -174
  76. package/src/components/utils/format_date.js +25 -25
  77. package/src/components/utils/index.js +6 -6
  78. package/src/components/utils/math_utils.js +29 -29
  79. package/src/components/voiceComponent.vue +119 -119
  80. package/src/components/welcomeKnowledgeFile.vue +332 -332
  81. package/src/components/welcomeLlmCard.vue +140 -140
  82. package/src/components/welcomeSuggest.vue +97 -97
  83. package/src/main.js +57 -57
  84. package/vue.config.js +54 -54
@@ -1,600 +1,654 @@
1
-
2
- <!-- preview-pdf
3
- 组件主要负责 知识项目中 文件的预览,携带定位信息参数 tagIds tagId 的会解析文件增加定位功能
4
- 不携带定位信息的 也是走 kkview项目预览
5
- 另外增加了在知识项目中预览当前文件的一些功能
6
- -->
7
- <template>
8
- <!-- <van-popup v-model="previewShowPopup" position="bottom" :style="{ height: '90%', background:'#FFFFFF'}" v-if="previewShowPopup">
9
- <div class="footer">
10
- <span>查看详情</span>
11
- <section @click="close">
12
- <i class="iconfont guoran-shanchu"></i>
13
- </section>
14
- </div>
15
- <template v-if="tagIds && tagIds.length != 0 && previewShowPopup">
16
- <pdfPosition :tagIds="tagIds" ></pdfPosition>
17
- </template>
18
- <template v-else>
19
- <div v-if="fileType == 'VIDEO'" style="width: 100%;height: calc(100% - 60px)">
20
- <video :src="url" controls width="100%;" height="98%"></video>
21
- </div>
22
- <div v-else-if="fileType == 'HTML'" style="width: 100%;height: calc(100% - 60px)">
23
- <div class="preview_iframe_html" style="text-algin:left" v-html="fileText"></div>
24
- </div>
25
- <template v-else-if="url.includes('https://www') || url.includes('http://www')">
26
- <iframe class="preview_iframe"
27
- :src="url"
28
- width="100%"
29
- height="100%"
30
- scrolling="100%"
31
- frameborder="no"
32
- border="0"></iframe>
33
- </template>
34
- <template v-else>
35
- <iframe class="preview_iframe" :src="previewUrl" style="border:none;"></iframe>
36
- </template>
37
- </template>
38
- <div class="loading_img" v-show="loading">
39
- <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
40
- </div>
41
- </van-popup> -->
42
- <el-drawer
43
- title="我是标题"
44
- :visible.sync="drawer"
45
- :with-header="false"
46
- :append-to-body="true"
47
- :destroy-on-close="true"
48
- :model="false"
49
- :direction="previewShowPopup ? 'btt' : 'rtl'"
50
- :size="previewShowPopup ? '90%' : '65%'"
51
- custom-class="pdf-preview-drawer"
52
- v-if="drawer"
53
- >
54
- <!-- v-else-if="drawer" -->
55
- <div class="drawer-footer">
56
- <span>{{title ? title : "查看详情"}}</span>
57
- <div class="header-right">
58
- <div class="onload_btn" v-if="isDownload" @click="downLoad">
59
- 下载
60
- </div>
61
- <div class="summaryBtn"
62
- :class="showSummary ? 'summaryActiveBtn' : ''"
63
- @click="summaryFun"
64
- >
65
- <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
66
- <span>智能摘要</span>
67
- </div>
68
- <template v-if="isHasChat">
69
- <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
70
- <i class="iconfont guoran-wendapingjia"></i>
71
- 聊一聊
72
- </div>
73
- <div class="chat chat_active" @click="previewToDialog(false)" v-else>
74
- <i class="iconfont guoran-wendapingjia"></i>
75
- 聊一聊
76
- </div>
77
- </template>
78
- <section @click="close">
79
- <i class="iconfont guoran-shanchu"></i>
80
- </section>
81
- </div>
82
- </div>
83
- <div id="drawer_content_pre">
84
- <intelligent-summary
85
- v-show="showSummary"
86
- :knowledgeId="knowledgeId"
87
- @closeSummary="closeSummary"
88
- @recommendQues="recommendQues"
89
- @getSummarySuccess="getSummarySuccess"
90
- :style="{marginTop:tagIds && tagIds.length != 0 ? '50px' : ''}"
91
- ></intelligent-summary>
92
- <template v-if="tagIds && tagIds.length != 0 && drawer">
93
- <pdfPosition :tagIds="tagIds" :isMessageRecord="isMessageRecord" :fileName="fileName" :textWatermarkStr="textWatermarkStr" ref="pdfPosition"></pdfPosition>
94
- </template>
95
- <template v-else>
96
- <div v-if="fileType == 'VIDEO'" style="width: 100%;">
97
- <video :src="url" controls width="100%;" height="98%"></video>
98
- </div>
99
- <div v-else-if="fileType == 'HTML'" style="width: 100%;">
100
- <div class="preview_iframe_html" style="text-algin:left" v-html="fileText"></div>
101
- </div>
102
- <template v-else-if="url.includes('https://www') || url.includes('http://www')">
103
- <iframe class="preview_iframe"
104
- :src="url"
105
- width="100%"
106
- height="100%"
107
- scrolling="100%"
108
- frameborder="no"
109
- border="0"></iframe>
110
- </template>
111
- <template v-else>
112
- <iframe class="preview_iframe_kk" :src="previewUrl" style="border:none;" :style="{height: iframeHeight}"></iframe>
113
- </template>
114
- </template>
115
- </div>
116
- <div class="loading_img" v-show="loading">
117
- <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
118
- </div>
119
- </el-drawer>
120
- </template>
121
-
122
- <script>
123
- import pdfPosition from './pdfPosition.vue'
124
- import { zoomElement } from '../assets/js/hammer'
125
- import IntelligentSummary from "./intelligentSummary";
126
- import { isMobile } from "../assets/js/common";
127
- import { Toast } from 'vant';
128
- export default {
129
- data () {
130
- return {
131
- previewShowPopup: false,
132
- fileText:'',
133
- fileType:"",
134
- isPc:true,
135
- drawer:false,
136
- tagIds: [],
137
- // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
138
- loading:true,
139
- fileName:'',
140
- previewKnowledgeId:"",
141
- showSummary:true,
142
- iframeHeight:"100%",
143
- isDownload:false,
144
- textWatermarkStr:""
145
- }
146
- },
147
- mounted() {
148
- window.addEventListener('message',this.handleIframeMessage,false);
149
- },
150
- props:{
151
- url:{
152
- type: String,
153
- required: true,
154
- },
155
- officePreviewType:{
156
- type: String,
157
- default: ''
158
- },
159
- isMessageRecord:{
160
- type: Boolean,
161
- default:false,
162
- },
163
- sourceFileType:{
164
- type: String,
165
- default: '',
166
- },
167
- title: {
168
- type: String,
169
- default: ''
170
- },
171
- isHasChat:{
172
- type:Boolean,
173
- default:false
174
- },
175
- knowledgeId:{
176
- type: String,
177
- default: '',
178
- },
179
- previewOssPath:{
180
- type: String,
181
- default: '',
182
- }
183
- },
184
- components:{
185
- IntelligentSummary,
186
- pdfPosition
187
- },
188
- watch:{
189
- drawer(value) {
190
- if(value) {
191
- this.$nextTick(() =>{
192
- if (this.tagIds && this.tagIds.length != 0){
193
- zoomElement(document.getElementById('pdf_container_view'))
194
- }
195
- })
196
- }
197
- setTimeout(() => {
198
- let previewIframe = document.getElementsByClassName('preview_iframe')
199
- Array.from(previewIframe).forEach(item =>{
200
- item.onload = () =>{
201
- console.debug('previewIframe 106',previewIframe,this.drawer)
202
- item.style.backgroundImage = 'none'
203
- }
204
- })
205
- })
206
- },
207
- showSummary:{
208
- handler(val){
209
- if (!val){
210
- this.$nextTick(() => {
211
- let preCon = document.querySelector('.pdf_view');
212
- if (preCon){
213
- preCon.style.height = 'calc(100% - ' + 50 + 'px)'
214
- }
215
- })
216
- } else {
217
- this.getSummarySuccess();
218
- }
219
- }
220
- },
221
- knowledgeId:{
222
- handler(val){
223
- console.log('knowledgeId',val)
224
- if (val){
225
- this.getTextWatermark();
226
- }
227
- }
228
- }
229
- },
230
- computed:{
231
- previewUrl() {
232
- console.debug('VUE_APP_ENV',process.env.VUE_APP_ENV)
233
- let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
234
- // if(this.url != '') {
235
- // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
236
- // url += btoa(encodeURIComponent(this.url))
237
- // } else {
238
- // url += btoa(this.url)
239
- // }
240
- // }
241
- url = url + this.url
242
- url += '&officePreviewType=pdf'
243
- if(this.watermark) {
244
- url = this.watermark.textWatermarkValue ? (url += '&textWatermarkValue=' + this.watermark.textWatermarkValue) : url
245
- url = this.watermark.visitorWatermarkValue ? (url += '&visitorWatermarkValue=' + this.watermark.visitorWatermarkValue) : url
246
- }
247
- console.log('textWatermarkStr 216',this.textWatermarkStr)
248
- if (this.textWatermarkStr){
249
- url += '&textWatermarkValue=' + this.textWatermarkStr
250
- }
251
- return url
252
- },
253
- // fileType() {
254
- // const fileType = this.url.substring(this.url.lastIndexOf('.'));
255
- // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
256
- // return 'VIDEO'
257
- // } else {
258
- // return 'OTHER'
259
- // }
260
-
261
- // }
262
- },
263
- methods :{
264
- close() {
265
- setTimeout(() =>{
266
- this.previewShowPopup = false;
267
- this.fileType = ''
268
- }, 300)
269
- this.drawer = false;
270
- this.showSummary = false;
271
- },
272
- loadIframe() {
273
-
274
- if(this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0)) {
275
- this.loading = false
276
- } else {
277
- let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
278
- if (iframe){
279
- iframe.onload = () => {
280
- this.loading = false;
281
- document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
282
- }
283
- }
284
- // let time = setInterval(() =>{
285
- //
286
- // if(iframe) {
287
- // this.loading = false
288
- // clearInterval(time)
289
- // }
290
- // }, 500)
291
- }
292
- },
293
- getBolb() {
294
- this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false',{
295
- fileInOssPath: this.url,
296
- templateId: ''
297
- }).then(res =>{
298
- if (res.data.code == 0) {
299
- this.fileText = res.data.data
300
- this.loading = false
301
- }
302
- })
303
- },
304
- previewToDialog(flag){
305
- this.$emit('previewToDialog',flag)
306
- },
307
- closeSummary(){
308
- this.showSummary = false;
309
- },
310
- recommendQues(item,knowledgeId){
311
- console.log('recommendQues',item,knowledgeId);
312
- this.$emit('recommendQues',item,knowledgeId)
313
- },
314
- handleIframeMessage(res){
315
- console.log('handleIframeMessage',res)
316
- if (res.data.type == 'getViewerHeight'){
317
- let iframeHeight = this.iframeHeight.replace('px','')
318
- if (res.data.data && iframeHeight != (res.data.data + 50)){
319
- this.iframeHeight = res.data.data + 50 + 'px'
320
- }
321
- }
322
- },
323
- summaryFun(){
324
- this.showSummary = !this.showSummary;
325
- if (this.showSummary){
326
- document.getElementById('drawer_content_pre').scrollTop = 0;
327
- }
328
- },
329
- getSummarySuccess(){
330
- this.$nextTick(() => {
331
- if (this.tagIds.length > 0){
332
- let intelligentSummary = document.getElementById('intelligentSummary');
333
- let preCon = document.querySelector('.pdf_view')
334
- console.log('intelligentSummary',preCon,intelligentSummary)
335
- if (intelligentSummary){
336
- let height = intelligentSummary.offsetHeight + 100;
337
- if (preCon){
338
- preCon.style.height = 'calc(100% - ' + height + 'px)'
339
- }
340
- console.log('height',height,preCon)
341
- }
342
- }
343
- })
344
- },
345
- getTextWatermark(){
346
- let url = '/knowledge-api/open/knowledge/getPermissionInfo';
347
- let obj = {
348
- "knowledgeId":this.knowledgeId,
349
- "userId":sessionStorage.getItem('loginUserId')
350
- }
351
- this.$http.post(url,obj).then(res => {
352
- console.log('getTextWatermark',res.data.data)
353
- if (res.data.data){
354
- this.textWatermarkStr = res.data.data.textWatermarkStr;
355
- this.isDownload = res.data.data.showDownloadBtn;
356
- }
357
- })
358
- },
359
- downLoad () {
360
- let url = this.previewOssPath
361
- if (decodeURIComponent(url) != url) {
362
- url = decodeURIComponent(url)
363
- }
364
- const fileType = url.substring(url.lastIndexOf('.'));
365
- this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
366
- headers:{
367
- "Content-Type": "application/json",
368
- }
369
- }).then(res => {
370
- console.log('downLoad 341',res)
371
- if (res.data) {
372
- if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
373
- if(isMobile()) {
374
- setTimeout(() =>{
375
- const range = document.createRange();
376
- range.selectNode(document.getElementById('text'));
377
- const selection = window.getSelection();
378
- //移除之前选中内容
379
- if (selection.rangeCount > 0) selection.removeAllRanges();
380
- selection.addRange(range);
381
- document.execCommand('copy');
382
- selection.removeAllRanges()
383
- Toast('下载地址已复制,请前往Safari浏览器访问下载');
384
- this.close()
385
- },100)
386
- } else {
387
- navigator.clipboard.writeText(res.data)
388
- this.$message.success({
389
- message:'下载地址已复制,请前往Safari浏览器访问下载',
390
- })
391
- }
392
- return
393
- } else {
394
- // setTimeout(() =>{
395
- // window.open(res.data,'下载', 'noopener')
396
- // }, 2000)
397
- // window.open(res.data,'下载', 'noopener')
398
- if(isMobile()) {
399
- const iframe = document.createElement("iframe");
400
- iframe.setAttribute("hidden", "hidden");
401
- iframe.onload = () => {
402
- if (iframe) {
403
- console.log("iframe onload....")
404
- iframe.setAttribute('src', 'about:blank');
405
- }
406
- };
407
- document.body.insertBefore(iframe, null);
408
- iframe.setAttribute("src", res.data);
409
- } else {
410
- let a = document.createElement('a')
411
- a.href = res.data
412
- a.download = (this.title) + fileType
413
- a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
414
- }
415
- this.close()
416
- }
417
- }
418
- })
419
- }
420
- },
421
- beforeDestroy() {
422
- window.removeEventListener('message', this.handleIframeMessage);
423
- }
424
- }
425
- </script>
426
-
427
- <style lang="less" scoped>
428
- #drawer_content_pre{
429
- padding: 20px;
430
- scroll-behavior: smooth;
431
- }
432
- .onload_btn {
433
- width: 80px;
434
- height: 26px;
435
- display: flex;
436
- align-items: center;
437
- justify-content: center;
438
- cursor: pointer;
439
- margin-right: 10px;
440
- border-radius: 15px;
441
- color: #ffffff;
442
- background-color: #366aff;
443
- }
444
- .preview_iframe {
445
- width: 100%;
446
- height: 100%;
447
- box-sizing: border-box;
448
- background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
449
- background-position: center;
450
- background-size: 50px;
451
- background-repeat: no-repeat;
452
- }
453
- .preview_iframe_kk{
454
- width: 100%;
455
- height: 100%;
456
- }
457
- .preview_iframe_html{
458
- width: 100%;
459
- height: 100%;
460
- overflow-y: scroll;
461
- text-align: left;
462
- box-sizing: border-box;
463
- padding: 16px;
464
- /deep/.lake-content{
465
- margin-left: 10px;
466
- }
467
- /deep/a:link {
468
- color: #0000ee!important;
469
- }
470
- /deep/a:visited {
471
- color: #0000ee!important;
472
- }
473
- /deep/a:hover {
474
- color: #0000ee!important;
475
- }
476
- /deep/a:active {
477
- color: #0000ee!important;
478
- }
479
- /deep/li:not(.rich-text-li), ol:not(.list-paddingleft-2), ul:not(.list-paddingleft-2){
480
- list-style-type: auto!important;
481
- }
482
- /deep/img{
483
- width: 100%;
484
- }
485
- /deep/.ne-table{
486
- width: 100% !important;
487
- }
488
- }
489
- .footer {
490
- width: calc(100% - 40px);
491
- height: 50px;
492
- display: flex;
493
- align-items: center;
494
- justify-content: space-between;
495
- cursor: pointer;
496
- padding: 0 20px;
497
- border-bottom: 1px solid #cccccc;
498
- }
499
- .loading_img {
500
- display: flex;
501
- align-items: center;
502
- justify-content: center;
503
- width: 100%;
504
- height: 100%;
505
- position: absolute;
506
- top: 0;
507
- left: 0;
508
- background: #FFF;
509
- img {
510
- width: 50px;
511
- height: 50px;
512
- }
513
- }
514
-
515
- .drawer-footer{
516
- width:100%;
517
- height: 50px;
518
- display: flex;
519
- align-items: center;
520
- justify-content: space-between;
521
- cursor: pointer;
522
- padding: 0 20px;
523
- border-bottom: 1px solid #cccccc;
524
- .header-right{
525
- display: flex;
526
- align-items: center;
527
- .summaryBtn{
528
- flex: none;
529
- //width: 95px;
530
- height: 26px;
531
- padding: 0 10px;
532
- background: #ffffff;
533
- display: flex;
534
- align-items: center;
535
- justify-content: center;
536
- box-sizing: border-box;
537
- border: 1px solid #a1b9ff;
538
- border-radius: 15px;
539
- cursor: pointer;
540
- color: #366aff;
541
- margin-right: 10px;
542
- font-size: 14px;
543
- i {
544
- font-size: 18px;
545
- margin: 0 5px;
546
- }
547
- }
548
- .summaryActiveBtn{
549
- background: #366aff !important;
550
- color: #ffffff !important;
551
- }
552
- .chat {
553
- width: 95px;
554
- height: 26px;
555
- background: #ffffff;
556
- display: flex;
557
- align-items: center;
558
- justify-content: center;
559
- box-sizing: border-box;
560
- border: 1px solid #a1b9ff;
561
- border-radius: 15px 0px 15px 15px;
562
- cursor: pointer;
563
- color: #366aff;
564
- margin-right: 10px;
565
- font-size: 14px;
566
- i {
567
- font-size: 16px;
568
- margin: 0 5px;
569
- }
570
- }
571
- .chat_active {
572
- background: #366aff !important;
573
- color: #FFFFFF !important;
574
- }
575
- }
576
- }
577
- @media screen and (max-width: 767px) {
578
- /* 这里是针对移动设备的css样式设置 */
579
- /deep/.el-drawer__body{
580
- height: 100%;
581
- }
582
- #drawer_content_pre {
583
- overflow: auto;
584
- height: calc(100% - 50px);
585
- background: #FFF;
586
- }
587
- }
588
- @media screen and (min-width: 768px) {
589
- /* 这里是针对pc设备的css样式设置 */
590
- /deep/.el-drawer__body{
591
- height: 100%;
592
- }
593
- #drawer_content_pre {
594
- overflow: auto;
595
- height: calc(100% - 50px);
596
- background: #FFF;
597
- }
598
- }
599
-
1
+
2
+ <!-- preview-pdf
3
+ 组件主要负责 知识项目中 文件的预览,携带定位信息参数 tagIds tagId 的会解析文件增加定位功能
4
+ 不携带定位信息的 也是走 kkview项目预览
5
+ 另外增加了在知识项目中预览当前文件的一些功能
6
+ -->
7
+ <template>
8
+ <!-- <van-popup v-model="previewShowPopup" position="bottom" :style="{ height: '90%', background:'#FFFFFF'}" v-if="previewShowPopup">
9
+ <div class="footer">
10
+ <span>查看详情</span>
11
+ <section @click="close">
12
+ <i class="iconfont guoran-shanchu"></i>
13
+ </section>
14
+ </div>
15
+ <template v-if="tagIds && tagIds.length != 0 && previewShowPopup">
16
+ <pdfPosition :tagIds="tagIds" ></pdfPosition>
17
+ </template>
18
+ <template v-else>
19
+ <div v-if="fileType == 'VIDEO'" style="width: 100%;height: calc(100% - 60px)">
20
+ <video :src="url" controls width="100%;" height="98%"></video>
21
+ </div>
22
+ <div v-else-if="fileType == 'HTML'" style="width: 100%;height: calc(100% - 60px)">
23
+ <div class="preview_iframe_html" style="text-algin:left" v-html="fileText"></div>
24
+ </div>
25
+ <template v-else-if="url.includes('https://www') || url.includes('http://www')">
26
+ <iframe class="preview_iframe"
27
+ :src="url"
28
+ width="100%"
29
+ height="100%"
30
+ scrolling="100%"
31
+ frameborder="no"
32
+ border="0"></iframe>
33
+ </template>
34
+ <template v-else>
35
+ <iframe class="preview_iframe" :src="previewUrl" style="border:none;"></iframe>
36
+ </template>
37
+ </template>
38
+ <div class="loading_img" v-show="loading">
39
+ <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
40
+ </div>
41
+ </van-popup> -->
42
+ <el-drawer
43
+ title="我是标题"
44
+ :visible.sync="drawer"
45
+ :with-header="false"
46
+ :append-to-body="true"
47
+ :destroy-on-close="true"
48
+ :model="false"
49
+ :direction="previewShowPopup ? 'btt' : 'rtl'"
50
+ :size="previewShowPopup ? '90%' : '65%'"
51
+ custom-class="pdf-preview-drawer"
52
+ v-if="drawer"
53
+ >
54
+ <!-- v-else-if="drawer" -->
55
+ <div class="drawer-footer">
56
+ <span>{{title ? title : "查看详情"}}</span>
57
+ <div class="header-right">
58
+ <div class="onload_btn" v-if="isDownload && isPc" @click="downLoad">
59
+ 下载
60
+ </div>
61
+ <div class="summaryBtn"
62
+ :class="showSummary ? 'summaryActiveBtn' : ''"
63
+ @click="summaryFun"
64
+ v-if="isHasChat"
65
+ >
66
+ <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
67
+ <span>智能摘要</span>
68
+ </div>
69
+ <template v-if="isHasChat">
70
+ <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
71
+ <i class="iconfont guoran-wendapingjia"></i>
72
+ 聊一聊
73
+ </div>
74
+ <div class="chat chat_active" @click="previewToDialog(false)" v-else>
75
+ <i class="iconfont guoran-wendapingjia"></i>
76
+ 聊一聊
77
+ </div>
78
+ </template>
79
+ <section @click="close">
80
+ <i class="iconfont guoran-shanchu"></i>
81
+ </section>
82
+ </div>
83
+ </div>
84
+ <div id="drawer_content_pre">
85
+ <intelligent-summary
86
+ v-show="showSummary && isHasChat"
87
+ :knowledgeId="knowledgeId"
88
+ @closeSummary="closeSummary"
89
+ @recommendQues="recommendQues"
90
+ @getSummarySuccess="getSummarySuccess"
91
+ :style="{marginTop:tagIds && tagIds.length != 0 && isPc ? '50px' : ''}"
92
+ ></intelligent-summary>
93
+ <template v-if="tagIds && tagIds.length != 0 && drawer">
94
+ <pdfPosition :tagIds="tagIds" :isMessageRecord="isMessageRecord" :fileName="fileName" :textWatermarkStr="textWatermarkStr" ref="pdfPosition"></pdfPosition>
95
+ </template>
96
+ <template v-else>
97
+ <div v-if="fileType == 'VIDEO'" style="width: 100%;">
98
+ <video :src="url" controls width="100%;" height="98%"></video>
99
+ </div>
100
+ <div v-else-if="fileType == 'HTML'" style="width: 100%;">
101
+ <div class="preview_iframe_html" style="text-algin:left" v-html="fileText"></div>
102
+ </div>
103
+ <template v-else-if="url.includes('https://www') || url.includes('http://www')">
104
+ <iframe class="preview_iframe"
105
+ :src="url"
106
+ width="100%"
107
+ height="100%"
108
+ scrolling="100%"
109
+ frameborder="no"
110
+ border="0"></iframe>
111
+ </template>
112
+ <template v-else>
113
+ <iframe class="preview_iframe_kk" :src="previewUrl" style="border:none;" :style="{height: iframeHeight}"></iframe>
114
+ </template>
115
+ </template>
116
+ <div class="mobile_onload_btn" v-if="isDownload && !isPc" @click="downLoad">
117
+ 下载
118
+ </div>
119
+ </div>
120
+ <div class="loading_img" v-show="loading">
121
+ <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
122
+ </div>
123
+ </el-drawer>
124
+ </template>
125
+
126
+ <script>
127
+ import pdfPosition from './pdfPosition.vue'
128
+ import { zoomElement } from '../assets/js/hammer'
129
+ import IntelligentSummary from "./intelligentSummary";
130
+ import { isMobile } from "../assets/js/common";
131
+ import { Toast } from 'vant';
132
+ export default {
133
+ data () {
134
+ return {
135
+ previewShowPopup: false,
136
+ fileText:'',
137
+ fileType:"",
138
+ isPc:false,
139
+ drawer:false,
140
+ tagIds: [],
141
+ // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
142
+ loading:true,
143
+ fileName:'',
144
+ previewKnowledgeId:"",
145
+ showSummary:true,
146
+ iframeHeight:"100%",
147
+ isDownload:false,
148
+ textWatermarkStr:""
149
+ }
150
+ },
151
+ mounted() {
152
+ window.addEventListener('message',this.handleIframeMessage,false);
153
+ this.isPcFun();
154
+ },
155
+ props:{
156
+ url:{
157
+ type: String,
158
+ required: true,
159
+ },
160
+ officePreviewType:{
161
+ type: String,
162
+ default: ''
163
+ },
164
+ isMessageRecord:{
165
+ type: Boolean,
166
+ default:false,
167
+ },
168
+ sourceFileType:{
169
+ type: String,
170
+ default: '',
171
+ },
172
+ title: {
173
+ type: String,
174
+ default: ''
175
+ },
176
+ isHasChat:{
177
+ type:Boolean,
178
+ default:false
179
+ },
180
+ knowledgeId:{
181
+ type: String,
182
+ default: '',
183
+ },
184
+ previewOssPath:{
185
+ type: String,
186
+ default: '',
187
+ }
188
+ },
189
+ components:{
190
+ IntelligentSummary,
191
+ pdfPosition
192
+ },
193
+ watch:{
194
+ drawer(value) {
195
+ if(value) {
196
+ this.$emit('open')
197
+ this.$nextTick(() =>{
198
+ if (this.tagIds && this.tagIds.length != 0){
199
+ zoomElement(document.getElementById('pdf_container_view'))
200
+ }
201
+ })
202
+ } else {
203
+ this.$emit('close')
204
+ }
205
+ setTimeout(() => {
206
+ let previewIframe = document.getElementsByClassName('preview_iframe')
207
+ Array.from(previewIframe).forEach(item =>{
208
+ item.onload = () =>{
209
+ console.debug('previewIframe 106',previewIframe,this.drawer)
210
+ item.style.backgroundImage = 'none'
211
+ }
212
+ })
213
+ })
214
+ },
215
+ showSummary:{
216
+ handler(val){
217
+ if (!val){
218
+ this.$nextTick(() => {
219
+ let preCon = document.querySelector('.pdf_view');
220
+ if (preCon){
221
+ preCon.style.height = 'calc(100% - ' + 50 + 'px)'
222
+ }
223
+ })
224
+ } else {
225
+ this.getSummarySuccess();
226
+ }
227
+ }
228
+ },
229
+ knowledgeId:{
230
+ handler(val){
231
+ if (val){
232
+ this.getTextWatermark();
233
+ }
234
+ }
235
+ }
236
+ },
237
+ computed:{
238
+ previewUrl() {
239
+ console.debug('VUE_APP_ENV',process.env.VUE_APP_ENV)
240
+ let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
241
+ // if(this.url != '') {
242
+ // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
243
+ // url += btoa(encodeURIComponent(this.url))
244
+ // } else {
245
+ // url += btoa(this.url)
246
+ // }
247
+ // }
248
+ url = url + this.url
249
+ url += '&officePreviewType=pdf'
250
+ if(this.watermark) {
251
+ url = this.watermark.textWatermarkValue ? (url += '&textWatermarkValue=' + this.watermark.textWatermarkValue) : url
252
+ url = this.watermark.visitorWatermarkValue ? (url += '&visitorWatermarkValue=' + this.watermark.visitorWatermarkValue) : url
253
+ }
254
+ console.log('textWatermarkStr 216',this.textWatermarkStr)
255
+ if (this.textWatermarkStr){
256
+ url += '&textWatermarkValue=' + this.textWatermarkStr
257
+ }
258
+ return url
259
+ },
260
+ // fileType() {
261
+ // const fileType = this.url.substring(this.url.lastIndexOf('.'));
262
+ // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
263
+ // return 'VIDEO'
264
+ // } else {
265
+ // return 'OTHER'
266
+ // }
267
+
268
+ // }
269
+ },
270
+ methods :{
271
+ close() {
272
+ setTimeout(() =>{
273
+ this.previewShowPopup = false;
274
+ this.fileType = ''
275
+ }, 300)
276
+ this.drawer = false;
277
+ this.showSummary = false;
278
+ },
279
+ loadIframe() {
280
+
281
+ if(this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0)) {
282
+ this.loading = false
283
+ } else {
284
+ let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
285
+ if (iframe){
286
+ iframe.onload = () => {
287
+ this.loading = false;
288
+ document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
289
+ }
290
+ }
291
+ // let time = setInterval(() =>{
292
+ //
293
+ // if(iframe) {
294
+ // this.loading = false
295
+ // clearInterval(time)
296
+ // }
297
+ // }, 500)
298
+ }
299
+ },
300
+ getBolb() {
301
+ this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false',{
302
+ fileInOssPath: this.url,
303
+ templateId: ''
304
+ }).then(res =>{
305
+ if (res.data.code == 0) {
306
+ this.fileText = res.data.data
307
+ this.loading = false
308
+ }
309
+ })
310
+ },
311
+ previewToDialog(flag){
312
+ this.$emit('previewToDialog',flag)
313
+ },
314
+ closeSummary(){
315
+ this.showSummary = false;
316
+ },
317
+ recommendQues(item,knowledgeId){
318
+ console.log('recommendQues',item,knowledgeId);
319
+ this.$emit('recommendQues',item,knowledgeId)
320
+ },
321
+ handleIframeMessage(res){
322
+ console.log('handleIframeMessage',res)
323
+ if (res.data.type == 'getViewerHeight'){
324
+ let iframeHeight = this.iframeHeight.replace('px','')
325
+ if (res.data.data && iframeHeight != (res.data.data + 50)){
326
+ this.iframeHeight = res.data.data + 50 + 'px'
327
+ }
328
+ }
329
+ },
330
+ summaryFun(){
331
+ this.showSummary = !this.showSummary;
332
+ if (this.showSummary){
333
+ document.getElementById('drawer_content_pre').scrollTop = 0;
334
+ }
335
+ },
336
+ getSummarySuccess(){
337
+ this.$nextTick(() => {
338
+ if (this.tagIds.length > 0){
339
+ let intelligentSummary = document.getElementById('intelligentSummary');
340
+ let preCon = document.querySelector('.pdf_view')
341
+ if (intelligentSummary){
342
+ let height = intelligentSummary.offsetHeight + (this.isPc ? 100 : 50 );
343
+ if (preCon){
344
+ preCon.style.height = 'calc(100% - ' + height + 'px)'
345
+ }
346
+ console.log('height',height,preCon)
347
+ }
348
+ }
349
+ })
350
+ },
351
+ getTextWatermark(){
352
+ let url = '/knowledge-api/open/knowledge/getPermissionInfo';
353
+ let obj = {
354
+ "knowledgeId":this.knowledgeId,
355
+ "userId":sessionStorage.getItem('_currentUserId'),
356
+ "mainId":sessionStorage.getItem('_mainId'),
357
+ "corpId":sessionStorage.getItem('_corpid')
358
+ }
359
+ this.$http.post(url,obj).then(res => {
360
+ console.log('getTextWatermark',res.data.data)
361
+ if (res.data.data){
362
+ this.textWatermarkStr = res.data.data.textWatermarkStr;
363
+ this.isDownload = res.data.data.showDownloadBtn;
364
+ }
365
+ })
366
+ },
367
+ downLoad () {
368
+ let url = this.previewOssPath
369
+ if (decodeURIComponent(url) != url) {
370
+ url = decodeURIComponent(url)
371
+ }
372
+ const fileType = url.substring(url.lastIndexOf('.'));
373
+ this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
374
+ headers:{
375
+ "Content-Type": "application/json",
376
+ }
377
+ }).then(res => {
378
+ console.log('downLoad 341',res)
379
+ if (res.data) {
380
+ if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
381
+ if(isMobile()) {
382
+ setTimeout(() =>{
383
+ const range = document.createRange();
384
+ range.selectNode(document.getElementById('text'));
385
+ const selection = window.getSelection();
386
+ //移除之前选中内容
387
+ if (selection.rangeCount > 0) selection.removeAllRanges();
388
+ selection.addRange(range);
389
+ document.execCommand('copy');
390
+ selection.removeAllRanges()
391
+ Toast('下载地址已复制,请前往Safari浏览器访问下载');
392
+ this.close()
393
+ },100)
394
+ } else {
395
+ navigator.clipboard.writeText(res.data)
396
+ this.$message.success({
397
+ message:'下载地址已复制,请前往Safari浏览器访问下载',
398
+ })
399
+ }
400
+ return
401
+ } else {
402
+ // setTimeout(() =>{
403
+ // window.open(res.data,'下载', 'noopener')
404
+ // }, 2000)
405
+ // window.open(res.data,'下载', 'noopener')
406
+ if(isMobile()) {
407
+ const iframe = document.createElement("iframe");
408
+ iframe.setAttribute("hidden", "hidden");
409
+ iframe.onload = () => {
410
+ if (iframe) {
411
+ console.log("iframe onload....")
412
+ iframe.setAttribute('src', 'about:blank');
413
+ }
414
+ };
415
+ document.body.insertBefore(iframe, null);
416
+ iframe.setAttribute("src", res.data);
417
+ } else {
418
+ let a = document.createElement('a')
419
+ a.href = res.data
420
+ a.download = (this.title) + fileType
421
+ a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
422
+ }
423
+ this.close()
424
+ }
425
+ }
426
+ })
427
+ },
428
+ isPcFun(){
429
+ if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
430
+ this.isPc = false
431
+ } else {
432
+ this.isPc = true
433
+ }
434
+ }
435
+ },
436
+ beforeDestroy() {
437
+ window.removeEventListener('message', this.handleIframeMessage);
438
+ }
439
+ }
440
+ </script>
441
+
442
+ <style lang="less" scoped>
443
+ #drawer_content_pre{
444
+ padding: 20px;
445
+ scroll-behavior: smooth;
446
+ .mobile_onload_btn{
447
+ position: absolute;
448
+ right: 0;
449
+ bottom: 10%;
450
+ width: 20px;
451
+ height: 60px;
452
+ display: flex;
453
+ align-items: center;
454
+ justify-content: center;
455
+ cursor: pointer;
456
+ border-top-left-radius: 10px;
457
+ border-bottom-left-radius: 10px;
458
+ color: #366aff;
459
+ background: #ffffff;
460
+ border: 1px solid #a1b9ff;
461
+ font-size: 12px;
462
+ border-right: none;
463
+ text-align: center;
464
+ }
465
+ }
466
+ .onload_btn {
467
+ width: 80px;
468
+ height: 26px;
469
+ display: flex;
470
+ align-items: center;
471
+ justify-content: center;
472
+ cursor: pointer;
473
+ margin-right: 10px;
474
+ border-radius: 15px;
475
+ color: #366aff;
476
+ background: #ffffff;
477
+ border: 1px solid #a1b9ff;
478
+ }
479
+ .preview_iframe {
480
+ width: 100%;
481
+ height: 100%;
482
+ box-sizing: border-box;
483
+ background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
484
+ background-position: center;
485
+ background-size: 50px;
486
+ background-repeat: no-repeat;
487
+ }
488
+ .preview_iframe_kk{
489
+ width: 100%;
490
+ height: 100%;
491
+ }
492
+ .preview_iframe_html{
493
+ width: 100%;
494
+ height: 100%;
495
+ overflow-y: scroll;
496
+ text-align: left;
497
+ box-sizing: border-box;
498
+ padding: 16px;
499
+ /deep/.lake-content{
500
+ margin-left: 10px;
501
+ }
502
+ /deep/a:link {
503
+ color: #0000ee!important;
504
+ }
505
+ /deep/a:visited {
506
+ color: #0000ee!important;
507
+ }
508
+ /deep/a:hover {
509
+ color: #0000ee!important;
510
+ }
511
+ /deep/a:active {
512
+ color: #0000ee!important;
513
+ }
514
+ /deep/li:not(.rich-text-li), ol:not(.list-paddingleft-2), ul:not(.list-paddingleft-2){
515
+ list-style-type: auto!important;
516
+ }
517
+ /deep/img{
518
+ width: 100%;
519
+ }
520
+ /deep/.ne-table{
521
+ width: 100% !important;
522
+ }
523
+ }
524
+ .footer {
525
+ width: calc(100% - 40px);
526
+ height: 50px;
527
+ display: flex;
528
+ align-items: center;
529
+ justify-content: space-between;
530
+ cursor: pointer;
531
+ padding: 0 20px;
532
+ border-bottom: 1px solid #cccccc;
533
+ }
534
+ .loading_img {
535
+ display: flex;
536
+ align-items: center;
537
+ justify-content: center;
538
+ width: 100%;
539
+ height: 100%;
540
+ position: absolute;
541
+ top: 0;
542
+ left: 0;
543
+ background: #FFF;
544
+ img {
545
+ width: 50px;
546
+ height: 50px;
547
+ }
548
+ }
549
+
550
+ .drawer-footer{
551
+ width:100%;
552
+ height: 50px;
553
+ display: flex;
554
+ align-items: center;
555
+ justify-content: space-between;
556
+ cursor: pointer;
557
+ padding: 0 20px;
558
+ border-bottom: 1px solid #cccccc;
559
+ .header-right{
560
+ display: flex;
561
+ align-items: center;
562
+ .summaryBtn{
563
+ flex: none;
564
+ //width: 95px;
565
+ height: 26px;
566
+ padding: 0 10px;
567
+ background: #ffffff;
568
+ display: flex;
569
+ align-items: center;
570
+ justify-content: center;
571
+ box-sizing: border-box;
572
+ border: 1px solid #a1b9ff;
573
+ border-radius: 15px;
574
+ cursor: pointer;
575
+ color: #366aff;
576
+ margin-right: 10px;
577
+ font-size: 14px;
578
+ i {
579
+ font-size: 18px;
580
+ margin: 0 5px;
581
+ }
582
+ }
583
+ .summaryActiveBtn{
584
+ background: #366aff !important;
585
+ color: #ffffff !important;
586
+ }
587
+ .chat {
588
+ width: 95px;
589
+ height: 26px;
590
+ background: #ffffff;
591
+ display: flex;
592
+ align-items: center;
593
+ justify-content: center;
594
+ box-sizing: border-box;
595
+ border: 1px solid #a1b9ff;
596
+ border-radius: 15px 0px 15px 15px;
597
+ cursor: pointer;
598
+ color: #366aff;
599
+ margin-right: 10px;
600
+ font-size: 14px;
601
+ i {
602
+ font-size: 16px;
603
+ margin: 0 5px;
604
+ }
605
+ }
606
+ .chat_active {
607
+ background: #366aff !important;
608
+ color: #FFFFFF !important;
609
+ }
610
+ }
611
+ }
612
+ @media screen and (max-width: 767px) {
613
+ /* 这里是针对移动设备的css样式设置 */
614
+ /deep/.el-drawer__body{
615
+ height: 100%;
616
+ }
617
+ #drawer_content_pre {
618
+ overflow: auto;
619
+ height: calc(100% - 50px);
620
+ background: #FFF;
621
+ }
622
+ }
623
+ @media screen and (min-width: 768px) {
624
+ /* 这里是针对pc设备的css样式设置 */
625
+ /deep/.el-drawer__body{
626
+ height: 100%;
627
+ }
628
+ #drawer_content_pre {
629
+ overflow: auto;
630
+ height: calc(100% - 50px);
631
+ background: #FFF;
632
+ }
633
+ }
634
+
635
+ @media screen and (min-width: 1350px) {
636
+ /* 这里是针对pc设备的css样式设置 */
637
+ .el-drawer__wrapper {
638
+ width: 55%;
639
+ left: calc(100vw - 55%);
640
+ right: 0;
641
+ /deep/.pdf-preview-drawer {
642
+ width: 100% !important;
643
+ }
644
+ }
645
+ /deep/.el-drawer__body{
646
+ height: 100%;
647
+ }
648
+ #drawer_content_pre {
649
+ overflow: auto;
650
+ height: calc(100% - 50px);
651
+ background: #FFF;
652
+ }
653
+ }
600
654
  </style>