焦怡璇 hace 1 año
padre
commit
cc46fdecd6

+ 77 - 26
README.md

@@ -134,39 +134,90 @@ Questions "1" -- "n" Option
 
 
 ```plantuml
-@startuml 
-left to right direction
-
-actor User
-actor AI
-
+@startuml
+start
+:用户进入注册模块;
+:用户输入账号、密码及二次密码;
+if (注册信息有效?) then (yes)
+    :注册成功;
+    :用户返回登录界面;
+else (no)
+    :注册失败提示;
+    :用户重新输入信息;
+endif
+:用户输入账号和密码;
+if (登录信息有效?) then (yes)
+    :登录成功;
+    :进入主界面;
+else (no)
+    :登录失败提示;
+    :用户重新输入信息;
+endif
+stop
+@enduml
+```
 
-rectangle "性格测试" {
-  User --> (做选择题)
-  (做选择题) --> (分析 MBTI 性格)
-  (分析 MBTI 性格) --> (保存结果)
-}
 
-rectangle "聊天" {
-  User --> (与 AI 聊天)
-  (与 AI 聊天) --> (保存聊天记录)
-  (保存聊天记录) --> (分析情绪)
-}
+```plantuml
+@startuml
+start
+:用户登录后选择MBTI性格检测功能;
+:系统展示测试题;
+
+repeat
+    :用户点击选项;
+repeat while (还有测试题?)
+
+:用户完成测试题;
+:系统生成MBTI测试结果;
+:用户查看测试结果;
+stop
+@enduml
+```
 
-rectangle "报告生成" {
-  User --> (生成心理报告)
-  (生成心理报告) --> (调用 MBTI 和情绪)
-}
 
-rectangle "反馈" {
-  User --> (提交反馈)
-}
+```plantuml
+@startuml
+start
+:用户进入AI聊天模块;
+:用户开始与AI进行实时对话;
+
+repeat
+    :用户结束内容;
+    :AI对用户输入聊天内容进行情绪分析;
+    :记录聊天时间、内容和心情指数;
+repeat while (用户继续聊天?)
+
+:用户结束聊天;
+:系统保存聊天记录;
+stop
+@enduml
+```
 
-rectangle "评价" {
-  User --> (提交评价)
-}
+```plantuml
+@startuml
+start
+:系统收集MBTI测试结果和聊天情绪分析数据;
+:生成个性化心理分析报告;
+:提供心理健康建议和治疗方法;
+:用户查看个性化心理报告;
+stop
+@enduml
+```
 
+```plantuml
+@startuml
+start
+:用户在反馈模块提交问题;
+:系统记录用户反馈信息;
+:用户查看其他用户评价;
+:用户提交自己的星级评价;
+:系统记录用户评价并上传;
+stop
 @enduml
 ```
 
 
+
+
+

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 940 - 15
heartvoice-app/package-lock.json


+ 1 - 0
heartvoice-app/package.json

@@ -44,6 +44,7 @@
     "@angular/cli": "18.2.12",
     "@angular/compiler-cli": "^18.0.0",
     "@angular/language-service": "^18.0.0",
+    "@compodoc/compodoc": "^1.1.26",
     "@ionic/angular-toolkit": "^11.0.1",
     "@types/jasmine": "~5.1.0",
     "@typescript-eslint/eslint-plugin": "^6.0.0",

+ 6 - 6
heartvoice-app/src/app/gexinhualiaotian/gexinhualiaotian.component.html

@@ -1,14 +1,14 @@
-<ion-header>
+<!-- <ion-header>
   <ion-toolbar>
     <ion-title>开始聊天</ion-title>
     <ion-buttons slot="start">
       <ion-button routerLink="/my-page">返回</ion-button>
     </ion-buttons>
   </ion-toolbar>
-</ion-header>
+</ion-header> -->
+
+<!-- <ion-content>
 
-<ion-content>
-  <!-- 聊天记录区域 -->
   <ion-list>
     <ion-item *ngFor="let message of messages" [ngClass]="{'user-message': message.sender === 'user', 'ai-message': message.sender === 'ai'}">
       <ion-label>{{ message.content }}</ion-label>
@@ -16,7 +16,7 @@
   </ion-list>
 </ion-content>
 
-<!-- 用户输入框 -->
+
 <ion-footer>
   <ion-toolbar>
     <ion-row>
@@ -28,4 +28,4 @@
       </ion-col>
     </ion-row>
   </ion-toolbar>
-</ion-footer>
+</ion-footer> -->

+ 89 - 85
heartvoice-app/src/app/gexinhualiaotian/gexinhualiaotian.component.ts

@@ -1,9 +1,11 @@
 import { Component, OnInit } from '@angular/core';
-import { IonButton, IonContent, IonHeader, IonToolbar, IonTitle, IonInput, IonItem, IonLabel, IonList, IonFooter, IonRow, IonCol, IonButtons } from '@ionic/angular/standalone';
+import { IonButton, IonContent, IonHeader, IonToolbar, IonTitle, IonInput, IonItem, IonLabel, IonList, IonFooter, IonRow, IonCol, IonButtons, ModalController } from '@ionic/angular/standalone';
 import { FmodeChatCompletion } from 'fmode-ng';
 import { FormsModule } from '@angular/forms';
 import { CommonModule } from '@angular/common'; // 导入 CommonModule
 import { CloudObject, CloudUser } from 'src/lib/ncloud';
+import { ChatPanelOptions, FmodeChat, openChatPanelModal, FmodeChatMessage } from 'fmode-ng';
+
 
 @Component({
   selector: 'app-home',
@@ -16,90 +18,92 @@ import { CloudObject, CloudUser } from 'src/lib/ncloud';
   ],
 })
 export class GexinhualiaotianComponent implements OnInit {
-  userInput: string = ''; // 用户输入的消息
-  messages: { content: string; sender: string }[] = []; // 消息数组
-  isSending: boolean = false; // 标记是否正在发送消息
-  chatContent: any[] = []; // 添加 chatContent 属性
-
-  constructor() {}
-
-  ngOnInit() {}
-
-  // 发送用户输入的消息
-  sendUserMessage() {
-    if (this.userInput.trim() && !this.isSending) {
-      // 将用户输入添加到消息数组
-      this.messages.push({ content: this.userInput, sender: 'user' });
-      this.sendMessage(); // 发送消息后调用 sendMessage 方法
-      this.saveChat(); // 确保在此处调用 saveChat 方法
-    }
-  }
-
-  // 保存聊天记录到 Chat 表
-  async saveChat() {
-    const currentUser = new CloudUser(); // 假设您有当前用户的信息
-    if (!currentUser?.id) {
-      console.error('当前用户无效,无法保存聊天记录。');
-      return; // 如果没有有效的用户,退出方法
-    }
-
-    const chatObject = new CloudObject("Chat"); // 创建 Chat 对象
-    let ACL: any = { // 公开访客 不可读 不可写
-      "*": { read: false, write: false }
-    };
-    ACL[currentUser?.id] = { read: true, write: true }; // 当前用户 可读 可写
-    let chatContentString = this.userInput;
-    let now = new Date();
-
-    // 设置聊天内容和用户信息
-    chatObject.set({
-      chatContent: chatContentString,
-      chatTime: now, // 使用 Date 对象
-      user: currentUser.toPointer(),
-    });
-
-    try {
-      await chatObject.save(); // 保存聊天记录
-      console.log('聊天记录已成功保存:', chatContentString);
-    } catch (error) {
-      console.error('保存聊天记录时出错:', error);
-    }
-    // 清空聊天记录
-    this.chatContent = [];
-  }
-
-  // 方法:实例化completion对象,传入消息数组,并订阅生成的可观察对象
-  sendMessage() {
-    console.log("创建消息");
-    this.isSending = true; // 设置为正在发送状态
-
-    let completion = new FmodeChatCompletion([
-      { role: "system", content: "你是一名心理医生,请根据用户的输入进行聊天。" },
-      { role: "user", content: this.userInput }
-    ]);
-
-    completion.sendCompletion().subscribe((message: any) => {
-      // 赋值消息内容给组件内属性
-      const responseMsg = message.content;
-
-      // 使用 setTimeout 确保消息体完全输出再打印
-      setTimeout(() => {
-        // 打印消息体
-        console.log(responseMsg);
-
-        // 清空之前的AI消息,只添加最后的AI回复
-        if (this.messages[this.messages.length - 1]?.sender === 'ai') {
-          this.messages.pop(); // 移除最后一条AI消息
-        }
-        this.messages.push({ content: responseMsg, sender: 'ai' }); // 添加最后的AI回复
-
-        this.isSending = false; // 发送完成,重置状态
-      }, 0); // 立即执行,但确保在当前调用栈结束后执行
-
-      // 清空用户输入
-      this.userInput = '';
-    });
-  }
+  // userInput: string = ''; // 用户输入的消息
+  //  messages: { content: string; sender: string }[] = []; // 消息数组
+  // isSending: boolean = false; // 标记是否正在发送消息
+  // chatContent: any[] = []; // 添加 chatContent 属性
+
+  constructor(   private modalCtrl:ModalController ) {}
+
+  ngOnInit() {
+   
+}
+
+  // // 发送用户输入的消息
+  // sendUserMessage() {
+  //   if (this.userInput.trim() && !this.isSending) {
+  //     // 将用户输入添加到消息数组
+  //     this.messages.push({ content: this.userInput, sender: 'user' });
+  //     this.sendMessage(); // 发送消息后调用 sendMessage 方法
+  //     this.saveChat(); // 确保在此处调用 saveChat 方法
+  //   }
+  // }
+
+  // // 保存聊天记录到 Chat 表
+  // async saveChat() {
+  //   const currentUser = new CloudUser(); // 假设您有当前用户的信息
+  //   if (!currentUser?.id) {
+  //     console.error('当前用户无效,无法保存聊天记录。');
+  //     return; // 如果没有有效的用户,退出方法
+  //   }
+
+  //   const chatObject = new CloudObject("Chat"); // 创建 Chat 对象
+  //   let ACL: any = { // 公开访客 不可读 不可写
+  //     "*": { read: false, write: false }
+  //   };
+  //   ACL[currentUser?.id] = { read: true, write: true }; // 当前用户 可读 可写
+  //   let chatContentString = this.userInput;
+  //   let now = new Date();
+
+  //   // 设置聊天内容和用户信息
+  //   chatObject.set({
+  //     chatContent: chatContentString,
+  //     chatTime: now, // 使用 Date 对象
+  //     user: currentUser.toPointer(),
+  //   });
+
+  //   try {
+  //     await chatObject.save(); // 保存聊天记录
+  //     console.log('聊天记录已成功保存:', chatContentString);
+  //   } catch (error) {
+  //     console.error('保存聊天记录时出错:', error);
+  //   }
+  //   // 清空聊天记录
+  //   this.chatContent = [];
+  // }
+
+  // // 方法:实例化completion对象,传入消息数组,并订阅生成的可观察对象
+  // sendMessage() {
+  //   console.log("创建消息");
+  //   this.isSending = true; // 设置为正在发送状态
+
+  //   let completion = new FmodeChatCompletion([
+  //     { role: "system", content: "你是一名心理医生,请根据用户的输入进行聊天。" },
+  //     { role: "user", content: this.userInput }
+  //   ]);
+
+  //   completion.sendCompletion().subscribe((message: any) => {
+  //     // 赋值消息内容给组件内属性
+  //     const responseMsg = message.content;
+
+  //     // 使用 setTimeout 确保消息体完全输出再打印
+  //     setTimeout(() => {
+  //       // 打印消息体
+  //       console.log(responseMsg);
+
+  //       // 清空之前的AI消息,只添加最后的AI回复
+  //       if (this.messages[this.messages.length - 1]?.sender === 'ai') {
+  //         this.messages.pop(); // 移除最后一条AI消息
+  //       }
+  //       this.messages.push({ content: responseMsg, sender: 'ai' }); // 添加最后的AI回复
+
+  //       this.isSending = false; // 发送完成,重置状态
+  //     }, 0); // 立即执行,但确保在当前调用栈结束后执行
+
+  //     // 清空用户输入
+  //     this.userInput = '';
+  //   });
+  // }
 }
 
 

+ 5 - 4
heartvoice-app/src/app/tab1/tab1.page.ts

@@ -33,10 +33,11 @@ export class Tab1Page {
     this.router.navigate(['/tabs/feedback'])
    }
    liaoTian(){
-     this.openChat()
-    // this.router.navigate(['/tabs/gexinhualiaotian'])
+    this.openChat();
+     //this.router.navigate(['/tabs/gexinhualiaotian'])
    }
 
+   
    /**
    * 开始聊天
    */
@@ -120,9 +121,9 @@ export class Tab1Page {
           console.log("onChatSaved", chat, chat?.chatSession, chat?.chatSession?.id);
       }
   };
+  openChatPanelModal(this.modalCtrl, options);}
+  
   
-  openChatPanelModal(this.modalCtrl, options);
-}
    personality(){
     this.router.navigate(['/tabs/personality-test'])
    }

+ 5 - 5
heartvoice-app/src/app/tabs/tabs.routes.ts

@@ -26,16 +26,16 @@ export const routes: Routes = [
         loadComponent: () =>
           import('../interlocution/interlocution.component').then((m) => m.InterlocutionComponent),
       },
-      {
-        path: 'gexinhualiaotian',
-        loadComponent: () =>
-          import('../gexinhualiaotian/gexinhualiaotian.component').then((m) => m.GexinhualiaotianComponent),
-      },
       {
         path: 'personality-test',
         loadComponent: () =>
           import('../personality-test/personality-test.component').then((m) => m.PersonalityTestComponent),
       },
+      // {
+      //   path: 'gexinhualiaotian',
+      //   loadComponent: () =>
+      //     import('../gexinhualiaotian/gexinhualiaotian.component').then((m) => m.GexinhualiaotianComponent),
+      // },
       {
         path: 'review',
         loadComponent: () =>

+ 3 - 0
heartvoice-app/tsconfig.doc.json

@@ -0,0 +1,3 @@
+{    
+     "include": ["src/**/*.ts"]
+}

BIN
心语项目开题演讲.pptx


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio