ソースを参照

修改ai回答

yangg 4 ヶ月 前
コミット
9c4c43998c

ファイルの差分が大きいため隠しています
+ 0 - 0
dist/index.html


ファイルの差分が大きいため隠しています
+ 0 - 0
dist/static/css/app.d43657da.css


ファイルの差分が大きいため隠しています
+ 0 - 0
dist/static/css/chunk-0abe3c10.74e755ce.css


ファイルの差分が大きいため隠しています
+ 0 - 0
dist/static/js/app.045e9aa3.js


ファイルの差分が大きいため隠しています
+ 0 - 0
dist/static/js/app.0def177e.js


ファイルの差分が大きいため隠しています
+ 0 - 0
dist/static/js/chunk-0abe3c10.ad088129.js


ファイルの差分が大きいため隠しています
+ 0 - 0
dist/static/js/chunk-eded1796.3cd763e6.js


+ 34 - 0
src/components/ai.vue

@@ -669,6 +669,7 @@ export default {
         html: true,
         breaks: true,
         linkify: true,
+        tables: true,    // 启用表格支持
       });
 
       // 自定义链接渲染规则
@@ -1265,4 +1266,37 @@ textarea {
   color: #333;
   word-break: break-all;
 }
+
+.message-text ::v-deep table {
+  border-collapse: collapse;
+  width: 100%;
+  margin: 10px 0;
+  font-size: 14px;
+}
+
+.message-text ::v-deep th,
+.message-text ::v-deep td {
+  border: 1px solid #dcdfe6;
+  padding: 8px 12px;
+  text-align: left;
+}
+
+.message-text ::v-deep th {
+  background-color: #f5f7fa;
+  color: #606266;
+  font-weight: 500;
+}
+
+.message-text ::v-deep tr:nth-child(even) {
+  background-color: #fafafa;
+}
+
+.message-text ::v-deep tr:hover {
+  background-color: #f5f7fa;
+}
+
+/* 确保表格在移动设备上可以水平滚动 */
+.message-text {
+  overflow-x: auto;
+}
 </style>

+ 33 - 0
src/components/webAi/css/ChatBox.css

@@ -491,4 +491,37 @@ textarea {
 
 ::v-deep .el-input-number--medium{
   width: 150px;
+}
+
+.message-text ::v-deep table {
+  border-collapse: collapse;
+  width: 100%;
+  margin: 10px 0;
+  font-size: 14px;
+}
+
+.message-text ::v-deep th,
+.message-text ::v-deep td {
+  border: 1px solid #dcdfe6;
+  padding: 8px 12px;
+  text-align: left;
+}
+
+.message-text ::v-deep th {
+  background-color: #f5f7fa;
+  color: #606266;
+  font-weight: 500;
+}
+
+.message-text ::v-deep tr:nth-child(even) {
+  background-color: #fafafa;
+}
+
+.message-text ::v-deep tr:hover {
+  background-color: #f5f7fa;
+}
+
+/* 确保表格在移动设备上可以水平滚动 */
+.message-text {
+  overflow-x: auto;
 }

+ 2 - 1
src/components/webAi/js/ChatBox.js

@@ -1011,7 +1011,8 @@ handleLinkClick(event) {
       const md = new MarkdownIt({
         html: true,
         breaks: true,
-        linkify: true
+        linkify: true,
+        tables: true,    // 启用表格支持
       });
 
       // 自定义链接渲染规则

+ 48 - 16
src/views/login/aiIndex.vue

@@ -612,23 +612,21 @@ export default {
 
     async handleResponse(value, existingMessage) {
       const data = value.data.answer;
-
+      
       existingMessage.messageType = data;
-      /* existingMessage.time = data.timestamp; this.$route.name !== "ai" &&*/
       existingMessage.message = "";
 
       let mainText = data;
-      let sourceText = "";
+      let sourceText = '';
 
       if (this.minioUrls && this.minioUrls.length > 0) {
-        sourceText =
-          "\n\n<div class='source-section'><h3>相关资料来源:</h3><ol>";
+        sourceText = "\n\n<div class='source-section'><h3>相关资料来源:</h3><ol>";
         this.minioUrls.forEach((url, index) => {
           sourceText += `<li><a href="${url.url}" target="_blank" class="source-link">${url.object_name}</a></li>`;
         });
         sourceText += "</ol></div>";
       }
-      console.log(mainText);
+
       // 先进行主要内容的打字效果
       await this.typeMessage(existingMessage, mainText);
 
@@ -660,31 +658,32 @@ export default {
     },
     renderMarkdown(rawMarkdown) {
       const md = new MarkdownIt({
-        html: true,
-        breaks: true,
-        linkify: true,
+        html: true,      // 启用 HTML 标签支持
+        breaks: true,    // 转换换行符为 <br>
+        linkify: true,   // 自动转换 URL 为链接
+        tables: true,    // 启用表格支持
       });
 
       // 自定义链接渲染规则
       md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
         const token = tokens[idx];
-        const hrefIndex = token.attrIndex("href");
+        const hrefIndex = token.attrIndex('href');
         const href = token.attrs[hrefIndex][1];
         return `<span class="custom-link" data-href="${href}">`;
       };
 
-      md.renderer.rules.link_close = () => "</span>";
+      md.renderer.rules.link_close = () => '</span>';
 
       const renderedHtml = md.render(rawMarkdown);
 
       // 使用 setTimeout 来确保 DOM 更新后再添加事件监听器
       setTimeout(() => {
-        const links = document.querySelectorAll(".custom-link");
-        links.forEach((link) => {
-          link.addEventListener("click", (e) => {
+        const links = document.querySelectorAll('.custom-link');
+        links.forEach(link => {
+          link.addEventListener('click', (e) => {
             e.preventDefault();
-            const href = link.getAttribute("data-href");
-            window.open(href, "_blank");
+            const href = link.getAttribute('data-href');
+            window.open(href, '_blank');
           });
         });
       }, 0);
@@ -1270,4 +1269,37 @@ textarea {
 .document-link:hover {
   background: rgba(60, 186, 222, 0.1);
 }
+
+.message-text ::v-deep table {
+  border-collapse: collapse;
+  width: 100%;
+  margin: 10px 0;
+  font-size: 14px;
+}
+
+.message-text ::v-deep th,
+.message-text ::v-deep td {
+  border: 1px solid #dcdfe6;
+  padding: 8px 12px;
+  text-align: left;
+}
+
+.message-text ::v-deep th {
+  background-color: #f5f7fa;
+  color: #606266;
+  font-weight: 500;
+}
+
+.message-text ::v-deep tr:nth-child(even) {
+  background-color: #fafafa;
+}
+
+.message-text ::v-deep tr:hover {
+  background-color: #f5f7fa;
+}
+
+/* 确保表格在移动设备上可以水平滚动 */
+.message-text {
+  overflow-x: auto;
+}
 </style>

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません