fuliqi
2024-08-15 c68786ea6525b9b853999c2896b80c18e42448d6
教师端恢复成员列表
1个文件已修改
62 ■■■■ 已修改文件
src/views/meet/index.vue 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/meet/index.vue
@@ -51,6 +51,7 @@
<script>
import { getStudentList } from '@/api/meet'
export default {
  data() {
    return {
@@ -74,49 +75,49 @@
  },
  beforeDestroy() {
    if (this.ws) {
      this.ws.close();
      this.ws.close()
    }
  },
  methods: {
    muteEveryone() {
      this.jitsiApi.executeCommand('muteEveryone', 'audio');
      this.jitsiApi.executeCommand('muteEveryone', 'audio')
    },
    videoEveryone() {
      this.jitsiApi.executeCommand('muteEveryone', 'video');
      this.jitsiApi.executeCommand('muteEveryone', 'video')
    },
    handleCommand(command) {
      this.sendMessage(JSON.stringify(command))
    },
    initWebSocket() {
      this.ws = new WebSocket('ws://127.0.0.1:8000/websocket/' + 1);
      let ws = this.ws;
      this.ws = new WebSocket('ws://127.0.0.1:8000/websocket/' + 1)
      let ws = this.ws
      ws.onopen = () => {
        console.log('WebSocket 连接成功');
        console.log('WebSocket 连接成功')
        // 发送心跳数据
        ws.send('ping');
      };
        ws.send('ping')
      }
      ws.onmessage = (event) => {
        console.log('收到服务器消息:', event.data);
        console.log('收到服务器消息:', event.data)
        // 处理服务器发来的消息
      };
      }
      ws.onerror = (error) => {
        console.error('WebSocket 连接出错:', error);
      };
        console.error('WebSocket 连接出错:', error)
      }
      ws.onclose = () => {
        console.log('WebSocket 连接已关闭');
        console.log('WebSocket 连接已关闭')
        // 可以在这里尝试重新连接
      };
      }
      // 组件销毁时断开 WebSocket 连接
      this.$once('hook:beforeDestroy', () => {
        ws.close();
      });
        ws.close()
      })
    },
    sendMessage(message) {
      if (this.ws.readyState === WebSocket.OPEN) {
        this.ws.send(message);
        this.ws.send(message)
      } else {
        console.error('WebSocket 连接未打开');
        console.error('WebSocket 连接未打开')
      }
    },
    hiddenStudent() {
@@ -219,14 +220,9 @@
          'camera',
          // 聊天
          'chat',
          // 'closedcaptions',
          // 共享
          'desktop',
          'download',
          // 'embedmeeting',
          // 'etherpad',
          // 'feedback',
          // 'filmstrip',
          'fullscreen',
          'hangup',
          // 'help',
@@ -236,11 +232,7 @@
          'livestreaming',
          'microphone',
          'noisesuppression',
          // 'participants-pane',
          // 'profile',
          // 'raisehand',
          'recording',
          // 'security',
          'select-background',
          'settings',
          'shareaudio',
@@ -249,8 +241,18 @@
          'stats',
          'tileview',
          'toggle-camera',
          // 'videoquality',
          'whiteboard'
          'whiteboard',
          // 'closedcaptions',
          // 'embedmeeting',
          // 'etherpad',
          // 'feedback',
          // 'filmstrip',
          'participants-pane',
          // 'profile',
          'raisehand',
          // 'security',
          'videoquality',
        ],
        whiteboard: {
          enabled: true
@@ -269,7 +271,7 @@
    }, 2500)
    // 初始化
    this.initWebSocket();
    this.initWebSocket()
  },
  beforeDestroy() {
    // 清除定时器,避免内存泄漏