| 
					
				 | 
			
			
				@@ -123,22 +123,25 @@ export class Tab2Page { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ${userPrompt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         `); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      onMessage:(chat:FmodeChat,message:FmodeChatMessage)=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        console.log("onMessage",message) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        let content:any = message?.content 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(typeof content === "string"){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          messages.push(content); // 将新消息添加到 messages 数组中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            consult.set({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              content: messages.join("\n"), // 将所有消息合并为一个字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          // 在此之前检查 consult 对象是否有效 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          console.log("准备保存聊天记录:", consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          consult.save().then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              console.log("聊天记录已保存"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }).catch((error) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              console.error("保存聊天记录时出错:", error); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      onMessage: (chat: FmodeChat, message: FmodeChatMessage) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log("onMessage", message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 直接通过 chat.messageList 获取所有消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const allMessages = chat.messageList.map(msg => msg.content).join("\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 更新 consult 对象的内容 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        consult.set({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            content: allMessages, // 将所有消息合并为一个字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 在此之前检查 consult 对象是否有效 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log("准备保存聊天记录:", consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 仅在内容发生变化时保存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        consult.save().then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          console.log("聊天记录已保存"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }).catch((error) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          console.error("保存聊天记录时出错:", error); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // chat?.chatSession?.id 本次会话的 chatId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         onChatSaved:(chat:FmodeChat)=>{ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -148,15 +151,9 @@ export class Tab2Page { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     openChatPanelModal(this.modalCtrl,options) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  matchedCounselor: { name: string; specialty: string } | null = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  matchedCounselor: { name: string; specialty: string } | null = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   async goChat(chatcompanion:CloudObject) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // 验证用户登录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let currentUser = new CloudUser(); 
			 |