Browse Source

'update:实现广场基本页面和模拟面试的逻辑'

abstract001 1 year ago
parent
commit
c608119bf3

+ 6 - 1
app-angular/src/modules/home/home-routing.module.ts

@@ -14,6 +14,7 @@ import {
 } from "./experience-square-information/experience-square-information.component";
 import {ExperienceSquareUserComponent} from "./experience-square-user/experience-square-user.component";
 import {AnalystReportsComponent} from "./analyst-reports/analyst-reports.component";
+import {MyresumeComponent} from "./myresume/myresume.component";
 
 const routes: Routes = [
   {
@@ -54,7 +55,11 @@ const routes: Routes = [
       {
         path: 'report', component: AnalystReportsComponent,
         canActivate: [AuthGuard],
-      }
+      },
+      {
+        path: 'myResume', component: MyresumeComponent,
+        canActivate: [AuthGuard],
+      },
     ]
   }
 ];

+ 2 - 0
app-angular/src/modules/home/home.module.ts

@@ -47,6 +47,7 @@ import {NzDrawerModule} from "ng-zorro-antd/drawer";
 import {NzBreadCrumbModule} from "ng-zorro-antd/breadcrumb";
 import {NzCascaderModule} from "ng-zorro-antd/cascader";
 import { AnalystReportsComponent } from './analyst-reports/analyst-reports.component';
+import { MyresumeComponent } from './myresume/myresume.component';
 
 @NgModule({
   declarations: [
@@ -63,6 +64,7 @@ import { AnalystReportsComponent } from './analyst-reports/analyst-reports.compo
     ExperienceSquareUserComponent,
     ExperienceSquareInformationComponent,
     AnalystReportsComponent,
+    MyresumeComponent,
   ],
   imports: [
     CommonModule,

+ 80 - 52
app-angular/src/modules/home/mock-interviews/mock-interviews.component.html

@@ -20,68 +20,96 @@
 <!--    </ion-item>-->
 <!--  </div>-->
 <!--</div>-->
+<div *ngIf="!isSmallScreen">
+  <nz-tabset [nzTabPosition]="'left'" [nzSelectedIndex]="selectedIndex" nzValue="small">
+    <nz-tab [nzTitle]="'选择页面'">
+      <!-- 选择页面的内容 -->
+      <nz-cascader
+        [nzSize]="'small'"
+        [nzOptions]="nzOptions"
+        [(ngModel)]="selectedValue"
+        [nzShowSearch]="true"
+        (ngModelChange)="onChanges($event)"
+        [nzTriggerAction]="'hover'"
+        [nzExpandTrigger]="'hover'"
+      ></nz-cascader>
+      <button nz-button nzType="primary" [nzLoading]="isLoadingOne" (click)="loadOne()">Click me!</button>
 
-<nz-tabset [nzTabPosition]="'left'" [nzSelectedIndex]="selectedIndex" nzValue="small">
-  <nz-tab [nzTitle]="'选择页面'">
-    <!-- 选择页面的内容 -->
-    <nz-cascader
-      [nzSize]="'large'"
-      [nzOptions]="nzOptions"
-      [(ngModel)]="selectedValue"
-      [nzShowSearch]="true"
-      (ngModelChange)="onChanges($event)"
-      [nzTriggerAction]="'hover'"
-      [nzExpandTrigger]="'hover'"
-    ></nz-cascader>
-    <button nz-button nzType="primary" [nzLoading]="isLoadingOne" (click)="loadOne()">Click me!</button>
-
-  </nz-tab>
-  <nz-tab [nzTitle]="'面试环节'">
-    <ng-template #contentTemplate>
-      <div class="chat-container">
-        <div class="chat-window" #chatWindow>
-          <div class="chat-label">聊天记录</div>
-          <div class="chat-messages">
-            <div *ngFor="let message of messagesListUser" class="message"
-                 [ngClass]="{'left': getReceived(message.role), 'right': getReceived(message.role)}">
-              <div class="avatar" [ngClass]="{'left': getReceived(message.role), 'right':getReceived(message.role)}">
-                <img [src]="getAvatar(message.role)" alt="Avatar"/>
+    </nz-tab>
+    <nz-tab [nzTitle]="'面试环节'">
+      <ng-template #contentTemplate>
+        <div class="chat-container">
+          <div class="chat-window" #chatWindow>
+            <div class="chat-label">聊天记录</div>
+            <div class="chat-messages">
+              <div *ngFor="let message of messagesListUser" class="message"
+                   [ngClass]="{'left': getReceived(message.role), 'right': getReceived(message.role)}">
+                <div class="avatar" [ngClass]="{'left': getReceived(message.role), 'right':getReceived(message.role)}">
+                  <img [src]="getAvatar(message.role)" alt="Avatar"/>
+                </div>
+                <div class="content">{{ message.content }}</div>
               </div>
-              <div class="content">{{ message.content }}</div>
             </div>
           </div>
-        </div>
-        <div class="input-container">
+          <div class="input-container">
         <textarea [nzSize]="'large'" nz-input [(ngModel)]="inputText" placeholder="请输入消息"
                   (keydown)="handleKeyDown($event)"></textarea>
-          <button nz-button nzType="primary" (click)="scrollToBottom()" [disabled]="createReport">滚动</button>
-          <button nz-button nzType="primary" (click)="handleButton()" [disabled]="createReport">发送</button>
-          <nz-modal [(nzVisible)]="isVisible" nzTitle="The first Modal" (nzOnCancel)="handleCancel()"
-                    (nzOnOk)="handleOk()">
-            <ng-container *nzModalContent>
-              <p>{{errorMessage}}</p>
-            </ng-container>
-          </nz-modal>
+            <button nz-button nzType="primary" (click)="handleButton()" [disabled]="createReport">发送</button>
+            <nz-modal [(nzVisible)]="isVisible" nzTitle="The first Modal" (nzOnCancel)="handleCancel()"
+                      (nzOnOk)="handleOk()">
+              <ng-container *nzModalContent>
+                <p>{{errorMessage}}</p>
+              </ng-container>
+            </nz-modal>
+          </div>
         </div>
-      </div>
-    </ng-template>
-    <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
-  </nz-tab>
-  <nz-tab [nzTitle]="'阿里面试官'">
-    <!-- 选择页面的内容 -->
-    <div #chatContainer>
+      </ng-template>
       <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
+    </nz-tab>
+  </nz-tabset>
+</div>
+<!-- 当页面宽度小于720px时显示的HTML代码 -->
+<div *ngIf="true">
+  <!-- 这里放置小屏幕下的HTML代码 -->
+  <!-- ... -->
+  <nz-cascader
+    [nzSize]="'small'"
+    [nzOptions]="nzOptions"
+    [(ngModel)]="selectedValue"
+    [nzShowSearch]="true"
+    (ngModelChange)="onChanges($event)"
+    [nzTriggerAction]="'hover'"
+    [nzExpandTrigger]="'hover'"
+  ></nz-cascader>
+  <button nz-button nzType="primary" [nzLoading]="isLoadingOne" (click)="loadTwo()">请选择你的模式</button>
+</div>
+<div *ngIf="isSmallScreen">
+  <div class="chat-container">
+    <div class="chat-window" #chatWindow>
+      <div class="chat-label">聊天记录</div>
+      <div class="chat-messages">
+        <div *ngFor="let message of messagesListUser" class="message"
+             [ngClass]="{'left': getReceived(message.role), 'right': getReceived(message.role)}">
+          <div class="avatar" [ngClass]="{'left': getReceived(message.role), 'right':getReceived(message.role)}">
+            <img [src]="getAvatar(message.role)" alt="Avatar"/>
+          </div>
+          <div class="content">{{ message.content }}</div>
+        </div>
+      </div>
     </div>
-  </nz-tab>
-  <nz-tab [nzTitle]="'华为面试官'">
-    <!-- 选择页面的内容 -->
-    <div #chatContainer>
-      <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
+    <div class="input-container">
+        <textarea [nzSize]="'large'" nz-input [(ngModel)]="inputText" placeholder="请输入消息"
+                  (keydown)="handleKeyDown($event)"></textarea>
+      <button nz-button nzType="primary" (click)="handleButton()" [disabled]="createReport">发送</button>
+      <nz-modal [(nzVisible)]="isVisible" nzTitle="The first Modal" (nzOnCancel)="handleCancel()"
+                (nzOnOk)="handleOk()">
+        <ng-container *nzModalContent>
+          <p>{{errorMessage}}</p>
+        </ng-container>
+      </nz-modal>
     </div>
-  </nz-tab>
-</nz-tabset>
-
-
+  </div>
+</div>
 
 
 

+ 89 - 62
app-angular/src/modules/home/mock-interviews/mock-interviews.component.ts

@@ -1,4 +1,4 @@
-import {Component, ElementRef, ViewChild, OnInit} from '@angular/core';
+import {Component, ElementRef, ViewChild, OnInit, HostListener} from '@angular/core';
 import {trigger, state, style, animate, transition} from '@angular/animations';
 import {TestChatCompletion, TestChatMessage} from '../class-chat-completion';
 import {ActivatedRoute} from '@angular/router';
@@ -23,7 +23,28 @@ Parse.initialize("dev")
     ])
   ]
 })
-export class MockInterviewsComponent {
+export class MockInterviewsComponent implements OnInit {
+  //监听窗口变化
+  isSmallScreen = false; // 标志位,表示是否是小屏幕
+  @HostListener('window:resize', ['$event'])
+  onResize(event: any) {
+    this.checkScreenSize();
+  }
+
+  // 检查屏幕大小
+  checkScreenSize() {
+    this.isSmallScreen = window.innerWidth < 720;
+  }
+
+  ngOnInit(): void {
+    this.route.queryParams.subscribe(params => {
+      console.log(params)
+      this.selectedIndex = params['tabIndex'] || 0;
+    });
+    this.checkScreenSize();
+
+  }
+
   showContent: boolean = false;
   showProgress: boolean = false;
   progress: number = 0;
@@ -157,6 +178,10 @@ export class MockInterviewsComponent {
 
   }
 
+  ngAfterViewChecked() {
+    this.scrollToBottom();
+  }
+
   messagesList: Array<TestChatMessage> = [
     {
       role: "assistant",
@@ -207,7 +232,6 @@ export class MockInterviewsComponent {
   typeQuestion: number = 0;
 
   @ViewChild('chatWindow') chatWindowRef!: ElementRef;
-  @ViewChild('chatContainer') chatContainerRef!: ElementRef;
 
   // 滚动到底部
   scrollToBottom() {
@@ -254,12 +278,17 @@ export class MockInterviewsComponent {
   }
 
   handleOk(): void {
-    this.isContinue = true;
+    if (this.errorMessage == '您有未完成的面试环节,请问您是否要继续') {
+      this.isContinue = true;
+      this.selectedIndex = 1;
+    }
     this.isVisible = false;
   }
 
   handleCancel(): void {
-    this.isContinue = false;
+    if (this.errorMessage == '您有未完成的面试环节,请问您是否要继续') {
+      this.isContinue = false;
+    }
     this.isVisible = false;
   }
 
@@ -311,21 +340,23 @@ export class MockInterviewsComponent {
 
     // 查询 LjUserInterviewData 表中当前用户的数据
     await query.find().then(async (results: any) => {
-      console.log(results[0].get('interviewResult'))
-      if (results[0].get('interviewResult') == 1) {
-        this.errorMessage = '您有未完成的面试环节,请问您是否要继续';
-        await this.showModal()
-        if (this.isContinue) {
-          console.log("继续面试")
-          this.messagesListUser = results[0].get('userList');
-          this.finalResult = results[0].get('question');
-          this.resultAnswers = results[0].get('answer');
-          this.messagesList = results[0].get('aiList');
-          this.typeQuestion = results[0].get('number');
-          this.isStart = results[0].get('interviewResult');
-        }
+      if (results.length > 0) {
+        if (results[0].get('interviewResult') == 1) {
+          this.errorMessage = '您有未完成的面试环节,请问您是否要继续';
+          await this.showModal();
+          if (this.isContinue) {
+            console.log("继续面试")
+            this.messagesListUser = results[0].get('userList');
+            this.finalResult = results[0].get('question');
+            this.resultAnswers = results[0].get('answer');
+            this.messagesList = results[0].get('aiList');
+            this.typeQuestion = results[0].get('number');
+            this.isStart = results[0].get('interviewResult');
+          }
 
+        }
       }
+
     });
   }
 
@@ -345,35 +376,36 @@ export class MockInterviewsComponent {
     // 查询 LjUserInterviewData 表中当前用户的数据
     await query.find().then(async (results: any) => {
       console.log(results.length)
-      if (results[0].get('interviewResult') != 0) {
-        const userInterviewData = results[0];
-
-        // 修改数据
-        userInterviewData.set('number', this.typeQuestion);
-        userInterviewData.set('question', this.finalResult);
-        userInterviewData.set('answer', this.resultAnswers);
-        userInterviewData.set('userList', this.messagesListUser);
-        userInterviewData.set('aiList', this.messagesList);
-        userInterviewData.set('interviewResult', this.isStart);
-
-        //判断当前是否结束了
-        let isOver = 0;
-        if (this.isStart != 0) {
-          isOver = 1;
+      if (results.length > 0) {
+        if (results[0].get('interviewResult') != 0) {
+          const userInterviewData = results[0];
+
+          // 修改数据
+          userInterviewData.set('number', this.typeQuestion);
+          userInterviewData.set('question', this.finalResult);
+          userInterviewData.set('answer', this.resultAnswers);
+          userInterviewData.set('userList', this.messagesListUser);
+          userInterviewData.set('aiList', this.messagesList);
+          userInterviewData.set('interviewResult', this.isStart);
+
+          //判断当前是否结束了
+          let isOver = 0;
+          if (this.isStart != 0) {
+            isOver = 1;
+          }
+          userInterviewData.set('interviewResult', isOver);
+
+          // 保存修改后的数据
+          await userInterviewData.save().then((savedUserInterviewData: any) => {
+            console.log('User Interview Data updated:', savedUserInterviewData);
+          }).catch((error: any) => {
+            console.error('Error updating User Interview Data:', error);
+          });
         }
-        userInterviewData.set('interviewResult', isOver);
-
-        // 保存修改后的数据
-        await userInterviewData.save().then((savedUserInterviewData: any) => {
-          console.log('User Interview Data updated:', savedUserInterviewData);
-        }).catch((error: any) => {
-          console.error('Error updating User Interview Data:', error);
-        });
       } else {
-        await this.saveUserInterviewData()
-        console.log("saveU")
+        await this.saveUserInterviewData();
+        console.log("saveU");
       }
-
     }).catch((error: any) => {
       console.error('Error retrieving User Interview Data:', error);
     });
@@ -404,14 +436,13 @@ export class MockInterviewsComponent {
         role: "user",
         content: this.inputText += '回答完毕',
       });
-      this.scrollToBottom()
+
       this.messagesListUser.push(
         {
-          role: 'user',
+          role: 'assistant',
           content: "感谢您的回答,请稍等,正在生成报告.....",
         }
       )
-      this.scrollToBottom()
       setTimeout(async () => {
         await this.createAiReport()
       }, 1000)
@@ -419,6 +450,7 @@ export class MockInterviewsComponent {
 
     } else {
       if (this.isStart == 0) {
+        this.createReport = true;
         this.messagesListUser.push({
             role: "user",
             content: "开始面试",
@@ -427,8 +459,6 @@ export class MockInterviewsComponent {
             role: "assistant",
             content: "请等待,对话生成中....."
           });
-        this.scrollToBottom()
-
 
         await this.getQuestion();
 
@@ -439,11 +469,11 @@ export class MockInterviewsComponent {
           role: "assistant",
           content: this.finalResult[this.typeQuestion].question
         });
-        this.scrollToBottom()
 
         this.isStart++;
         this.typeQuestion++;
         await this.getUserInterviewData()
+        this.createReport = false
 
 
       } else {
@@ -454,7 +484,6 @@ export class MockInterviewsComponent {
             role: "user",
             content: this.inputText += '回答完毕',
           });
-          this.scrollToBottom()
           this.resultAnswers.push(this.inputText);
 
           this.messagesListUser.push(
@@ -464,14 +493,13 @@ export class MockInterviewsComponent {
             }
           );
           console.log(this.resultAnswers);
-          this.scrollToBottom()
           this.inputText = "";
           // 将滚动条滚动到底部
           this.typeQuestion++;
           await this.getUserInterviewData()
         } else {
           this.errorMessage = '您的输入为空,请检查输入';
-          this.showModal()
+          await this.showModal()
           return
         }
       }
@@ -507,7 +535,6 @@ export class MockInterviewsComponent {
           content: this.messagesList[this.messagesList.length - 1].content,
         }
       );
-      this.scrollToBottom()
       resolve(undefined);
     });
   }
@@ -619,13 +646,6 @@ export class MockInterviewsComponent {
   selectedIndex = 0;
 
 
-  ngOnInit() {
-    this.route.queryParams.subscribe(params => {
-      console.log(params)
-      this.selectedIndex = params['tabIndex'] || 0;
-    });
-  }
-
   //级联数据
   selectedValue: any[] = []
 
@@ -646,8 +666,15 @@ export class MockInterviewsComponent {
 
   }
 
+  //小版本
+  smallVersion: boolean = false
+
+  loadTwo(): void {
+    this.smallVersion = true
+  }
+
   handleClick(): void {
-    this.selectedIndex = 2
+    this.selectedIndex = 1
     console.log(this.selectedValue)
     console.log(this.selectedValue[0])
   }

+ 1 - 1
app-angular/src/modules/home/nav-menu/nav-menu.component.html

@@ -62,7 +62,7 @@
             <a routerLink="/home/mine">我的信息</a>
           </li>
           <li nz-menu-item nzMatchRouter>
-            <a>我的简历</a>
+            <a routerLink="/home/myResume">我的简历</a>
           </li>
           <li nz-menu-item nzMatchRouter>
             <a routerLink="/home/expersquare">分享广场</a>