askbot-dragon 1.8.28-beta → 1.8.29-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "askbot-dragon",
3
- "version": "1.8.28-beta",
3
+ "version": "1.8.29-beta",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -18,6 +18,9 @@
18
18
  ></excel-view>
19
19
  <pdf-view v-else-if="fileType === 'PDF'" ref="pdfView" :split_paragraphs="splitParagraph" :ossPath="url" :isPC="isPC" :textWatermarkStr="textWatermarkStr"></pdf-view>
20
20
  <mark-down-view v-else-if="fileType === 'MD'" :url="url" :split_paragraphs="splitParagraph" :textWatermarkStr="textWatermarkStr"></mark-down-view>
21
+ <div v-else-if="fileType === 'URL'">
22
+ <div class="preview_iframe_html" style="text-align:left" v-html="fileText"></div>
23
+ </div>
21
24
  </div>
22
25
  <template v-if="splitParagraph.length > 1 && fileType !== 'XLS' && fileType !== 'XLSX'">
23
26
  <div class="btn_footer" v-if="!isPC">
@@ -54,8 +57,9 @@ export default {
54
57
  currentPage:0,
55
58
  excelHeaderData:"",
56
59
  excelRowList:[],
57
- tableChunkData:[]
58
-
60
+ tableChunkData:[],
61
+ fileText:"",
62
+ colors: ['#E3EBFF', '#FFF5DC', '#FFE8D8','#D6F3EA','#FFF1C3'],
59
63
  }
60
64
  },
61
65
  props:{
@@ -76,6 +80,10 @@ export default {
76
80
  textWatermarkStr: {
77
81
  type: String,
78
82
  default: ''
83
+ },
84
+ previewOssPath:{
85
+ type:String,
86
+ default:""
79
87
  }
80
88
  },
81
89
  methods:{
@@ -126,6 +134,11 @@ export default {
126
134
  this.excelRowList = res.data.data.extractChunkInfo.tableChunkData[0].table_md.table_data;
127
135
  }
128
136
  this.fileType = res.data.data.fileType
137
+ // 判断是否为 HTTP 链接,但排除包含 aliyuncs 的OSS链接
138
+ if ((this.previewOssPath.startsWith('http://') || this.previewOssPath.startsWith('https://')) && !this.previewOssPath.includes('aliyuncs')) {
139
+ this.fileType = 'URL';
140
+ this.getUrlContent(this.html_result)
141
+ }
129
142
  }
130
143
  this.$nextTick(() => {
131
144
  if (this.fileType === 'XLS' || this.fileType === 'XLSX'){
@@ -164,13 +177,18 @@ export default {
164
177
  }
165
178
  await this.$refs.pdfView.loadPage(page);
166
179
  this.$refs.pdfView.jumpToHighlight(this.currentPage)
167
- } else if (this.fileType == 'DOC' || this.fileType == 'DOCX' || this.fileType == 'TXT' || this.fileType == 'MD' || this.fileType == 'HTML'){
180
+ } else if (this.fileType == 'DOC' || this.fileType == 'DOCX' || this.fileType == 'TXT' || this.fileType == 'MD' || this.fileType == 'HTML' || this.fileType == 'URL'){
168
181
  if (this.splitParagraph[this.currentPage] && this.splitParagraph[this.currentPage].original_paragraph){
169
182
  const id = this.splitParagraph[this.currentPage].original_paragraph[0].paragraph_id;
170
183
  let dom = document.getElementById(id);
171
184
  let paragraphs = this.$el.querySelectorAll(`[paragraph-id="${this.splitParagraph[this.currentPage].original_paragraph[0].paragraph_id}"]`);
172
- if (this.fileType == 'HTML'){
173
- paragraphs = this.$el.querySelectorAll(`[data-paragraph-id="${this.splitParagraph[this.currentPage].original_paragraph[0].paragraph_id}"]`);
185
+ if (this.fileType == 'HTML' || this.fileType == 'URL'){
186
+ if (this.splitParagraph[this.currentPage].original_paragraph[0].images && this.splitParagraph[this.currentPage].original_paragraph[0].images.length > 0){
187
+ paragraphs = this.$el.querySelectorAll(`[data-paragraph-id="${this.splitParagraph[this.currentPage].original_paragraph[1].paragraph_id}"]`);
188
+ } else {
189
+ paragraphs = this.$el.querySelectorAll(`[data-paragraph-id="${this.splitParagraph[this.currentPage].original_paragraph[0].paragraph_id}"]`);
190
+ }
191
+
174
192
  }
175
193
  if (dom){
176
194
  dom.scrollIntoView({ behavior: 'smooth' });
@@ -217,7 +235,125 @@ export default {
217
235
  }
218
236
  }
219
237
  }
220
- }
238
+ },
239
+ // 新增方法:获取URL内容并对图片地址进行签名处理
240
+ getUrlContent(url) {
241
+ this.loading = true;
242
+ console.log('url',url)
243
+ this.$http.get(url).then((res) => {
244
+ if (res.status === 200) {
245
+ // 处理HTML内容中的图片地址,添加签名
246
+ this.processImageUrls(res.data);
247
+ } else {
248
+ console.error('获取URL内容失败');
249
+ this.loading = false;
250
+ }
251
+ }).catch((err) => {
252
+ console.error('获取URL内容失败:', err);
253
+ this.loading = false;
254
+ });
255
+ },
256
+ setColor(){
257
+ this.splitParagraph.forEach((item,index) => {
258
+ const colorIndex = index % this.colors.length;
259
+ if (item.original_paragraph){
260
+ item.original_paragraph.forEach(items => {
261
+ const paragraphs = this.$el.querySelectorAll(`[data-paragraph-id="${items.paragraph_id}"]`);
262
+ paragraphs.forEach(paragraph => {
263
+ paragraph.style.background = this.colors[colorIndex]
264
+ })
265
+ })
266
+ }
267
+ })
268
+ },
269
+ // 处理HTML内容中的图片地址,为OSS图片添加签名
270
+ processImageUrls(htmlContent) {
271
+ // 创建临时DOM元素来解析HTML
272
+ const tempDiv = document.createElement('div');
273
+ tempDiv.innerHTML = htmlContent;
274
+
275
+ // 查找所有图片标签
276
+ const imgTags = tempDiv.querySelectorAll('img');
277
+ let processedCount = 0;
278
+ let totalImages = imgTags.length;
279
+
280
+ if (totalImages === 0) {
281
+ // 没有图片,直接显示内容
282
+ this.fileText = htmlContent;
283
+ this.loading = false;
284
+ document.getElementById('drawer_content_pre').style.backgroundImage = 'none';
285
+ this.$nextTick(() => {
286
+ this.setColor()
287
+ })
288
+ this.$emit('loadingSuccess');
289
+ return;
290
+ }
291
+
292
+ // 处理每个图片地址
293
+ imgTags.forEach((img) => {
294
+ const imgSrc = img.getAttribute('src');
295
+ if (imgSrc && (imgSrc.includes('aliyuncs') || imgSrc.includes('oss-'))) {
296
+ // 为OSS图片获取签名URL
297
+ this.getSignedImageUrl(imgSrc, (signedUrl) => {
298
+ if (signedUrl) {
299
+ img.setAttribute('src', signedUrl);
300
+ }
301
+ processedCount++;
302
+
303
+ // 所有图片处理完成后,更新内容
304
+ if (processedCount === totalImages) {
305
+ this.fileText = tempDiv.innerHTML;
306
+ this.loading = false;
307
+ document.getElementById('drawer_content_pre').style.backgroundImage = 'none';
308
+ this.$nextTick(() => {
309
+ this.setColor()
310
+ })
311
+ this.$emit('loadingSuccess');
312
+ }
313
+ });
314
+ } else {
315
+ // 非OSS图片,直接跳过
316
+ processedCount++;
317
+ if (processedCount === totalImages) {
318
+ this.fileText = tempDiv.innerHTML;
319
+ this.loading = false;
320
+ document.getElementById('drawer_content_pre').style.backgroundImage = 'none';
321
+ this.$nextTick(() => {
322
+ this.setColor()
323
+ })
324
+ this.$emit('loadingSuccess');
325
+ }
326
+ }
327
+ });
328
+ },
329
+
330
+ // 获取图片的签名URL
331
+ getSignedImageUrl(imgSrc, callback) {
332
+ // 检查是否是相对路径,如果是则拼接完整URL
333
+ let fullImgUrl = imgSrc;
334
+ if (imgSrc.startsWith('/') || !imgSrc.startsWith('http')) {
335
+ // 从当前URL中提取域名
336
+ const urlObj = new URL(this.url);
337
+ fullImgUrl = urlObj.origin + (imgSrc.startsWith('/') ? imgSrc : '/' + imgSrc);
338
+ }
339
+
340
+ // 调用获取临时证书的API
341
+ this.$http.post('/knowledge-api/knowledge/getTemporaryCertificate', {
342
+ "fileInOssPath": fullImgUrl
343
+ }, {
344
+ params: { needEncrypt: false }
345
+ }).then(res => {
346
+ if (res.data.code === '0') {
347
+ callback(res.data.data);
348
+ } else {
349
+ console.error('获取图片签名失败:', res.data.message);
350
+ callback(null);
351
+ }
352
+ }).catch(err => {
353
+ console.error('获取图片签名失败:', err);
354
+ callback(null);
355
+ });
356
+ },
221
357
  },
222
358
  mounted() {
223
359
  this.getLocationInfo();
@@ -369,6 +505,48 @@ export default {
369
505
  }
370
506
  }
371
507
  }
508
+ .preview_iframe_html {
509
+ width: 100%;
510
+ height: 100%;
511
+ overflow-y: scroll;
512
+ text-align: left;
513
+ box-sizing: border-box;
514
+ padding: 16px;
515
+
516
+ /deep/.lake-content {
517
+ margin-left: 10px;
518
+ }
519
+
520
+ /deep/a:link {
521
+ color: #0000ee !important;
522
+ }
523
+
524
+ /deep/a:visited {
525
+ color: #0000ee !important;
526
+ }
527
+
528
+ /deep/a:hover {
529
+ color: #0000ee !important;
530
+ }
531
+
532
+ /deep/a:active {
533
+ color: #0000ee !important;
534
+ }
535
+
536
+ /deep/li:not(.rich-text-li),
537
+ ol:not(.list-paddingleft-2),
538
+ ul:not(.list-paddingleft-2) {
539
+ list-style-type: auto !important;
540
+ }
541
+
542
+ /deep/img {
543
+ width: auto;
544
+ }
545
+
546
+ /deep/.ne-table {
547
+ width: 100% !important;
548
+ }
549
+ }
372
550
  .animation {
373
551
  animation-name: highlight;
374
552
  animation-duration: 4s;
@@ -106,7 +106,7 @@
106
106
  <new-position-preview ref="newPositionPreview"
107
107
  v-else-if="tagIds && tagIds.length != 0 && newVersion && newFileType !== 'PPT' && newFileType !== 'PPTX' && newFileType !== 'IMAGE'"
108
108
  :textWatermarkStr="textWatermarkStr"
109
- :knowledgeId="knowledgeId" :tagIds="tagIds" :url="previewHref"></new-position-preview>
109
+ :knowledgeId="knowledgeId" :tagIds="tagIds" :url="previewHref" :previewOssPath="previewOssPath"></new-position-preview>
110
110
  <template v-else>
111
111
  <div v-if="fileType == 'VIDEO'" style="width: 100%;height: 100%">
112
112
  <video :src="url" controls width="100%;" height="98%"></video>