askbot-dragon 1.8.30-beta → 1.8.32-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.30-beta",
3
+ "version": "1.8.32-beta",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -90,11 +90,11 @@ function newInitWaterMark(elId, textValue) {
90
90
 
91
91
  watermark_y_space: 60, //水印y轴间隔
92
92
 
93
- watermark_color: "black", //水印字体颜色
93
+ watermark_color: "#949494", //水印字体颜色
94
94
 
95
- watermark_alpha: 0.3, //水印透明度
95
+ watermark_alpha: 0.15, //水印透明度
96
96
 
97
- watermark_fontsize: "12px", //水印字体大小
97
+ watermark_fontsize: "14px", //水印字体大小
98
98
 
99
99
  watermark_font: "微软雅黑", //水印字体
100
100
 
@@ -19,6 +19,7 @@ export default {
19
19
  return{
20
20
  colors: ['#E3EBFF', '#FFF5DC', '#FFE8D8','#D6F3EA','#FFF1C3'],
21
21
  html:"",
22
+ loading:false
22
23
  }
23
24
  },
24
25
  props:{
@@ -55,20 +56,8 @@ export default {
55
56
  }).then(res => {
56
57
  if(res.data) {
57
58
  this.$http.get(res.data).then(res => {
58
- this.html = res.data;
59
- let drawer = document.getElementById('drawer_content_pre')
60
- if (drawer){
61
- drawer.style.backgroundImage = 'none';
62
- drawer.style.overflowX = 'hidden';
63
- }
64
- this.$nextTick(() => {
65
- this.setColor();
66
- setTimeout(() => {
67
- if (this.textWatermarkStr){
68
- newInitWaterMark('docHtml',this.textWatermarkStr)
69
- }
70
- },500)
71
- })})
59
+ this.processImageUrls(res.data);
60
+ })
72
61
  }
73
62
  })
74
63
 
@@ -110,6 +99,118 @@ export default {
110
99
  this.$parent.scrollToParagraph('first')
111
100
  },500)
112
101
  },
102
+ // 处理HTML内容中的图片地址,为OSS图片添加签名
103
+ processImageUrls(htmlContent) {
104
+ // 创建临时DOM元素来解析HTML
105
+ const tempDiv = document.createElement('div');
106
+ tempDiv.innerHTML = htmlContent;
107
+
108
+ // 查找所有图片标签
109
+ const imgTags = tempDiv.querySelectorAll('img');
110
+ let processedCount = 0;
111
+ let totalImages = imgTags.length;
112
+
113
+ if (totalImages === 0) {
114
+ // 没有图片,直接显示内容
115
+ this.html = htmlContent;
116
+ this.loading = false;
117
+ let drawer = document.getElementById('drawer_content_pre')
118
+ if (drawer){
119
+ drawer.style.backgroundImage = 'none';
120
+ drawer.style.overflowX = 'hidden';
121
+ }
122
+ this.$nextTick(() => {
123
+ this.setColor();
124
+ setTimeout(() => {
125
+ if (this.textWatermarkStr){
126
+ newInitWaterMark('docHtml',this.textWatermarkStr)
127
+ }
128
+ },500)
129
+ })
130
+ return;
131
+ }
132
+
133
+ // 处理每个图片地址
134
+ imgTags.forEach((img) => {
135
+ const imgSrc = img.getAttribute('src');
136
+ if (imgSrc && (imgSrc.includes('aliyuncs') || imgSrc.includes('oss-'))) {
137
+ // 为OSS图片获取签名URL
138
+ this.getSignedImageUrl(imgSrc, (signedUrl) => {
139
+ if (signedUrl) {
140
+ img.setAttribute('src', signedUrl);
141
+ }
142
+ processedCount++;
143
+
144
+ // 所有图片处理完成后,更新内容
145
+ if (processedCount === totalImages) {
146
+ this.html = tempDiv.innerHTML;
147
+ this.loading = false;
148
+ let drawer = document.getElementById('drawer_content_pre')
149
+ if (drawer){
150
+ drawer.style.backgroundImage = 'none';
151
+ drawer.style.overflowX = 'hidden';
152
+ }
153
+ this.$nextTick(() => {
154
+ this.setColor();
155
+ setTimeout(() => {
156
+ if (this.textWatermarkStr){
157
+ newInitWaterMark('docHtml',this.textWatermarkStr)
158
+ }
159
+ },500)
160
+ })
161
+ }
162
+ });
163
+ } else {
164
+ // 非OSS图片,直接跳过
165
+ processedCount++;
166
+ if (processedCount === totalImages) {
167
+ this.html = tempDiv.innerHTML;
168
+ this.loading = false;
169
+ let drawer = document.getElementById('drawer_content_pre')
170
+ if (drawer){
171
+ drawer.style.backgroundImage = 'none';
172
+ drawer.style.overflowX = 'hidden';
173
+ }
174
+ this.$nextTick(() => {
175
+ this.setColor();
176
+ setTimeout(() => {
177
+ if (this.textWatermarkStr){
178
+ newInitWaterMark('docHtml',this.textWatermarkStr)
179
+ }
180
+ },500)
181
+ })
182
+ }
183
+ }
184
+ });
185
+ },
186
+
187
+ // 获取图片的签名URL
188
+ getSignedImageUrl(imgSrc, callback) {
189
+ // 检查是否是相对路径,如果是则拼接完整URL
190
+ let fullImgUrl = imgSrc;
191
+ if (imgSrc.startsWith('/') || !imgSrc.startsWith('http')) {
192
+ // 从当前URL中提取域名
193
+ const urlObj = new URL(this.url);
194
+ fullImgUrl = urlObj.origin + (imgSrc.startsWith('/') ? imgSrc : '/' + imgSrc);
195
+ }
196
+
197
+ // 调用获取临时证书的API
198
+ this.$http.post('/knowledge-api/knowledge/getTemporaryCertificate', {
199
+ "fileInOssPath": fullImgUrl
200
+ }, {
201
+ params: { needEncrypt: false }
202
+ }).then(res => {
203
+ if (res.data.code === '0') {
204
+ callback(res.data.data);
205
+ } else {
206
+ console.error('获取图片签名失败:', res.data.message);
207
+ callback(null);
208
+ }
209
+ }).catch(err => {
210
+ console.error('获取图片签名失败:', err);
211
+ callback(null);
212
+ });
213
+ },
113
214
  },
114
215
  watch:{
115
216
  html_result:{
@@ -18,9 +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
+ <template v-else-if="fileType === 'URL'">
22
+ <div class="preview_iframe_html" id="preview_iframe_html" style="text-align:left" v-html="fileText"></div>
23
+ </template>
24
24
  </div>
25
25
  <template v-if="splitParagraph.length > 1 && fileType !== 'XLS' && fileType !== 'XLSX'">
26
26
  <div class="btn_footer" v-if="!isPC">
@@ -42,6 +42,7 @@ import DocView from "./docView";
42
42
  import ExcelView from "./excelView";
43
43
  import PdfView from "./pdfView";
44
44
  import MarkDownView from "./markDownView";
45
+ import { newInitWaterMark } from "../../assets/js/common";
45
46
  export default {
46
47
  name: "newPositionPreview",
47
48
  components: { MarkDownView, PdfView, ExcelView, DocView },
@@ -287,6 +288,9 @@ export default {
287
288
  dom.style.backgroundImage = 'none';
288
289
  }
289
290
  this.setColor()
291
+ if (this.textWatermarkStr){
292
+ newInitWaterMark('preview_iframe_html',this.textWatermarkStr)
293
+ }
290
294
  })
291
295
  this.$emit('loadingSuccess');
292
296
  return;
@@ -313,6 +317,9 @@ export default {
313
317
  dom.style.backgroundImage = 'none';
314
318
  }
315
319
  this.setColor()
320
+ if (this.textWatermarkStr){
321
+ newInitWaterMark('preview_iframe_html',this.textWatermarkStr)
322
+ }
316
323
  })
317
324
  this.$emit('loadingSuccess');
318
325
  }
@@ -329,6 +336,9 @@ export default {
329
336
  dom.style.backgroundImage = 'none';
330
337
  }
331
338
  this.setColor()
339
+ if (this.textWatermarkStr){
340
+ newInitWaterMark('preview_iframe_html',this.textWatermarkStr)
341
+ }
332
342
  })
333
343
  this.$emit('loadingSuccess');
334
344
  }