|
@@ -85,7 +85,7 @@ export class Tab2Page {
|
|
|
|
|
|
localStorage.setItem("company", "E4KpGvTEto");
|
|
|
|
|
|
- this.consult = new CloudObject("ChatRecord");
|
|
|
+ let consult = new CloudObject("ChatRecord");
|
|
|
|
|
|
let now = new Date();
|
|
|
let dateStr = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
|
|
@@ -124,14 +124,11 @@ export class Tab2Page {
|
|
|
console.log("onMessage", message);
|
|
|
let content: any = message?.content;
|
|
|
|
|
|
- this.consult.set({
|
|
|
+ consult.set({
|
|
|
content: chat.messageList,
|
|
|
});
|
|
|
|
|
|
- this.consult.save().then(() => {
|
|
|
-
|
|
|
- this.generateReport();
|
|
|
- });
|
|
|
+ consult.save();
|
|
|
},
|
|
|
onChatSaved: (chat: FmodeChat) => {
|
|
|
console.log("onChatSaved", chat, chat?.chatSession, chat?.chatSession?.id);
|
|
@@ -140,50 +137,51 @@ export class Tab2Page {
|
|
|
openChatPanelModal(this.modalCtrl, options);
|
|
|
}
|
|
|
|
|
|
-async generateReport() {
|
|
|
- if (!this.consult) {
|
|
|
- console.error('Consult对象未定义');
|
|
|
- return;
|
|
|
- }
|
|
|
- let chatContent = this.consult.get('content') || [];
|
|
|
-
|
|
|
- let report = "聊天记录报告\n\n";
|
|
|
- if (chatContent.length === 0) {
|
|
|
- report += "没有聊天记录。\n\n";
|
|
|
- } else {
|
|
|
- chatContent.forEach((message: any, index: number) => {
|
|
|
- report += `消息 ${index + 1}:\n\n`;
|
|
|
- report += `内容: ${message.content}\n\n`;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
- const sentiment = this.analyzeSentiment(message.content);
|
|
|
- report += `心晴分析: ${sentiment}\n\n`;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- await this.showReportModal(report);
|
|
|
- }
|
|
|
- analyzeSentiment(text:String) {
|
|
|
-
|
|
|
- if (text.includes("好") || text.includes("喜欢")) {
|
|
|
- return "积极";
|
|
|
- } else if (text.includes("坏") || text.includes("不喜欢")) {
|
|
|
- return "消极";
|
|
|
- } else {
|
|
|
- return "中性";
|
|
|
- }
|
|
|
- }
|
|
|
- extractKeywords(text:String): string[] {
|
|
|
-
|
|
|
- return text.split(/\s+/).filter(word => word.length > 0);
|
|
|
- }
|
|
|
- async showReportModal(report: string) {
|
|
|
- const modal = await this.modalCtrl.create({
|
|
|
- component: ReportModalComponent,
|
|
|
- componentProps: { report }
|
|
|
- });
|
|
|
- return await modal.present();
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
questions = [
|
|
|
{
|
|
|
title: '如何应对焦虑?',
|