소스 검색

编辑器中只查看用户反馈

zq 2 일 전
부모
커밋
0e41b9068f
2개의 변경된 파일29개의 추가작업 그리고 6개의 파일을 삭제
  1. 27 4
      src/components/CommonPreview.vue
  2. 2 2
      src/views/book/courseware/preview/CoursewarePreview.vue

+ 27 - 4
src/components/CommonPreview.vue

@@ -390,10 +390,10 @@
                 <el-divider class="mt10" />
                 <span v-html="item.feedBack"></span>
                 <div>
-                  <el-button type="text" class="el-icon-edit" @click="handEditFeedback(item)"> 编辑</el-button>
+                  <!-- <el-button type="text" class="el-icon-edit" @click="handEditFeedback(item)"> 编辑</el-button>
                   <el-divider direction="vertical" />
                   <el-button type="text" class="el-icon-delete" @click="handDelFeedback(item.id)"> 删除</el-button>
-                  <el-divider direction="vertical" />
+                  <el-divider direction="vertical" /> -->
                   <el-button type="text" class="el-icon-place" @click="handleLocation(item, 13)"> 定位</el-button>
                 </div>
               </li>
@@ -1405,6 +1405,29 @@ export default {
       if (this.dialogType === 1) return this.delNote(id);
       if (this.dialogType === 2) return this.delFeedback(id);
     },
+
+    /**
+     * 为HTML内容中的图片添加最大宽度限制
+     * @param {string} html - HTML字符串
+     * @returns {string} - 处理后的HTML字符串
+     */
+    addImageMaxWidth(html) {
+      if (!html) return html;
+
+      const regex = /<img([^>]*)>/gi;
+      return html.replace(regex, (match, attributes) => {
+        if (attributes.includes('style=')) {
+          return match.replace(/style=["']([^"']*)["']/i, (styleMatch, styleValue) => {
+            if (styleValue.includes('max-width')) {
+              return styleMatch;
+            }
+            return `style="${styleValue}; max-width: 200px;"`;
+          });
+        }
+        return `<img${attributes} style="max-width: 200px;">`;
+      });
+    },
+
     /**
      * 获取笔记列表
      * @param {Object} params - 参数对象
@@ -1424,7 +1447,7 @@ export default {
                 startIndex: n.startIndex,
                 endIndex: n.endIndex,
                 text: n.text,
-                note: n.note,
+                note: this.addImageMaxWidth(n.note),
               };
               this.allNoteList.push(obj);
             }
@@ -1604,7 +1627,7 @@ export default {
                 startIndex: n.startIndex,
                 endIndex: n.endIndex,
                 text: n.text,
-                feedBack: n.feedBack,
+                feedBack: this.addImageMaxWidth(n.feedBack),
               };
               this.allFeedbackList.push(obj);
             }

+ 2 - 2
src/views/book/courseware/preview/CoursewarePreview.vue

@@ -84,8 +84,8 @@
         <span class="button" @click="setCollect"><SvgIcon icon-class="sidebar-collect" size="14" /> 收藏 </span>
         <span class="line"></span>
         <span class="button" @click="setTranslate"> <SvgIcon icon-class="sidebar-translate" size="14" /> 翻译</span>
-        <span class="line"></span>
-        <span class="button" @click="setFeedback"> <SvgIcon icon-class="sidebar-feedback" size="14" /> 用户反馈</span>
+        <!-- <span class="line"></span>
+        <span class="button" @click="setFeedback"> <SvgIcon icon-class="sidebar-feedback" size="14" /> 用户反馈</span> -->
       </template>
     </div>
   </div>