Quellcode durchsuchen

Merge branch 'master' of http://git.fmode.cn:3000/4u/workspace

19136808282 vor 3 Monaten
Ursprung
Commit
8628299702

+ 2 - 2
docs-prod/schema.md

@@ -441,8 +441,8 @@ left to right direction
 
 输入评价内容 --> 保存退出
 
-保存退出 --> 返回当前页面 : 保存成功
-返回当前页面 --> [*]
+保存退出 --> [*]:保存成功
+保存退出 --> 输入评价内容: 保存失败
 @enduml
 ```
 # 查看报告业务

+ 2 - 12
soul-app/src/app/report-modal/report-modal.component.ts

@@ -35,14 +35,10 @@ export class ReportModalComponent  implements OnInit {
     // 获取当前用户的 ObjectId
     const currentUser = new CloudUser();
     await currentUser.current(); // 确保用户信息已加载
-    const userId = currentUser.id; // 获取当前用户的 ObjectId
-
     // 创建查询并添加过滤条件
     let query = new CloudQuery("ChatRecord");
     query.equalTo("user", currentUser.toPointer()); // 过滤条件,确保只获取当前用户的记录
-
     this.chatrecordList = await query.find();
-
     // 遍历 chatrecordList,去除每个记录中 user 的第一条 content
     this.chatrecordList.forEach(chatrecord => {
         const contentArray = chatrecord.get('content');
@@ -54,7 +50,7 @@ export class ReportModalComponent  implements OnInit {
             }
         }
     });
-}
+  }
   analyzeUserFeeling(content: string): { score: number; label: string } {
     const moodScores = {
       positive: {
@@ -70,9 +66,7 @@ export class ReportModalComponent  implements OnInit {
         score: -1
       }
     };
-
     let totalScore = 0;
-
     // 分析内容并计算分数
     const contentWords = content.split(/\s+/);
     contentWords.forEach(word => {
@@ -82,7 +76,6 @@ export class ReportModalComponent  implements OnInit {
         }
       }
     });
-
     // 判断心情状态
     let label = '中性';
     if (totalScore > 0) {
@@ -90,11 +83,8 @@ export class ReportModalComponent  implements OnInit {
     } else if (totalScore < 0) {
       label = '消极';
     }
-
     return { score: totalScore, label };
   }
-
-
   async ngOnInit() {
     await this.loadChatRecordList();
     // 在这里可以遍历 chatrecordList 中的用户内容并进行情感分析
@@ -107,5 +97,5 @@ export class ReportModalComponent  implements OnInit {
             }
         });
     });
-} 
+  } 
 }

+ 1 - 1
soul-app/src/app/tab1/tab1.page.html

@@ -7,7 +7,7 @@
       </ion-avatar>
  
       <!-- 搜索框 -->
-      <ion-searchbar slot="end" expand="with-icon"></ion-searchbar>
+      <ion-searchbar slot="end" expand="with-icon" [placeholder]="placeholderText" class="custom-searchbar"></ion-searchbar>
     </ion-item>
   </ion-toolbar>
 </ion-header>

+ 11 - 6
soul-app/src/app/tab1/tab1.page.ts

@@ -21,11 +21,16 @@ import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-log
   schemas: [CUSTOM_ELEMENTS_SCHEMA],
 })
 export class Tab1Page {
-  onSearch(event: any) {
-    const searchTerm = event.target.value; // 获取用户输入的搜索内容
-    console.log('搜索内容:', searchTerm);
-    // 在这里添加搜索逻辑,例如过滤列表或导航到搜索结果页面
+  placeholderText: string = '';
+  placeholderIndex: number = 0;
+  placeholders: string[] = ['热门话题', '心理普查', '漂流瓶','用户评价'];
+  cyclePlaceholder() {
+    setInterval(() => {
+      this.placeholderText = this.placeholders[this.placeholderIndex];
+      this.placeholderIndex = (this.placeholderIndex + 1) % this.placeholders.length;
+    }, 2000); // 每2秒切换一次
   }
+
   topics = [
     {
       id: 1,
@@ -99,7 +104,8 @@ export class Tab1Page {
     this.router.navigate([`tabs/${route}`, { id: topicId }]);
   }
   constructor(private router: Router,private modalCtrl: ModalController) {
-    // 其他构造函数代码
+    this.cyclePlaceholder();
+        // 其他构造函数代码
   }
   matchedCounselor: { content: string; rating: number } | null = null;
   review: any = { rating: 5 };  // 示例数据
@@ -110,7 +116,6 @@ export class Tab1Page {
     return Array(Math.min(length, maxStars)).fill(null);
   }
   async evaluate() {
-    // 处理点击评价的逻辑
     // 验证用户登录
     let currentUser = new CloudUser();
     if(!currentUser?.id){

+ 3 - 5
soul-app/src/app/tab2/tab2.page.ts

@@ -24,7 +24,6 @@ import { CustomerServiceComponent } from '../customer-service/customer-service.c
 })
 export class Tab2Page {
 
-  isModalOpen: boolean = false; // 定义 isModalOpen 属性
   placeholderText: string = '';
   placeholderIndex: number = 0;
   placeholders: string[] = ['智能陪聊', '普通聊天', '小贴心建议'];
@@ -50,14 +49,13 @@ export class Tab2Page {
     this.cyclePlaceholder();
   }
   matchedCounselor: { name: string; specialty: string } | null = null;
+  isModalOpen: boolean = false; // 定义 isModalOpen 属性
   async clickToConsult(chatpartner: CloudObject) {
       await this.initChat(chatpartner, true);
   }
-
   async goChat(chatcompanion: CloudObject) {
       await this.initChat(chatcompanion, false);
   }
-
   private async initChat(partner: CloudObject, isConsult: boolean) {
       // 验证用户登录
       let currentUser = new CloudUser();
@@ -106,10 +104,10 @@ export class Tab2Page {
             chat.role.set("name", partner.get("name"));
             chat.role.set("bio", partner.get("bio"));
             chat.role.set("expertise", partner.get("expertise"));
-            chat.role.set("avatar", partner.get("avatar") || "/assets/img/2.png"); // 设置聊天伙伴头像
+            chat.role.set("avatar", partner.get("avatar") || "/assets/img/2.png");
             chat.role.set("prompt", `
             # 角色设定
-            您是${partner.get("name")},一位${partner.get("bio")}的聊天伙伴,需要为用户提供陪伴和支持等积极情绪。
+            您是${partner.get("name")},一位在${partner.get("expertise")}专业领域的${partner.get("bio")}的聊天伙伴,需要为用户提供陪伴和支持等积极情绪。
             # 开始话语
             当您准备好了,可以以一个关心用户的朋友的身份,向来访的用户打招呼
             # 对话环节

+ 0 - 5
soul-app/src/app/user-evaluate/user-evaluate.component.ts

@@ -20,18 +20,15 @@ export class UserEvaluateComponent  implements OnInit {
     content: '',
     rating: 0,
   };
-
   constructor(private modalCtrl: ModalController) { 
     this.currentUser = new CloudUser();
   }
-
   userDataChange(key: string, ev: any) {
     let value = ev?.detail?.value;
     if (value) {
       this.userData[key] = value;
     }
   }
-
   async save() {
     // 确保 currentUser 是有效的 CloudUser 实例
     if (!this.currentUser) {
@@ -44,11 +41,9 @@ export class UserEvaluateComponent  implements OnInit {
       console.error('评价保存失败');
     }
   }
-
   cancel() {
     this.modalCtrl.dismiss(null, "cancel");
   }
-
   ngOnInit() {}
 }
   export async function openUserEvaModal(modalCtrl:ModalController):Promise<CloudUser|null>{

+ 0 - 6
soul-app/src/lib/cloud.evaluate.ts

@@ -5,14 +5,12 @@ export class CloudEvaluate extends CloudObject {
     userData: Record<string, any>;
     currentUser: CloudUser; // 添加当前用户的引用
     modalCtrl: any; // 假设 modalCtrl 是通过构造函数传入的
-
     constructor(userData: Record<string, any>, currentUser: CloudUser,modalCtrl: any) {
         super("_ChatEvaluate"); 
         this.userData = userData; // 保存用户评价数据
         this.currentUser = currentUser; // 保存当前用户
         this.modalCtrl = modalCtrl; // 保存模态控制器
     }
-
     /** 保存评价 */
     override async save() {
         // 确保 rating 是数字类型
@@ -20,7 +18,6 @@ export class CloudEvaluate extends CloudObject {
             this.userData['rating'] = Number(this.userData['rating']);
         }
         console.log('保存评价被调用'); // 调试日志
-
         // 调用后端 API 保存评价
         const response = await fetch(`http://dev.fmode.cn:1337/parse/classes/ChatEvaluate`, {
             headers: {
@@ -35,16 +32,13 @@ export class CloudEvaluate extends CloudObject {
             }),
             method: "POST"
         });
-
         const result = await response.json();
         console.log('保存结果:', result); // 输出保存结果
-
         if (result?.error) {
             console.error(result?.error);
             console.error('评价保存失败');
             return null;
         }
-
         console.log('评价保存成功:', result);
         this.modalCtrl.dismiss(result, "confirm"); // 关闭模态框并传递结果
         return result; // 返回保存的结果