fuliqi
2024-08-15 c68786ea6525b9b853999c2896b80c18e42448d6
教师端恢复成员列表
1个文件已修改
96 ■■■■ 已修改文件
src/views/meet/index.vue 96 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/meet/index.vue
@@ -9,7 +9,7 @@
          <el-row :gutter="5">
            <el-col :span="12">
              <el-input placeholder="搜索学员" size="small" clearable @input="getStudentList" @clear="getStudentList"
                v-model="searchForm.keyword" />
                        v-model="searchForm.keyword"/>
            </el-col>
            <el-col :span="2">
              <el-button type="primary" size="small" @click="getStudentList">搜索</el-button>
@@ -51,8 +51,9 @@
<script>
import { getStudentList } from '@/api/meet'
export default {
  data() {
  data () {
    return {
      ws: null,
      jitsiApi: null,
@@ -72,80 +73,80 @@
      showStudentList: []
    }
  },
  beforeDestroy() {
  beforeDestroy () {
    if (this.ws) {
      this.ws.close();
      this.ws.close()
    }
  },
  methods: {
    muteEveryone() {
      this.jitsiApi.executeCommand('muteEveryone', 'audio');
    muteEveryone () {
      this.jitsiApi.executeCommand('muteEveryone', 'audio')
    },
    videoEveryone() {
      this.jitsiApi.executeCommand('muteEveryone', 'video');
    videoEveryone () {
      this.jitsiApi.executeCommand('muteEveryone', 'video')
    },
    handleCommand(command) {
    handleCommand (command) {
      this.sendMessage(JSON.stringify(command))
    },
    initWebSocket() {
      this.ws = new WebSocket('ws://127.0.0.1:8000/websocket/' + 1);
      let ws = this.ws;
    initWebSocket () {
      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) {
    sendMessage (message) {
      if (this.ws.readyState === WebSocket.OPEN) {
        this.ws.send(message);
        this.ws.send(message)
      } else {
        console.error('WebSocket 连接未打开');
        console.error('WebSocket 连接未打开')
      }
    },
    hiddenStudent() {
    hiddenStudent () {
      this.showStudent = !this.showStudent
    },
    changeJitsiWindowSize(width, height) {
    changeJitsiWindowSize (width, height) {
      this.jitsiApi.resizeLargeVideo(width, height)
    },
    getShowText() {
    getShowText () {
      if (this.showStudent) {
        return '隐藏'
      } else {
        return '显示'
      }
    },
    getStatus(status) {
    getStatus (status) {
      if (status === 1) {
        return '在线'
      } else if (status === 0) {
        return '离线'
      }
    },
    handleTabChange(tab) {
    handleTabChange (tab) {
      let status = parseInt(tab.name)
      this.showStudentList = this.studentList.filter(student => {
        return student.onlineStatus === status
      })
    },
    getStudentList() {
    getStudentList () {
      let params = {
        keyword: this.searchForm.keyword
      }
@@ -156,7 +157,7 @@
        })
      })
    },
    getRoomInfo() {
    getRoomInfo () {
      this.jitsiApi.getRoomsInfo().then(rooms => {
        rooms.rooms.forEach(room => {
          // 房间的id是一个子域名,且@符前的会议名称是经过URL编码的
@@ -186,7 +187,7 @@
      })
    }
  },
  mounted() {
  mounted () {
    this.height = window.innerHeight
    this.meetId = this.$route.query.meetId
    this.getStudentList()
@@ -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,9 +271,9 @@
    }, 2500)
    // 初始化
    this.initWebSocket();
    this.initWebSocket()
  },
  beforeDestroy() {
  beforeDestroy () {
    // 清除定时器,避免内存泄漏
    if (this.intervalId) {
      clearInterval(this.intervalId)