askbot-dragon 1.7.76-beta → 1.7.78-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.
@@ -41,7 +41,7 @@
41
41
  </template>
42
42
  <div class="header_close" v-else>
43
43
  <span class="title_left">
44
- {{ title ? title : '查看详情' }}
44
+ {{ title ? title : $t('dragonCommon.viewDetails') }}
45
45
  </span>
46
46
  <section @click="close">
47
47
  <i class="iconfont guoran-shanchu"></i>
@@ -107,7 +107,7 @@
107
107
  :url="previewHref"
108
108
  ></new-position-preview>
109
109
  <template v-else>
110
- <div v-if="fileType == 'VIDEO'" style="width: 100%;height: 100%">
110
+ <div v-if="fileType == 'VIDEO'" style="width: 100%;">
111
111
  <video :src="url" controls width="100%;" height="98%"></video>
112
112
  </div>
113
113
  <div v-else-if="fileType == 'HTML'" style="width: 100%;">
@@ -152,7 +152,7 @@ import { isMobile } from "../assets/js/common";
152
152
  import { Toast } from 'vant';
153
153
  import NewPositionPreview from "./preview/newPositionPreview";
154
154
  export default {
155
- data() {
155
+ data () {
156
156
  return {
157
157
  previewShowPopup: false,
158
158
  fileText: '',
@@ -162,461 +162,437 @@ export default {
162
162
  tagIds: [],
163
163
  // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
164
164
  loading: true,
165
- fileName: '',
166
165
  previewKnowledgeId: "",
167
166
  showSummary: false,
168
167
  iframeHeight: "100%",
169
168
  isDownload: false,
170
169
  textWatermarkStr: "",
171
- copy: '',
172
- newVersion: '',
173
- previewHref: "",
174
- newFileType: "",
175
- numberPage: 0,
176
- pageChunkData: [],
177
- currentPage: 0
170
+ copy:'',
171
+ newVersion:'',
172
+ previewHref:"",
173
+ newFileType:"",
174
+ numberPage:0,
175
+ pageChunkData:[],
176
+ currentPage:0
178
177
  }
179
178
  },
180
- mounted() {
181
- this.$i18n.locale = sessionStorage.getItem("systemLanguage") || 'cn';
182
- window.addEventListener('message', this.handleIframeMessage, false);
183
- this.isPcFun();
179
+ mounted () {
180
+ this.$i18n.locale = sessionStorage.getItem("systemLanguage") || 'cn';
181
+ window.addEventListener('message', this.handleIframeMessage, false);
182
+ this.isPcFun();
183
+ },
184
+ props: {
185
+ url: {
186
+ type: String,
187
+ required: true,
184
188
  },
185
- props: {
186
- url: {
187
- type: String,
188
- required: true,
189
- },
190
- officePreviewType: {
191
- type: String,
192
- default: ''
193
- },
194
- isMessageRecord: {
195
- type: Boolean,
196
- default: false,
197
- },
198
- sourceFileType: {
199
- type: String,
200
- default: '',
201
- },
202
- title: {
203
- type: String,
204
- default: ''
205
- },
206
- isHasChat: {
207
- type: Boolean,
208
- default: false
209
- },
210
- knowledgeId: {
211
- type: String,
212
- default: '',
213
- },
214
- previewOssPath: {
215
- type: String,
216
- default: '',
217
- },
218
- folderName: {
219
- type: String,
220
- default: '',
221
- },
222
- folderUrl: {
223
- type: String,
224
- default: '',
225
- },
226
- isLiBang: {
227
- type: Boolean,
228
- default: false
229
- },
230
- formKnowledgeManagement: {
231
- type: Boolean,
232
- default: false
233
- }
189
+ officePreviewType: {
190
+ type: String,
191
+ default: ''
234
192
  },
235
- components: {
236
- NewPositionPreview,
237
- IntelligentSummary,
238
- pdfPosition
193
+ isMessageRecord: {
194
+ type: Boolean,
195
+ default: false,
239
196
  },
240
- watch: {
241
- drawer(value) {
242
- if (value) {
243
- this.$emit('open')
244
- this.$nextTick(() => {
245
- if (this.tagIds && this.tagIds.length != 0) {
246
- zoomElement(document.getElementById('pdf_container_view'))
247
- }
248
- })
249
- } else {
250
- this.$emit('close')
251
- }
252
- setTimeout(() => {
253
- let previewIframe = document.getElementsByClassName('preview_iframe')
254
- Array.from(previewIframe).forEach(item => {
255
- item.onload = () => {
256
- console.debug('previewIframe 106', previewIframe, this.drawer)
257
- item.style.backgroundImage = 'none'
258
- }
259
- })
197
+ sourceFileType: {
198
+ type: String,
199
+ default: '',
200
+ },
201
+ title: {
202
+ type: String,
203
+ default: ''
204
+ },
205
+ isHasChat: {
206
+ type: Boolean,
207
+ default: false
208
+ },
209
+ knowledgeId: {
210
+ type: String,
211
+ default: '',
212
+ },
213
+ previewOssPath: {
214
+ type: String,
215
+ default: '',
216
+ },
217
+ folderName: {
218
+ type: String,
219
+ default: '',
220
+ },
221
+ folderUrl: {
222
+ type: String,
223
+ default: '',
224
+ },
225
+ isLiBang: {
226
+ type: Boolean,
227
+ default: false
228
+ }},
229
+ components: {
230
+ NewPositionPreview,
231
+ IntelligentSummary,
232
+ pdfPosition
233
+ },
234
+ watch: {
235
+ drawer (value) {
236
+ if (value) {
237
+ this.$emit('open')
238
+ this.$nextTick(() => {
239
+ zoomElement(document.getElementById('drawer_content_pre'))
260
240
  })
261
- },
262
- showSummary: {
263
- handler(val) {
264
- // if (!val){
265
- // this.$nextTick(() => {
266
- // let preCon = document.querySelector('.pdf_view');
267
- // if (preCon){
268
- // preCon.style.height = 'calc(100% - ' + 50 + 'px)'
269
- // }
270
- // })
271
- // } else {
272
- // this.getSummarySuccess();
273
- // }
274
- if (val) {
275
- this.getSummarySuccess();
276
- }
277
- }
278
- },
279
- knowledgeId: {
280
- handler(val) {
281
- if (val) {
282
- this.getTextWatermark();
283
- }
284
- }
241
+ } else {
242
+ this.$emit('close')
285
243
  }
286
244
  },
287
- computed: {
288
- pdfStyle() {
289
- return {
290
- paddingTop: this.isPc ? '30px' : '0', // 30px 是 加上外层的 20 流出 50的上边距展示 放大缩小操作栏
291
- paddingBottom: this.tagIds > 1 ? '60px' : '0',
292
- height: '100%'
293
- }
294
- },
295
- previewUrl() {
296
- console.debug('VUE_APP_ENV', process.env.VUE_APP_ENV)
297
- let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
298
- // if(this.url != '') {
299
- // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
300
- // url += btoa(encodeURIComponent(this.url))
301
- // } else {
302
- // url += btoa(this.url)
245
+ showSummary: {
246
+ handler (val) {
247
+ // if (!val){
248
+ // this.$nextTick(() => {
249
+ // let preCon = document.querySelector('.pdf_view');
250
+ // if (preCon){
251
+ // preCon.style.height = 'calc(100% - ' + 50 + 'px)'
303
252
  // }
253
+ // })
254
+ // } else {
255
+ // this.getSummarySuccess();
304
256
  // }
305
- url = url + this.url
306
- url += '&officePreviewType=pdf'
307
- if (this.watermark) {
308
- url = this.watermark.textWatermarkValue ? (url += '&textWatermarkValue=' + this.watermark.textWatermarkValue) : url
309
- url = this.watermark.visitorWatermarkValue ? (url += '&visitorWatermarkValue=' + this.watermark.visitorWatermarkValue) : url
257
+ if (val) {
258
+ this.getSummarySuccess();
310
259
  }
311
- console.log('textWatermarkStr 216', this.textWatermarkStr)
312
- if (this.textWatermarkStr) {
313
- url += '&textWatermarkValue=' + this.textWatermarkStr
260
+ }
261
+ },
262
+ knowledgeId: {
263
+ handler (val) {
264
+ if (val) {
265
+ this.getTextWatermark();
314
266
  }
315
- return url
316
- },
317
- // fileType() {
318
- // const fileType = this.url.substring(this.url.lastIndexOf('.'));
319
- // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
320
- // return 'VIDEO'
267
+ }
268
+ }
269
+ },
270
+ computed: {
271
+ pdfStyle () {
272
+ return {
273
+ paddingTop: this.isPc ? '30px' : '0', // 30px 是 加上外层的 20 流出 50的上边距展示 放大缩小操作栏
274
+ paddingBottom: this.tagIds > 1 ? '60px' : '0',
275
+ height: '100%'
276
+ }
277
+ },
278
+ previewUrl () {
279
+ console.debug('VUE_APP_ENV', process.env.VUE_APP_ENV)
280
+ let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
281
+ // if(this.url != '') {
282
+ // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
283
+ // url += btoa(encodeURIComponent(this.url))
321
284
  // } else {
322
- // return 'OTHER'
285
+ // url += btoa(this.url)
323
286
  // }
324
-
325
287
  // }
288
+ url = url + this.url
289
+ if (this.sourceFileType == '.ppt' || this.sourceFileType == '.pptx' || this.sourceFileType == '.pdf') {
290
+ url += '&officePreviewType=pdf'
291
+ }
292
+ console.log('textWatermarkStr 216', this.textWatermarkStr)
293
+ if (this.textWatermarkStr) {
294
+ url += '&textWatermarkValue=' + this.textWatermarkStr
295
+ }
296
+ return url
326
297
  },
327
- methods: {
328
- close() {
329
- setTimeout(() => {
330
- this.previewShowPopup = false;
331
- this.fileType = ''
332
- }, 300)
333
- this.drawer = false;
334
- this.showSummary = false;
335
- },
336
- loadIframe() {
298
+ // fileType() {
299
+ // const fileType = this.url.substring(this.url.lastIndexOf('.'));
300
+ // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
301
+ // return 'VIDEO'
302
+ // } else {
303
+ // return 'OTHER'
304
+ // }
337
305
 
338
- if (this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0 && this.newFileType !== 'PPT')) {
339
- this.loading = false
340
- } else {
341
- let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
342
- if (iframe) {
343
- iframe.onload = () => {
344
- this.loading = false;
345
- document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
346
- }
347
- }
348
- // let time = setInterval(() =>{
349
- //
350
- // if(iframe) {
351
- // this.loading = false
352
- // clearInterval(time)
353
- // }
354
- // }, 500)
355
- }
356
- },
357
- getBolb() {
358
- this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false', {
359
- fileInOssPath: this.url,
360
- templateId: ''
361
- }).then(res => {
362
- if (res.data.code == 0) {
363
- this.fileText = res.data.data
364
- this.loading = false
365
- }
366
- })
367
- },
368
- previewToDialog(flag) {
369
- this.$emit('previewToDialog', flag)
370
- },
371
- closeSummary() {
372
- this.showSummary = false;
373
- },
374
- recommendQues(item, knowledgeId) {
375
- console.log('recommendQues', item, knowledgeId);
376
- this.$emit('recommendQues', item, knowledgeId)
377
- },
378
- handleIframeMessage(res) {
379
- if (res.data.type == 'getViewerHeight') {
380
- let iframeHeight = this.iframeHeight.replace('px', '')
381
- if (res.data.data && iframeHeight != (res.data.data + 50)) {
382
- this.iframeHeight = res.data.data + 50 + 'px'
306
+ // }
307
+ },
308
+ methods: {
309
+ close () {
310
+ setTimeout(() => {
311
+ this.previewShowPopup = false;
312
+ this.fileType = ''
313
+ }, 300)
314
+ this.drawer = false;
315
+ this.showSummary = false;
316
+ },
317
+ loadIframe () {
318
+
319
+ if (this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0 && this.newFileType !== 'PPT')) {
320
+ this.loading = false
321
+ } else {
322
+ let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
323
+ if (iframe) {
324
+ iframe.onload = () => {
325
+ this.loading = false;
326
+ document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
383
327
  }
384
328
  }
385
- if (res.data.type == 'getViewPage' && res.data.data) {
386
- this.numberPage = Number(res.data.data);
387
- if (this.pageChunkData.length > 0) {
388
- this.scrollPPTPage(this.pageChunkData[0])
389
- }
329
+ // let time = setInterval(() =>{
330
+ //
331
+ // if(iframe) {
332
+ // this.loading = false
333
+ // clearInterval(time)
334
+ // }
335
+ // }, 500)
336
+ }
337
+ },
338
+ getBolb () {
339
+ this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false', {
340
+ fileInOssPath: this.url,
341
+ templateId: ''
342
+ }).then(res => {
343
+ if (res.data.code == 0) {
344
+ this.fileText = res.data.data
345
+ this.loading = false
390
346
  }
391
- if (res.data.type == 'getViewerHeight' || res.data.type == 'getViewPage') {
392
- if (this.pageChunkData.length > 0) {
393
- this.scrollPPTPage(this.pageChunkData[0])
394
- }
347
+ })
348
+ },
349
+ previewToDialog (flag) {
350
+ this.$emit('previewToDialog', flag)
351
+ },
352
+ closeSummary () {
353
+ this.showSummary = false;
354
+ },
355
+ recommendQues (item, knowledgeId) {
356
+ console.log('recommendQues', item, knowledgeId);
357
+ this.$emit('recommendQues', item, knowledgeId)
358
+ },
359
+ handleIframeMessage (res) {
360
+ if (res.data.type == 'getViewerHeight') {
361
+ let iframeHeight = this.iframeHeight.replace('px', '')
362
+ if (res.data.data && iframeHeight != (res.data.data + 50)) {
363
+ this.iframeHeight = res.data.data + 50 + 'px'
395
364
  }
396
- },
397
- summaryFun() {
398
- this.showSummary = !this.showSummary;
399
- if (this.showSummary) {
400
- document.getElementById('drawer_content_pre').scrollTop = 0;
365
+ }
366
+ if (res.data.type == 'getViewPage' && res.data.data){
367
+ this.numberPage = Number(res.data.data);
368
+ if (this.pageChunkData.length > 0){
369
+ this.scrollPPTPage(this.pageChunkData[0])
401
370
  }
402
- },
403
- getSummarySuccess() {
404
- this.$nextTick(() => {
405
- // if (this.tagIds.length > 0){
406
- // let intelligentSummary = document.getElementById('intelligentSummary');
407
- // let preCon = document.querySelector('.pdf_view')
408
- // if (intelligentSummary){
409
- // let height = intelligentSummary.offsetHeight + (this.isPc ? 100 : 50 );
410
- // if (preCon){
411
- // preCon.style.height = 'calc(100% - ' + height + 'px)'
412
- // }
413
- // console.log('height',height,preCon)
414
- // }
415
- // }
416
- // let intelligentSummary = document.getElementById('intelligentSummary');
417
- // let height = intelligentSummary.offsetHeight
418
- // this.pdfStyle.height = 'calc(100% - ' + height + 'px)'
419
- })
420
- },
421
- getTextWatermark() {
422
- let url = '/knowledge-api/open/knowledge/getPermissionInfo';
423
- let obj = {
424
- "knowledgeId": this.knowledgeId,
425
- "userId": sessionStorage.getItem('_currentUserId'),
426
- "mainId": sessionStorage.getItem('_mainId'),
427
- "corpId": sessionStorage.getItem('_corpid')
371
+ }
372
+ if (res.data.type == 'getViewerHeight' || res.data.type == 'getViewPage'){
373
+ if (this.pageChunkData.length > 0){
374
+ this.scrollPPTPage(this.pageChunkData[0])
428
375
  }
429
- this.$http.post(url, obj).then(res => {
430
- console.log('getTextWatermark', res.data.data)
431
- if (res.data.data) {
432
- this.textWatermarkStr = res.data.data.textWatermarkStr;
433
- this.isDownload = res.data.data.showDownloadBtn;
434
- }
435
- })
436
- },
437
- downLoad() {
438
- // if (this.formKnowledgeManagement) {
439
- // this.$emit('downLoad', this.previewOssPath);
440
- // return
376
+ }
377
+ },
378
+ summaryFun () {
379
+ this.showSummary = !this.showSummary;
380
+ if (this.showSummary) {
381
+ document.getElementById('drawer_content_pre').scrollTop = 0;
382
+ }
383
+ },
384
+ getSummarySuccess () {
385
+ this.$nextTick(() => {
386
+ // if (this.tagIds.length > 0){
387
+ // let intelligentSummary = document.getElementById('intelligentSummary');
388
+ // let preCon = document.querySelector('.pdf_view')
389
+ // if (intelligentSummary){
390
+ // let height = intelligentSummary.offsetHeight + (this.isPc ? 100 : 50 );
391
+ // if (preCon){
392
+ // preCon.style.height = 'calc(100% - ' + height + 'px)'
393
+ // }
394
+ // console.log('height',height,preCon)
395
+ // }
441
396
  // }
442
- let url = this.previewOssPath
443
- if (decodeURIComponent(url) != url) {
444
- url = decodeURIComponent(url)
397
+ // let intelligentSummary = document.getElementById('intelligentSummary');
398
+ // let height = intelligentSummary.offsetHeight
399
+ // this.pdfStyle.height = 'calc(100% - ' + height + 'px)'
400
+ })
401
+ },
402
+ getTextWatermark () {
403
+ let url = '/knowledge-api/open/knowledge/getPermissionInfo';
404
+ let obj = {
405
+ "knowledgeId": this.knowledgeId,
406
+ "userId": sessionStorage.getItem('_currentUserId'),
407
+ "mainId": sessionStorage.getItem('_mainId'),
408
+ "corpId": sessionStorage.getItem('_corpid')
409
+ }
410
+ this.$http.post(url, obj).then(res => {
411
+ console.log('getTextWatermark', res.data.data)
412
+ if (res.data.data) {
413
+ this.textWatermarkStr = res.data.data.textWatermarkStr;
414
+ this.isDownload = res.data.data.showDownloadBtn;
445
415
  }
446
- const fileType = url.substring(url.lastIndexOf('.'));
447
- this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
448
- headers: {
449
- "Content-Type": "application/json",
450
- }
451
- }).then(res => {
452
- console.log('downLoad 341', res)
453
- if (res.data || res.bodyText) {
454
- if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
455
- this.copy = res.data
456
- if (isMobile()) {
457
- setTimeout(() => {
458
- const range = document.createRange();
459
- range.selectNode(document.getElementById('text'));
460
- const selection = window.getSelection();
461
- //移除之前选中内容
462
- if (selection.rangeCount > 0) selection.removeAllRanges();
463
- selection.addRange(range);
464
- document.execCommand('copy');
465
- selection.removeAllRanges()
466
- Toast(this.$t('dragonCommon.Safaridownload'));
467
- this.close()
468
- }, 100)
469
- } else {
470
- let a = document.createElement('a')
471
- a.href = res.data
472
- a.download = (this.title) + fileType
473
- a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
474
- }
475
- return
416
+ })
417
+ },
418
+ downLoad () {
419
+ let url = this.previewOssPath
420
+ if (decodeURIComponent(url) != url) {
421
+ url = decodeURIComponent(url)
422
+ }
423
+ const fileType = url.substring(url.lastIndexOf('.'));
424
+ this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
425
+ headers: {
426
+ "Content-Type": "application/json",
427
+ }
428
+ }).then(res => {
429
+ console.log('downLoad 341', res)
430
+ if (res.data || res.bodyText) {
431
+ if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
432
+ this.copy = res.data
433
+ if (isMobile()) {
434
+ setTimeout(() =>{
435
+ const range = document.createRange();
436
+ range.selectNode(document.getElementById('text'));
437
+ const selection = window.getSelection();
438
+ //移除之前选中内容
439
+ if (selection.rangeCount > 0) selection.removeAllRanges();
440
+ selection.addRange(range);
441
+ document.execCommand('copy');
442
+ selection.removeAllRanges()
443
+ Toast(this.$t('dragonCommon.Safaridownload'));
444
+ this.close()
445
+ },100)
476
446
  } else {
477
- // setTimeout(() =>{
478
- // window.open(res.data,'下载', 'noopener')
479
- // }, 2000)
480
- // window.open(res.data,'下载', 'noopener')
481
- if (isMobile()) {
482
-
483
- const iframe = document.createElement("iframe");
484
- iframe.setAttribute("hidden", "hidden");
485
- iframe.onload = () => {
486
- if (iframe) {
487
- console.log("iframe onload....")
488
- iframe.setAttribute('src', 'about:blank');
489
- }
490
- };
491
- document.body.insertBefore(iframe, null);
492
- iframe.setAttribute("src", res.data);
493
- } else {
494
- let a = document.createElement('a')
495
- a.href = res.data
496
- a.download = (this.title) + fileType
497
- a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
498
- }
499
- this.close()
447
+ let a = document.createElement('a')
448
+ a.href = res.data
449
+ a.download = (this.title) + fileType
450
+ a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
500
451
  }
501
- }
502
- })
503
- },
504
- isPcFun() {
505
- if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
506
- this.isPc = false
507
- } else {
508
- this.isPc = true
509
- }
510
- },
511
- clickFloder() {
512
- this.$emit('previewClickFloder')
513
- },
514
- getOssPath(url) {
515
- let httpUrl = '/knowledge-api/knowledge/getTemporaryCertificate';
516
- let type = this.getFileType(url)
517
- this.newFileType = type;
518
- if (type === 'VIDEO' || type === 'PDF' || type === 'EXCEL' || type === 'TXT' || type === 'DOC') {
519
- httpUrl += '?needEncrypt=false'
520
- } else {
521
- httpUrl += '?needEncrypt=true'
522
- }
523
- this.$http.post(httpUrl, {
524
- "fileInOssPath": url
525
- }).then(res => {
526
- console.log('getOssPath', res)
527
- if (res.data.code == '0') {
528
- this.previewHref = res.data.data;
529
- }
530
- })
531
- },
532
- getFileType(url) {
533
- let index = url.lastIndexOf('?')
534
- let newFileInOssPath = url.substring(0, url.indexOf("?"))
535
- if (index == -1) {
536
- newFileInOssPath = url
537
- }
538
- const fileType = newFileInOssPath.substring(newFileInOssPath.lastIndexOf('.'));
539
- if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.MOVC' || fileType === '.mov' || fileType === '.movc') {
540
- return 'VIDEO'
541
- } else if (fileType === '.html') {
542
- return 'HTML'
543
- } else if (fileType === '.png' || fileType === '.jpg' || fileType === '.jpeg' || fileType === '.PNG' || fileType === '.JPG' || fileType === '.JPEG') {
544
- return 'IMAGE'
545
- } else if (fileType === '.docx' || fileType === '.doc') {
546
- return 'DOC'
547
- } else if (fileType === '.ppt' || fileType === '.pptx') {
548
- return 'PPT'
549
- } else if (fileType === '.pdf') {
550
- return 'PDF'
551
- } else if (fileType === '.txt') {
552
- return 'TXT'
553
- } else {
554
- return 'OTHER'
555
- }
556
- },
557
- //判断是否使用新定位组件
558
- getLocationInfo() {
559
- this.newVersion = "";
560
- this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + this.tagIds.join(',')).then(res => {
561
- console.log('getLocationInfo', res)
562
- this.pageChunkData = [];
563
- if (res.data.code == 0) {
564
- if (res.data.data && res.data.data.length > 0 && res.data.data[0].extractVersion == 'v3') {
565
- this.newVersion = true;
566
- if (this.newFileType !== 'PPT') {
567
- this.loading = false;
568
- }
569
- for (let i = 0; i < res.data.data.length; i++) {
570
- if (res.data.data[i].paragraphChunkInfo && res.data.data[i].paragraphChunkInfo.pageChunkData) {
571
- this.pageChunkData.push(res.data.data[i].paragraphChunkInfo.pageChunkData.page_number)
572
- }
573
- }
574
- if (this.pageChunkData.length > 1) {
575
- let iframe = document.getElementsByClassName('preview_iframe_kk')
576
- if (iframe && iframe.length > 0) {
577
- iframe[0].style.paddingBottom = '50px'
452
+ return
453
+ } else {
454
+ // setTimeout(() =>{
455
+ // window.open(res.data,'下载', 'noopener')
456
+ // }, 2000)
457
+ // window.open(res.data,'下载', 'noopener')
458
+ if (isMobile()) {
459
+ const iframe = document.createElement("iframe");
460
+ iframe.setAttribute("hidden", "hidden");
461
+ iframe.onload = () => {
462
+ if (iframe) {
463
+ console.log("iframe onload....")
464
+ iframe.setAttribute('src', 'about:blank');
578
465
  }
579
- }
466
+ };
467
+ document.body.insertBefore(iframe, null);
468
+ iframe.setAttribute("src", res.data);
580
469
  } else {
581
- this.newVersion = false;
470
+ let a = document.createElement('a')
471
+ a.href = res.data
472
+ a.download = (this.title) + fileType
473
+ a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
582
474
  }
475
+ this.close()
583
476
  }
584
- })
585
- },
586
- currentChange(value) {
587
- this.currentPage = value - 1;
588
- this.scrollPPTPage()
589
- },
590
- prev() {
591
- if (this.currentPage == 0) {
592
- return
593
477
  }
594
- this.currentPage--;
595
- this.scrollPPTPage()
596
- },
597
- next() {
598
- if (this.currentPage === (this.pageChunkData.length - 1)) {
599
- return;
478
+ })
479
+ },
480
+ isPcFun () {
481
+ if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
482
+ this.isPc = false
483
+ } else {
484
+ this.isPc = true
485
+ }
486
+ },
487
+ clickFloder() {
488
+ this.$emit('previewClickFloder')
489
+ },
490
+ getOssPath(url){
491
+ let httpUrl = '/knowledge-api/knowledge/getTemporaryCertificate';
492
+ let type = this.getFileType(url)
493
+ this.newFileType = type;
494
+ if (type === 'VIDEO' || type === 'PDF' || type === 'EXCEL' || type === 'TXT' || type === 'DOC') {
495
+ httpUrl += '?needEncrypt=false'
496
+ } else {
497
+ httpUrl += '?needEncrypt=true'
498
+ }
499
+ this.$http.post(httpUrl, {
500
+ "fileInOssPath": url
501
+ }).then(res => {
502
+ console.log('getOssPath',res)
503
+ if (res.data.code == '0'){
504
+ this.previewHref = res.data.data;
600
505
  }
601
- this.currentPage++;
602
- this.scrollPPTPage()
603
- },
604
- scrollPPTPage() {
605
- if (this.numberPage > 0) {
606
- let pageNumber = this.pageChunkData[this.currentPage];
607
- let height = Math.floor(Number(this.iframeHeight.replace('px', "")));
608
- let pageHeight = Math.floor(height / this.numberPage);
609
- let scrollHeight = (pageNumber - 1) * pageHeight;
610
- let dom = document.getElementById('drawer_content_pre');
611
- if (dom) {
612
- dom.scrollTo(0, scrollHeight)
506
+ })
507
+ },
508
+ getFileType(url){
509
+ let index = url.lastIndexOf('?')
510
+ let newFileInOssPath = url.substring(0, url.indexOf("?"))
511
+ if (index == -1){
512
+ newFileInOssPath = url
513
+ }
514
+ const fileType = newFileInOssPath.substring(newFileInOssPath.lastIndexOf('.'));
515
+ if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.MOVC' || fileType === '.mov' || fileType === '.movc') {
516
+ return 'VIDEO'
517
+ } else if (fileType === '.html') {
518
+ return 'HTML'
519
+ } else if (fileType === '.png' || fileType === '.jpg' || fileType === '.jpeg' || fileType === '.PNG' || fileType === '.JPG' || fileType === '.JPEG') {
520
+ return 'IMAGE'
521
+ } else if (fileType === '.docx' || fileType === '.doc'){
522
+ return 'DOC'
523
+ } else if (fileType === '.ppt' || fileType === '.pptx'){
524
+ return 'PPT'
525
+ } else if (fileType === '.pdf'){
526
+ return 'PDF'
527
+ } else if (fileType === '.txt'){
528
+ return 'TXT'
529
+ } else {
530
+ return 'OTHER'
531
+ }
532
+ },
533
+ //判断是否使用新定位组件
534
+ getLocationInfo(){
535
+ this.newVersion = "";
536
+ this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + this.tagIds.join(',')).then(res => {
537
+ console.log('getLocationInfo',res)
538
+ this.pageChunkData = [];
539
+ if (res.data.code == 0){
540
+ if (res.data.data && res.data.data.length > 0 && res.data.data[0].extractVersion == 'v3'){
541
+ this.newVersion = true;
542
+ if (this.newFileType !== 'PPT'){
543
+ this.loading = false;
544
+ }
545
+ for (let i=0;i<res.data.data.length;i++){
546
+ if (res.data.data[i].paragraphChunkInfo && res.data.data[i].paragraphChunkInfo.pageChunkData){
547
+ this.pageChunkData.push(res.data.data[i].paragraphChunkInfo.pageChunkData.page_number)
548
+ }
549
+ }
550
+ if (this.pageChunkData.length > 1){
551
+ let iframe = document.getElementsByClassName('preview_iframe_kk')
552
+ if (iframe && iframe.length > 0){
553
+ iframe[0].style.paddingBottom = '50px'
554
+ }
555
+ }
556
+ } else {
557
+ this.newVersion = false;
613
558
  }
614
559
  }
560
+ })
561
+ },
562
+ currentChange (value) {
563
+ this.currentPage = value - 1;
564
+ this.scrollPPTPage()
565
+ },
566
+ prev(){
567
+ if (this.currentPage == 0){
568
+ return
615
569
  }
570
+ this.currentPage--;
571
+ this.scrollPPTPage()
616
572
  },
617
- beforeDestroy() {
618
- window.removeEventListener('message', this.handleIframeMessage);
573
+ next(){
574
+ if (this.currentPage === (this.pageChunkData.length - 1)){
575
+ return;
576
+ }
577
+ this.currentPage++;
578
+ this.scrollPPTPage()
579
+ },
580
+ scrollPPTPage(){
581
+ if (this.numberPage > 0){
582
+ let pageNumber = this.pageChunkData[this.currentPage];
583
+ let height = Math.floor(Number(this.iframeHeight.replace('px',"")));
584
+ let pageHeight = Math.floor(height / this.numberPage);
585
+ let scrollHeight = (pageNumber - 1) * pageHeight;
586
+ let dom = document.getElementById('drawer_content_pre');
587
+ if (dom){
588
+ dom.scrollTo(0,scrollHeight)
589
+ }
590
+ }
619
591
  }
592
+ },
593
+ beforeDestroy () {
594
+ window.removeEventListener('message', this.handleIframeMessage);
595
+ }
620
596
  }
621
597
  </script>
622
598
 
@@ -907,7 +883,6 @@ justify-content: space-between;
907
883
  .header-right {
908
884
  display: flex;
909
885
  }
910
-
911
886
  .summaryBtn {
912
887
  flex: none;
913
888
  //width: 95px;
@@ -1019,6 +994,10 @@ justify-content: space-between;
1019
994
  overflow: auto;
1020
995
  height: calc(100% - 50px);
1021
996
  background: #FFF;
997
+ background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
998
+ background-position: center;
999
+ background-size: 50px;
1000
+ background-repeat: no-repeat;
1022
1001
  }
1023
1002
 
1024
1003
  .libang_content_pre {