Forráskód Böngészése

fix: 修复智能数据历史记录对话内容不显示的问题

zhupei 1 éve
szülő
commit
cab87593c8

+ 6 - 0
src/components/DialogWrap.vue

@@ -572,6 +572,12 @@ export default defineComponent({
 
     onMounted(() => {
       scrollToEnd();
+      
+      // 应用代码高亮效果
+      setTimeout(() => {
+        applyHighLight();
+      });
+
       /**
        * 应用引用效果
        * 答案中 引用图标(感叹号)点击时,浮层显示引用内容

+ 28 - 1
src/components/dialog-wrap/format-dialog-item.js

@@ -8,7 +8,7 @@ const replaceCode = (text, index) => {
 export default function formatDialogItem(item, index) {
     const client_id = generateClientUniqueId(JSON.stringify(item));
 
-    return {
+    const result = {
         /**
          * 客户端生成的ID
          * 此数据作为列表唯一的key
@@ -47,5 +47,32 @@ export default function formatDialogItem(item, index) {
                 file_url: `http://${window.location.hostname}${port}${item.file_url}`,
             }
         })[0] : null,
+    };
+
+    if (item.code) {
+        result.code = `
+              <pre>
+              <code class="hljs language-python">
+${item.code}
+              </code>
+              </pre>
+        `
+    }
+
+    if (item.sql) {
+        result.sql = `
+              <pre>
+              <code class="hljs language-sql">
+${item.sql}
+              </code>
+              </pre>
+              `
     }
+
+    if (item.image_url) {
+        const port = window.location.port ? `:${window.location.port}` : '';
+        result.image_url = `http://${window.location.hostname}${port}${item.image_url}`
+    }
+
+    return result;
 }