lex-xin 3 năm trước cách đây
mục cha
commit
446b8b18cd

+ 3 - 1
src/components/live-broadcast/runtime.ts

@@ -113,6 +113,7 @@ const MessageSeatMember = RongIMLib.registerMessageType('RC:Chatroom:SeatMember'
 type MessageProps = {
 type MessageProps = {
   messageType: 'RC:Chatroom:Welcome' | 'RC:TxtMsg' | 'RC:Chatroom:Barrage' | 'RC:Chatroom:Like' | 'RC:Chatroom:SeatsCtrl' | 'RC:Chatroom:ChatBan' | 'RC:Chatroom:SeatApply',
   messageType: 'RC:Chatroom:Welcome' | 'RC:TxtMsg' | 'RC:Chatroom:Barrage' | 'RC:Chatroom:Like' | 'RC:Chatroom:SeatsCtrl' | 'RC:Chatroom:ChatBan' | 'RC:Chatroom:SeatApply',
   content: any,
   content: any,
+  senderUserId: any
 }
 }
 
 
 type MessageEvent = {
 type MessageEvent = {
@@ -129,7 +130,8 @@ const Events = RongIMLib.Events
    const { messages } = evt
    const { messages } = evt
    for (const message of messages) {
    for (const message of messages) {
     //  console.log(LIVE_EVENT_MESSAGE[message.messageType], message)
     //  console.log(LIVE_EVENT_MESSAGE[message.messageType], message)
-     if (LIVE_EVENT_MESSAGE[message.messageType]) {
+    const isSelf = message.senderUserId && Number(message.senderUserId) === state.user?.speakerId
+     if (!isSelf && LIVE_EVENT_MESSAGE[message.messageType]) {
       event.emit(LIVE_EVENT_MESSAGE[message.messageType], {...message.content, $EventMessage: message})
       event.emit(LIVE_EVENT_MESSAGE[message.messageType], {...message.content, $EventMessage: message})
      }
      }
    }
    }

+ 8 - 0
src/components/live-message/model/join-model.tsx

@@ -47,6 +47,14 @@ export default defineComponent({
     event.on(LIVE_EVENT_MESSAGE['RC:Chatroom:Leave'], this.onLeave); // 移动端接收的消息
     event.on(LIVE_EVENT_MESSAGE['RC:Chatroom:Leave'], this.onLeave); // 移动端接收的消息
     event.on(LIVE_EVENT_MESSAGE['RC:LookerLoginOut'], this.onLeave); // 后台接收的消息
     event.on(LIVE_EVENT_MESSAGE['RC:LookerLoginOut'], this.onLeave); // 后台接收的消息
   },
   },
+  unmounted() {
+    event.off(LIVE_EVENT_MESSAGE['RC:Chatroom:SeatApply'], this.onSeatApply);
+    event.off(LIVE_EVENT_MESSAGE['RC:Chatroom:SeatResponse'], this.onSeatApply);
+    event.off(LIVE_EVENT_MESSAGE['RM:RTC:UserLeave'], this.onSeatApply);
+    event.off(LIVE_EVENT_MESSAGE['RM:RTC:SwitchRole'], this.onSwitchRole);
+    event.off(LIVE_EVENT_MESSAGE['RC:Chatroom:Leave'], this.onLeave); // 移动端接收的消息
+    event.off(LIVE_EVENT_MESSAGE['RC:LookerLoginOut'], this.onLeave); // 后台接收的消息
+  },
   methods: {
   methods: {
     async onLeave(value: any) {
     async onLeave(value: any) {
       // 学生离开时处理
       // 学生离开时处理