dusenyao 4 years ago
parent
commit
dad62a2f2d

+ 1 - 0
src/styles/index.scss

@@ -28,6 +28,7 @@ body {
 
 ul {
   padding-inline-start: 0;
+  margin: 0;
 }
 
 #app {

+ 0 - 1
src/views/live/student/group.js

@@ -221,7 +221,6 @@ export function initListener(vue) {
    */
   rtc.on('chat_message', data => {
     let dat = JSON.parse(data);
-    console.log(dat);
     // 敏感词过滤:如果发送的聊天消息被系统判定包含敏感词,则只有发送者能收到本条消息,房间内其他人都不会收到这条聊天消息。
     // 如果返回消息中有 isFilterChat 字段(消息不包含敏感词返回数据中无isFilterChat字段),且isFilterChat的值为1,则说明该消息包含敏感字,除发送者外其他人不会收到这条消息。
     if (dat.isFilterChat && dat.isFilterChat === 1) {

+ 24 - 11
src/views/live/teacher/group.js

@@ -76,10 +76,6 @@ export function unSubscribeStream(stream) {
 export function initListener(vue) {
   rtc.on('login_success', data => {
     console.log('登录成功', data);
-    Message({
-      message: '登录成功',
-      type: 'success'
-    });
     vue.roomData = data;
   });
 
@@ -94,6 +90,10 @@ export function initListener(vue) {
   // 教师 必须在加入房间成功的事件回调里创建本地流
   rtc.on('conference_join', () => {
     console.log('加入房间成功');
+    Message({
+      message: '加入房间成功',
+      type: 'success'
+    });
     createLocalStream();
   });
 
@@ -227,13 +227,14 @@ export function initListener(vue) {
    */
   rtc.on('chat_message', data => {
     let dat = JSON.parse(data);
-    console.log(dat);
     // 敏感词过滤:如果发送的聊天消息被系统判定包含敏感词,则只有发送者能收到本条消息,房间内其他人都不会收到这条聊天消息。
     // 如果返回消息中有 isFilterChat 字段(消息不包含敏感词返回数据中无isFilterChat字段),且isFilterChat的值为1,则说明该消息包含敏感字,除发送者外其他人不会收到这条消息。
     if (dat.isFilterChat && dat.isFilterChat === 1) {
       return;
     }
-    vue.chatList.push(dat);
+    if (vue.chatList.every(item => item.chatId !== dat.chatId)) {
+      vue.chatList.push(dat);
+    }
   });
 
   rtc.on('allowChatChange', function (data) {
@@ -252,10 +253,22 @@ export function downloadWebSDK(vue) {
       'https://class.csslcloud.net/static/dist/js/classMode.js',
       'https://class.csslcloud.net/static/dist/js/classUpdateChat.js'
     ];
-    for (let i = 0; i < scriptArray.length; i++) {
-      createScript(scriptArray[i]).onload = () => {
-        vue.loadedNumber += 1;
-      };
-    }
+    scriptArray.forEach(
+      item =>
+        (createScript(item).onload = () => {
+          vue.loadedNumber += 1;
+        })
+    );
   };
 }
+
+export function removeWebSDK() {
+  let scriptArray = [
+    'https://class.csslcloud.net/sdk/websdk/hdRtc-6.7.2.js',
+    'https://class.csslcloud.net/static/dist/js/classMode.js',
+    'https://class.csslcloud.net/static/dist/js/classUpdateChat.js'
+  ];
+  scriptArray.forEach(item => {
+    document.querySelector(`script[src='${item}']`).remove();
+  });
+}

+ 1 - 3
src/views/live/teacher/group.vue

@@ -188,11 +188,9 @@ export default {
   watch: {
     loadedNumber(newVal) {
       if (newVal === 2) {
-        console.log(this.room_id);
         if (!this.room_id || !this.session_id) {
           return;
         }
-        console.log(1);
         this.rtc = common.initSDK({
           userid: this.live_room_sys_user_id,
           roomid: this.room_id,
@@ -296,7 +294,6 @@ export default {
     enterGroup(group_id) {
       JoinGroup_Teacher({ task_id: this.task_id, group_id })
         .then(({ room_id, session_id }) => {
-          console.log(room_id, session_id);
           this.room_id = room_id;
           this.session_id = session_id;
           common.downloadWebSDK(this);
@@ -318,6 +315,7 @@ export default {
           common.unSubscribeStream(item);
         });
         this.streamList = [];
+        common.removeWebSDK();
         this.$message.success('退出小组讨论成功');
       });
     }