Browse Source

首页会话功能流式数据展示完成

bobo04052021@163.com 3 weeks ago
parent
commit
626d909b09
2 changed files with 18 additions and 11 deletions
  1. 2 2
      src/layouts/default/layout.data.ts
  2. 16 9
      src/layouts/default/sider/bottomSider2.vue

+ 2 - 2
src/layouts/default/layout.data.ts

@@ -1,7 +1,7 @@
 export const noHeadeLink = ['/micro-vent-3dModal/dashboard/analysis', '/model3D/home', '/fileManager/cad-viewer'];
 export const noSiderLink = ['/fileManager/cad-viewer', '/micro-vent-3dModal/dashboard/bd/fire', '/micro-vent-3dModal/dashboard/bd/dust'];
-// export const noChatLink = ['/micro-vent-3dModal/modelchannel/model3D/home'];
-export const noChatLink = [];
+export const noChatLink = ['/micro-vent-3dModal/modelchannel/model3D/home'];
+// export const noChatLink = [];
 export const noContentLink = ['/micro-vent-3dModal/modelchannel/model3D/home'];
 export const ThemeModel = {
   theme5_5: {

+ 16 - 9
src/layouts/default/sider/bottomSider2.vue

@@ -93,8 +93,12 @@
                 <div v-else class="system-message">
                   <div class="answerIcon"></div>
                   <div class="answer-message">
-                    <div v-if="message.Origintype == 'thinking'" class="thinking-text" v-html="formatMessage(message.content)"></div>
-                    <div v-else-if="message.Origintype == 'text'" class="answer-text" v-html="formatMessage(message.content)"></div>
+                    <div v-if="message.Origintype === 'thinking'">
+                      <span :id="'thinking-' + message.id" class="thinking-text" v-html="formatMessage(message.content)"></span>
+                    </div>
+                    <div v-if="message.Origintype1 === 'text'">
+                      <span :id="'text-' + message.id" class="answer-text" v-html="formatMessage(message.content1)"></span>
+                    </div>
                   </div>
                 </div>
               </div>
@@ -154,10 +158,12 @@ interface ListItem {
 let userId = unref(userStore.getUserInfo).id;
 // const userId = ref(0);
 type MessageItem = {
-  id: string; // 唯一标识(可用时间戳生成)
+  id: string; // 唯一标识时间戳
   type: 'user' | 'system';
   content: string;
-  Origintype: string;
+  content1?: string;
+  Origintype?: string;
+  Origintype1?: string;
   timestamp: number; // 排序依据
 };
 const messageList = ref<MessageItem[]>([]);
@@ -307,7 +313,6 @@ const sendMessage1 = async () => {
     id: `user_${Date.now()}`,
     type: 'user',
     content: inputText.value,
-    Origintype: '',
     timestamp: Date.now(),
   });
   // 构造请求参数
@@ -341,6 +346,7 @@ const sendMessage1 = async () => {
       id: `response_${Date.now()}`,
       type: 'response', // 消息类型
       content: '',
+      content1: '',
       Origintype: '',
       timestamp: Date.now(), // 时间戳用来排序
     };
@@ -379,10 +385,10 @@ const sendMessage1 = async () => {
             }
             if (data.type === 'text') {
               // 找到当前消息对象并更新 content
-              const targetMessage1 = messageList.value.find((msg) => msg.id === newMessage.id);
-              if (targetMessage1) {
-                targetMessage1.content += data.content; // 追加内容
-                targetMessage1.Origintype = data.type;
+              const targetMessage = messageList.value.find((msg) => msg.id === newMessage.id);
+              if (targetMessage) {
+                targetMessage.content1 += data.content; // 追加内容
+                targetMessage.Origintype1 = data.type;
                 scrollToBottom();
               }
             }
@@ -465,6 +471,7 @@ async function sessionsHistory(id: string) {
           id: `system_${Date.now()}`,
           type: 'system',
           content: item.content,
+          content1: item.thinking_content,
           timestamp: Date.now(),
         });
       }