Browse Source

ai应用支持img显示

SanHQin 3 days ago
parent
commit
b65c1284cf

+ 6 - 0
src/views/Student/components/AIWorkModal.vue

@@ -116,6 +116,7 @@ const processContent = async (content: string) => {
           // 如果已经包含html标签则不再渲染
           if (!/^(\s*<[^>]+>.*<\/[^>]+>\s*|<[^>]+\/>\s*)$/s.test(item2.content.trim())) {
             item2.content = md.render(item2.content)
+            item2.content = item2.content.replace(/&lt;/g, '<').replace(/&quot;/g, '"').replace(/&gt;/g, '>')
           }
         })
       }
@@ -202,6 +203,11 @@ watch(
 	background-color: #fff;
 }
 
+
+.na_m_i_content :deep(img){
+  max-width: 100%;
+}
+
 .messageNode{
   width: 100%;
   height: auto;

+ 13 - 0
src/views/Student/components/choiceQuestionDetailDialog.vue

@@ -414,9 +414,19 @@ const lookWorkData = computed(() => {
     const _workFind = processedWorkArray.value.find(
       (i: any) => i.id === lookWorkDetail.value
     )
+
+    _workFind.content.forEach((i:any) => {
+      i.messages.forEach((i2:any) => {
+        // 转字符  例如&lt; 》 <   &quot; 》 "  &gt; 》 >
+        i2.content = i2.content.replace(/&lt;/g, '<').replace(/&quot;/g, '"').replace(/&gt;/g, '>')
+      })
+    })
     if (_workFind) {
       _result = _workFind
     }
+
+
+    console.log(_workFind)
   }
 
   return _result
@@ -1153,6 +1163,9 @@ onUnmounted(() => {
             box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.1);
             border-radius: 0 0 12px 12px;
             background-color: #fff;
+            :deep(img){
+              max-width: 100%;
+            }
           }
 
           .messageNode {