Browse Source

Merge branch 'master' of http://git.fmode.cn:3000/csdn1233/s202226701049

未来全栈 3 months ago
parent
commit
fa4b619206
2 changed files with 23 additions and 7 deletions
  1. 1 1
      AIart-app/src/app/tab4/tab4.page.html
  2. 22 6
      AIart-app/src/app/tab4/tab4.page.ts

+ 1 - 1
AIart-app/src/app/tab4/tab4.page.html

@@ -20,7 +20,7 @@
         <ion-icon name="chatbubbles-outline" slot="start"></ion-icon>
         开始兴趣分析
       </ion-button>
-      <ion-button expand="block" fill="outline" class="secondary-button" (click)="restoreChat('6Dik4d8HC4')">
+      <ion-button expand="block" fill="outline" class="secondary-button" (click)="restoreChat()">
         <ion-icon name="refresh-outline" slot="start"></ion-icon>
         恢复上次分析
       </ion-button>

+ 22 - 6
AIart-app/src/app/tab4/tab4.page.ts

@@ -12,6 +12,7 @@ import { InterestSearchComponent } from '../interest-search/interest-search.comp
 import { FormsModule } from '@angular/forms';
 import { CloudUser } from 'src/lib/ncloud';
 import { openUserLoginModal } from 'src/lib/user/model-user-login/model-user-login.component';
+import { CloudQuery } from '../lib/ncloud';
 
 @Component({
   selector: 'app-tab4',
@@ -149,6 +150,14 @@ export class tab4Page {
         onChatSaved: (chat: FmodeChat) => {
           // chat?.chatSession?.id 本次会话的 chatId
           console.log("onChatSaved", chat, chat?.chatSession, chat?.chatSession?.id)
+          let user = new CloudUser();
+          let studyReport = new CloudObject("StudyReport");
+          studyReport.set({
+            user:user.toPointer(),
+            chatId:chat?.chatSession?.id,
+            messageList:chat?.messageList
+          })
+          studyReport.save();
         }
       }
       openChatPanelModal(this.modalCtrl, options)
@@ -159,13 +168,20 @@ export class tab4Page {
    * 恢复聊天
    * @chatId 从onChatSaved生命周期中,获取chat?.chatSession?.id
    */
-  async restoreChat(chatId: string) {
-    if (await this.checkLogin()) {
-      let options: ChatPanelOptions = {
-        roleId: "2DXJkRsjXK",
-        chatId: chatId
+  async restoreChat() {
+    let user = new CloudUser();
+    let query = new CloudQuery("StudyReport");
+    query.equalTo("user",user?.id)
+    let report = await query.first()
+    let chatId = report?.get('chatId')
+    if(chatId){
+      if (await this.checkLogin()) {
+        let options: ChatPanelOptions = {
+          roleId: "2DXJkRsjXK",
+          chatId: chatId
+        }
+        openChatPanelModal(this.modalCtrl, options)
       }
-      openChatPanelModal(this.modalCtrl, options)
     }
   }