Przeglądaj źródła

修复指针问题

warrior 1 tydzień temu
rodzic
commit
58d45ed806

+ 2 - 2
projects/live-app/src/app/app.component.ts

@@ -63,7 +63,7 @@ export class AppComponent implements OnInit {
       // 设置状态栏背景颜色(可选)
       // await StatusBar.setBackgroundColor({ color: '#000000' });
     } catch (error) {
-      console.error('设置状态栏时出错:', error);
+      console.warn('设置状态栏时出错:', error);
     }
   }
 
@@ -75,7 +75,7 @@ export class AppComponent implements OnInit {
       // 设置状态栏背景色
       await StatusBar.setBackgroundColor({ color: backgroundColor });
     } catch (error) {
-      console.error('设置状态栏背景色时出错:', error);
+      console.warn('设置状态栏背景色时出错:', error);
     }
   }
 }

+ 31 - 18
projects/live-app/src/app/components/call-modal/call-modal.component.ts

@@ -8,14 +8,14 @@ import { AiChatService } from '../../../services/aichart.service';
 import { ConnectTaskService } from '../../../services/connectTask.service';
 import { MessageService } from '../../../services/message.service';
 import * as Parse from 'parse';
-
+import { Subject } from 'rxjs';
+import { takeUntil } from 'rxjs/operators';
 @Component({
   selector: 'app-call-modal',
   templateUrl: './call-modal.component.html',
   styleUrls: ['./call-modal.component.scss'],
   standalone: true,
-  imports: [
-  ],
+  imports: [],
 })
 export class CallModalComponent implements OnInit {
   @Input('profile') profile?: Parse.Object;
@@ -25,6 +25,7 @@ export class CallModalComponent implements OnInit {
   currentUser?: Parse.Object = Parse.User.current(); //当前登录用户
   iscall: boolean = false;
   isLiveing: boolean = false; // 是否在直播通话中
+  private ngUnsubscribe = new Subject<void>(); // 用于取消订阅
   constructor(
     private router: Router,
     private toastController: ToastController,
@@ -33,7 +34,9 @@ export class CallModalComponent implements OnInit {
     private msgSer: MessageService,
     private aiChatServ: AiChatService
   ) {
-    this.msgSer.event$.subscribe((data) => {
+    this.msgSer.event$
+    .pipe(takeUntil(this.ngUnsubscribe)) // 使用 takeUntil 取消订阅
+    .subscribe((data) => {
       this.inviteCallback(data);
     });
   }
@@ -43,8 +46,9 @@ export class CallModalComponent implements OnInit {
     this.refresh();
   }
   ngOnDestroy(): void {
-    //Called once, before the instance is destroyed.
-    //Add 'implements OnDestroy' to the class.
+    this.ngUnsubscribe.next();
+    this.ngUnsubscribe.complete();
+    
     if (!this.isLiveing && this.uid !== this.currentUser?.id) {
       console.log('断开连接');
       this.msgSer?.unsubscribeMessage(this.uid!);
@@ -59,6 +63,7 @@ export class CallModalComponent implements OnInit {
     query.equalTo('profile', this.profile?.id);
     query.notEqualTo('isDeleted', true);
     this.room = await query.first();
+    console.log(this.room);
     if (!this.room?.id) return;
     this.userStatus = await this.connectTask.getState(
       this.profile?.get('user').id,
@@ -110,20 +115,27 @@ export class CallModalComponent implements OnInit {
     });
     await alert.present();
   }
-  async inviteCallback(event: boolean) {
+  timer: any; // 定时器
+  inviteCallback(event: boolean) {
     console.log(event);
     if (event == undefined) return;
-    this.iscall = false;
-    const toast = await this.toastController.create({
-      message: `对方${event ? '已接受' : '拒绝'}通话邀请`,
-      color: event ? 'success' : 'warning',
-      duration: 1500,
-    });
-    toast.present();
-    if (event) {
-      this.isLiveing = true;
-      this.router.navigate(['live/link-room/' + this.room?.id]);
-    }
+    this.timer && clearTimeout(this.timer);
+    this.timer = setTimeout(async () => {
+      this.iscall = false;
+      const toast = await this.toastController.create({
+        message: `对方${event ? '已接受' : '拒绝'}通话邀请`,
+        color: event ? 'success' : 'warning',
+        duration: 1500,
+      });
+      toast.present();
+      if (event) {
+        this.isLiveing = true;
+        let path = location.pathname;
+        if (path.indexOf('/live/link-room/') != -1) return;
+        console.log(this.room);
+        this.router.navigate(['live/link-room/' + this.room?.id]);
+      }
+    }, 100);
   }
   async sendVideoCallInvite() {
     let second = await this.aiChatServ.get_duration(
@@ -148,6 +160,7 @@ export class CallModalComponent implements OnInit {
     this.msgSer.publishMessage('USERCALLINVITATION', this.uid!);
   }
   async onCloseCall() {
+    this.timer && clearTimeout(this.timer);
     this.iscall = false;
     const toast = await this.toastController.create({
       message: '已取消视频通话邀请',

+ 26 - 19
projects/live-app/src/app/components/flutter-comp/flutter-comp.component.ts

@@ -1,27 +1,29 @@
 import { Component, Input, OnInit } from '@angular/core';
 import { MessageService } from '../../../services/message.service';
 
-import {VapInit} from '../../../lib/vap-player/index'
-
+import { VapInit } from '../../../lib/vap-player/index';
+import { Subject } from 'rxjs';
+import { takeUntil } from 'rxjs/operators';
 @Component({
   selector: 'app-flutter-comp',
   templateUrl: './flutter-comp.component.html',
   styleUrls: ['./flutter-comp.component.scss'],
   standalone: true,
-  imports: []
+  imports: [],
 })
 export class FlutterCompComponent implements OnInit {
-  @Input('domId') domId: string = 'vap-gift'
-  constructor(
-    public msgSerrvice: MessageService
-  ) { 
-    this.msgSerrvice.eventplay$.subscribe((data) => {
-      this.playGift(data);
-    });
+  @Input('domId') domId: string = 'vap-gift';
+  private ngUnsubscribe = new Subject<void>(); // 用于取消订阅
+  constructor(public msgSerrvice: MessageService) {
+    this.msgSerrvice.eventplay$
+      .pipe(takeUntil(this.ngUnsubscribe)) // 使用 takeUntil 取消订阅
+      .subscribe((data) => {
+        this.playGift(data);
+      });
   }
-  playGift(param:{video:string,config:any}){
-    console.log('param:',param);
-    this.msgSerrvice.isPlayer = true
+  playGift(param: { video: string; config: any }) {
+    console.log('param:', param);
+    this.msgSerrvice.isPlayer = true;
     let dom = document.getElementById(this.domId);
     // console.log(dom);
     let vapPlayer = VapInit({
@@ -45,18 +47,23 @@ export class FlutterCompComponent implements OnInit {
       vapPlayer = null;
       console.log('播放结束');
       this.msgSerrvice.giftLogMap.pop();
-      if(this.msgSerrvice.giftLogMap.length > 0){
-        let obj = this.msgSerrvice.giftLogMap.slice(-1)[0]
+      if (this.msgSerrvice.giftLogMap.length > 0) {
+        let obj = this.msgSerrvice.giftLogMap.slice(-1)[0];
         this.playGift({
           video: obj.gift.video,
           config: obj.gift.config,
         });
-      }else{
-        this.msgSerrvice.isPlayer = false
+      } else {
+        this.msgSerrvice.isPlayer = false;
       }
     });
-    vapPlayer.on('playering', function() { console.log('playering'); })
+    vapPlayer.on('playering', function () {
+      console.log('playering');
+    });
   }
-  ngOnInit() {
+  ngOnInit() {}
+  ngOnDestroy(): void {
+    this.ngUnsubscribe.next();
+    this.ngUnsubscribe.complete();
   }
 }

+ 1 - 1
projects/live-app/src/app/components/live/live.component.html

@@ -8,7 +8,7 @@
       height="100%"
       (click)="onChangeScreen('big',$event)"
     >
-    等待对方接受邀请...
+    等待对方接...
     </div>
     <!-- 副屏 -->
     <div

+ 3 - 3
projects/live-app/src/modules/live/link-page/link-page.component.ts

@@ -114,9 +114,9 @@ export class LinkPageComponent implements OnInit {
       observer: false, //修改swiper自己或子元素时,自动初始化swiper
       observeParents: true, //修改swiper的父元素时,自动初始化swiper
     });
-    swiper.on('slideChange', function (event: any) {
-      // console.log(event);
-    });
+    // swiper.on('slideChange', function (event: any) {
+    //   // console.log(event);
+    // });
   }
   /* 关注状态 */
   async getFollwState(uid: string) {

+ 1 - 1
projects/live-app/src/modules/tabs/tabs/tabs.component.ts

@@ -184,7 +184,7 @@ export class TabsComponent implements OnInit {
       }
       await this.requestMicrophonePermission()
     } catch (error) {
-      console.error('请求权限时出错:', error);
+      console.warn('请求权限时出错:', error);
     }
   }
   async requestMicrophonePermission() {

+ 24 - 0
projects/live-app/src/modules/user/share/share.component.html

@@ -21,4 +21,28 @@
       </div>
     </div>
   </div>
+  <div class="list">
+    <div class="title">邀请记录</div>
+    @for (item of list; track $index) {
+    <div class="li" (click)="toUrl(item?.id)">
+      <div class="li-left">
+        <img [src]="item?.get('avatar')" class="avatar" />
+      </div>
+      <div class="li-right">
+        <div class="li-right-user">
+          <div class="user-name">
+            {{
+              item?.get("nickname") ||
+                item?.get("name")
+            }}
+          </div>
+          <div class="time">
+            {{ item.createdAt | date : "yyyy-MM-dd HH:mm" }}
+          </div>
+        </div>
+        <ion-icon name="chevron-forward"></ion-icon>
+      </div>
+    </div>
+    }
+  </div>
 </div>

+ 45 - 0
projects/live-app/src/modules/user/share/share.component.scss

@@ -42,4 +42,49 @@
       }
     }
   }
+  .list {
+    padding: 10px;
+    border-radius: 4px;
+    background: white;
+    max-height: 500px;
+    overflow-y: scroll;
+    .title{
+      margin-bottom: 6px;
+    }
+    .li {
+      display: flex;
+      justify-content: space-between;
+      // padding: 1.0256vw 2.5641vw;
+      background: white;
+      border-bottom: 0.2564vw solid #e5e5e5;
+      .li-left {
+        flex-shrink: 0;
+        width: 10.2564vw;
+        .avatar {
+          width: 9.2308vw;
+          height: 9.2308vw;
+          border-radius: 50%;
+        }
+      }
+      .li-right {
+        display: flex;
+        flex: 1;
+        margin-left: 2.5641vw;
+        justify-content: space-between;
+        align-items: center;
+        .li-right-user {
+          display: flex;
+          flex-direction: column;
+          .user-name{
+            font-size: 3.5897vw;
+            margin-bottom: 1.5385vw;
+          }
+          .time {
+            font-size: 3.0769vw;
+            color: #7d7d7d;
+          }
+        }
+      }
+    }
+  }
 }

+ 20 - 1
projects/live-app/src/modules/user/share/share.component.ts

@@ -4,13 +4,16 @@ import { ToastController } from '@ionic/angular';
 import { NavComponent } from '../../../app/components/nav/nav.component';
 import * as Parse from 'parse';
 import { ionicStandaloneModules } from '../../ionic-standalone.modules';
+import { Router } from '@angular/router';
+import { CommonModule, DatePipe } from '@angular/common';
 
 @Component({
   selector: 'app-share',
   templateUrl: './share.component.html',
   styleUrls: ['./share.component.scss'],
   standalone: true,
-  imports: [...ionicStandaloneModules, NavComponent],
+  imports: [...ionicStandaloneModules, NavComponent,CommonModule],
+  providers: [DatePipe],
 })
 export class ShareComponent implements OnInit {
   @Input() path: string = '/chat/home';
@@ -20,13 +23,26 @@ export class ShareComponent implements OnInit {
   bannerUrl: string =
     'https://file-cloud.fmode.cn/Qje9D4bqol/20241220/qvj1bm054428527.png';
   codeUrl: string = '';
+  list:Array<Parse.Object> = []
+
   constructor(
     private toastController: ToastController,
+    private router: Router,
     private http: HttpClient
   ) {}
 
   ngOnInit() {
     this.getCode()
+    this.getInvite()
+  }
+  async getInvite(){
+    let uid = Parse.User.current()?.id;
+    let query = new Parse.Query('User')
+    query.equalTo('invite',uid)
+    query.skip(this.list.length)
+    query.limit(20)
+    let res = await query.find()
+    this.list.push(...res)
   }
   ngOnChanges() {
     this.getCode();
@@ -114,4 +130,7 @@ export class ShareComponent implements OnInit {
       location.href = this.imgUrl;
     }
   }
+  toUrl(id: string) {
+    this.router.navigate(['/user/profile/' + id]);
+  }
 }

+ 3 - 3
projects/live-app/src/services/live.service.ts

@@ -192,7 +192,7 @@ export class LiveService {
   async join() {
     let path = location.pathname;
     if (path.indexOf('/live/link-room/') == -1) return;
-    console.log('频道:', this.options.channel);
+    console.log('频道id:', this.options.channel);
     this.client
       .join(
         this.options.appid,
@@ -220,7 +220,7 @@ export class LiveService {
         this.afterJoin();
       })
       .catch((err: any) => {
-        console.log('进入频道失败:', err);
+        console.error('进入频道失败:', err);
       });
   }
   /* 发布本地视频 */
@@ -277,7 +277,7 @@ export class LiveService {
   /* 订阅远程视频 */
   async joinReady() {
     this.client.remoteUsers.forEach((user: any) => {
-      console.log('remoteUsers', user.uid);
+      // console.log('remoteUsers', user.uid);
       this.client.subscribe(user, 'audio').then((audioTrack: any) => {
         // this.user_published_list.add(user);
         if (!this.user_published_list.find((item) => item.uid === user.uid)) {