| | |
| | | <el-tab-pane label="在线学员" name="1"></el-tab-pane> |
| | | <el-tab-pane label="离线学员" name="0"></el-tab-pane> |
| | | </el-tabs> |
| | | <el-row :gutter="20" v-for="student in showStudentList" :key="student.id" class="student-row"> |
| | | <el-col :span="18"> |
| | | <div> |
| | | {{ student.realName }} |
| | | <el-table :data="showStudentList" style="width: 100%"> |
| | | <el-table-column prop="realName" label="学员姓名"></el-table-column> |
| | | <el-table-column prop="id" label="操作" width="80px;"> |
| | | <template slot-scope="scope"> |
| | | <el-dropdown trigger="click" @command="handleCommand"> |
| | | <i class="el-icon-more-outline" id="more"></i> |
| | | <el-dropdown-menu slot="dropdown"> |
| | | <el-dropdown-item :command="{ command: 'openCamera', id: scope.row.id }">打开摄像头</el-dropdown-item> |
| | | <el-dropdown-item :command="{ command: 'mute', id: scope.row.id }">静音</el-dropdown-item> |
| | | <el-dropdown-item :command="{ command: 'kickOut', id: scope.row.id }">踢出</el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="onlineStatus" label="状态" width="80px;"> |
| | | <template slot-scope="scope"> |
| | | <div :class="{ online: scope.row.onlineStatus === 1, outline: scope.row.onlineStatus === 0 }"> |
| | | {{ getStatus(scope.row.onlineStatus) }} |
| | | </div> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <div :class="{online: student.onlineStatus === 1, outline: student.onlineStatus === 0}"> |
| | | {{ getStatus(student.onlineStatus) }} |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <el-button class="link-left" type="primary" size="small" @click="muteEveryone">全体静音</el-button> |
| | | </el-row> |
| | | </div> |
| | | </div> |
| | |
| | | |
| | | <script> |
| | | import { getStudentList } from '@/api/meet' |
| | | |
| | | export default { |
| | | data () { |
| | | return { |
| | | ws: null, |
| | | jitsiApi: null, |
| | | width: 0, |
| | | height: 0, |
| | |
| | | showStudentList: [] |
| | | } |
| | | }, |
| | | beforeDestroy() { |
| | | if (this.ws) { |
| | | this.ws.close(); |
| | | } |
| | | }, |
| | | methods: { |
| | | muteEveryone() { |
| | | 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; |
| | | ws.onopen = () => { |
| | | console.log('WebSocket 连接成功'); |
| | | // 发送心跳数据 |
| | | ws.send('ping'); |
| | | }; |
| | | ws.onmessage = (event) => { |
| | | console.log('收到服务器消息:', event.data); |
| | | // 处理服务器发来的消息 |
| | | }; |
| | | ws.onerror = (error) => { |
| | | console.error('WebSocket 连接出错:', error); |
| | | }; |
| | | ws.onclose = () => { |
| | | console.log('WebSocket 连接已关闭'); |
| | | // 可以在这里尝试重新连接 |
| | | }; |
| | | |
| | | // 组件销毁时断开 WebSocket 连接 |
| | | this.$once('hook:beforeDestroy', () => { |
| | | ws.close(); |
| | | }); |
| | | }, |
| | | sendMessage(message) { |
| | | if (this.ws.readyState === WebSocket.OPEN) { |
| | | this.ws.send(message); |
| | | } else { |
| | | console.error('WebSocket 连接未打开'); |
| | | } |
| | | }, |
| | | hiddenStudent () { |
| | | this.showStudent = !this.showStudent |
| | | }, |
| | |
| | | this.intervalId = setInterval(() => { |
| | | this.getRoomInfo() |
| | | }, 2500) |
| | | |
| | | // 初始化 |
| | | this.initWebSocket(); |
| | | }, |
| | | beforeDestroy () { |
| | | // 清除定时器,避免内存泄漏 |
| | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | /deep/ thead { |
| | | display: none; |
| | | } |
| | | |
| | | #more:hover { |
| | | cursor: pointer; |
| | | } |
| | | |
| | | #meet { |
| | | height: 100%; |
| | | } |