Commit ff5e3f73 authored by 刘阳's avatar 刘阳

Merge branch 'master' of https://dev.jiuaoedu.com/huanglu/gk-online-teacher

# Conflicts: # src/views/answer-screen/index.vue # src/views/home/index.vue
parents 62eb3bf2 376de221
......@@ -6764,11 +6764,6 @@
"version": "3.8.1",
"resolved": "http://git.jksxb.cn:8081/repository/geek/core-js/-/core-js-3.8.1.tgz",
"integrity": "sha1-9RUjZorIopTRKFw7nbRAJf2mbUc="
},
"jquery": {
"version": "3.5.1",
"resolved": "http://git.jksxb.cn:8081/repository/geek/jquery/-/jquery-3.5.1.tgz",
"integrity": "sha1-17TQjhv9uGrS8aPQOeoXMEcXq7U="
}
}
},
......@@ -7667,6 +7662,11 @@
"supports-color": "^7.0.0"
}
},
"jquery": {
"version": "3.5.1",
"resolved": "http://git.jksxb.cn:8081/repository/geek/jquery/-/jquery-3.5.1.tgz",
"integrity": "sha1-17TQjhv9uGrS8aPQOeoXMEcXq7U="
},
"js-base64": {
"version": "2.6.4",
"resolved": "https://registry.npm.taobao.org/js-base64/download/js-base64-2.6.4.tgz?cache=0&sync_timestamp=1596556044168&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjs-base64%2Fdownload%2Fjs-base64-2.6.4.tgz",
......
<template>
<div class="geek-rtc-play" ref="player"></div>
<div class="geek-rtc-play" ref="player">
</div>
</template>
<script>
export default {
......
......@@ -125,9 +125,6 @@ export default class HWOnline {
await stream.initialize()
this.localStream = stream;
console.log('local stream: ', stream);
this.streams.push(stream)
this.subscribedCb(this.streams)
return stream
}
......@@ -169,6 +166,8 @@ export default class HWOnline {
console.log('stream-added: ', event)
const {stream} = event
this.client.subscribe(stream, { video: true, audio: true})
console.log('stream-added: addCb')
this.addCb(stream)
})
// 远端流删除事件,当取消选看远端用户或者原来已经选看的远端用户退出房间后会收到该事件通知。
this.client.on('stream-removed', (event) => {
......@@ -178,6 +177,7 @@ export default class HWOnline {
this.streams.splice(index, 1)
}
this.subscribedCb && this.subscribedCb(this.streams);
this.removeCb(stream)
})
// 远端流更新事件,当远端用户的流发生变化,例如添加或者移除音视频轨,视频轨规格变化时会收到该事件通知。
this.client.on('stream-updated', (event) => {
......@@ -218,6 +218,16 @@ export default class HWOnline {
this.subscribedCb = cb
}
// add
addStream(cb) {
this.addCb = cb
}
// remove
removeStream(cb) {
this.removeCb = cb
}
// 有用户加入房间的回调
userJoinCb(cb) {
this.joinCb = cb
......
<template>
<div ref="gk_screen_std" class="gk-screen-std">
<div v-if="questionType === 1 || questionType === 2" ref="vd">
<div v-if="isChoice" ref="vd">
<geek-draw-board
ref="draw"
:points="paints[currentIndex]"
......@@ -16,14 +16,9 @@
:key="itm.title"
>{{ itm.name }}
</el-button>
<el-button @click="sendAnswer"
type="primary"
class="itm"
:disabled="disabled">提交
</el-button>
</div>
</div>
<div v-if="questionType === 0">
<div v-else>
<div class="ans-wrap">
<el-button
v-for="itm in Answers"
......@@ -37,14 +32,10 @@
</el-button>
</div>
</div>
<el-button v-if="questionType === 0 "
type="primary"
@click="sendAnswer"
:disabled="disabled"
class="ans-commit">
提交
</el-button>
<div class="none" v-if="questionType === -1" >暂无题目作答,请等候老师发送</div>
<el-button type="primary" @click="sendChoose" :disabled="false" class="ans-commit">
提交
</el-button>
</div>
</template>
......@@ -78,9 +69,8 @@ export default {
paints: [],
paintType: '',
currentIndex: '',
questionType: -1,
paintTypes,
getMsg: {}
isChoice: true,
paintTypes
};
},
methods: {
......@@ -96,22 +86,13 @@ export default {
console.log(value);
this.currentAns = value;
},
sendAnswer() {
let msg = ''
if (this.questionType === 0) {
msg = this.currentAns
} else if (this.questionType === 1 || this.questionType === 2) {
msg = this.$refs.draw.getImg()
} else {
msg = ''
}
sendChoose() {
console.log('currentPaintData', this.$refs.draw.getImg());
socket.sendGroupMsg(
{
payload: {
type: this.questionType,
answer: msg,
}
type: 'answer',
message: this.currentAns,
questionType: ''
},
(data) => {
console.log('回执', data);
......@@ -121,22 +102,17 @@ export default {
},
dealMsg(msg) {
console.log('msg', msg);
this.getMsg = msg
// 42["msg",{"from":"teacher-1608135771425","type":"question",
// "payload":{"type":0,"title":"选择题"}}]
if (msg && msg.from && msg.from.indexOf('teacher') > -1 && msg.payload.type > -1) {
this.questionType = msg.payload.type
}
console.log('msg', this.questionType);
if (msg && msg.from && msg.from.indexOf('teacher') > -1 && msg.type === 'question') {
this.disabled = false;
}
}
},
beforeDestroy() {
this.getMsg = {}
socket.offMsg(this.dealMsg);
// socket.offMsg(this.dealMsg);
},
mounted() {
this.paintType = 'pencil';
socket.onMsg(this.dealMsg);
// socket.onMsg(this.dealMsg);
document.body.addEventListener('touchmove', (e) => {
e.preventDefault();
}, { passive: false });
......@@ -150,6 +126,7 @@ export default {
display: flex;
flex-flow: column;
align-items: center;
overflow: hidden;
.tools-wrap {
position: fixed;
left: 20px;
......@@ -166,7 +143,7 @@ export default {
}
}
.draw-board {
height: 100vh;
height: 80vh;
width: 100vw;
background: #f5f5f5;
}
......@@ -188,9 +165,5 @@ export default {
font-size: 40px;
margin-top: 5vh;
}
.none{
font-size: 26px;
margin-top: 40vh;
}
}
</style>
......@@ -76,7 +76,12 @@ export default {
}
const routeName = joinObj.path
socket.connect(userId, () => {
this.$router.push({ name: routeName, query: { userId, roomId: this.roomId }})
this.$router.push({
name: routeName,
query: {
userId, roomId: this.roomId, username: this.username
}
})
})
}
},
......
<template>
<div class="home">
<div class="player">
<RtcPlayer :stream="mainStream" class="local-player" />
<div v-if="mainStream"
:id="mainStream.getType() === 'local' ? mainStream.getId() : `player_${mainStream.getId()}`"
class="local-player" />
<el-button v-if="isJoin" type="primary"
@click.native="fullPlayer" class="full-screen">全屏</el-button>
</div>
<div class="side">
<el-form ref="form" label-width="80px" style="margin-top: 30px">
<!-- <el-row :gutter="8">
<el-col :span="24">
<el-form-item label="房间号">
<el-input v-model="roomId" placeholder="Please input roomid" type='number'></el-input>
</el-form-item>
</el-col>
</el-row> -->
<el-row :gutter="8">
<el-col :span="24">
<el-form-item label="麦克风">
......@@ -39,8 +34,9 @@
<el-button type="primary" @click="play">加入房间</el-button>
</div>
<div class="stream-pre">
<RtcPlayer @click="clickItm(itm)"
class="item" v-for="(itm, index) in subStreams" :stream="itm" :key="index" />
<div @click="clickItm(itm, index)"
class="item" v-for="(itm, index) in subStreams" :key="itm.getId()"
:id="itm.getType() === 'local' ? itm.getId() : `player_${itm.getId()}`" />
</div>
</div>
</div>
......@@ -49,7 +45,6 @@
<script>
// eslint-disable-next-line import/no-unresolved
import HWRTC from '@/utils/hwrtc'
import RtcPlayer from '@/components/rct-play'
export default {
data() {
......@@ -66,12 +61,12 @@ export default {
streams: [],
localStream: null,
isJoin: false,
mainId: ''
mainId: '',
mainStream: null,
}
},
name: 'Home',
components: {
RtcPlayer
},
watch: {
microId(N, O) {
......@@ -79,19 +74,15 @@ export default {
},
camerId(N, O) {
if (N !== O && this.isJoin) this.localStream.switchDevice('video', N);
}
},
},
computed: {
subStreams() {
const subs = (this.streams || []).filter((itm) => itm !== this.mainStream)
console.log('subs: **** ', subs)
const subs = (this.streams || []).filter((itm) => !this.mainStream
|| itm.getId() !== this.mainStream.getId())
console.log('===: sub', subs)
return subs
},
mainStream() {
const main = (this.streams || []).find((itm) => itm.getId() === this.mainId)
console.log('main: **** ', main)
return main
}
},
methods: {
async play() {
......@@ -100,16 +91,40 @@ export default {
this.localStream = await this.rtc.createStream(this.microId, this.camerId)
await this.rtc.publish(this.localStream)
this.isJoin = true
this.mainStream = this.localStream
this.streams.push(this.mainStream)
console.log('=====: ', this.localStream.getType())
this.$nextTick(() => {
this.playStream(this.mainStream)
})
} catch (error) {
console.log('创建失败: ', error)
}
},
playStream(stream) {
// eslint-disable-next-line no-unused-expressions
const isLocal = stream.getType() === 'local';
if (isLocal) {
console.log('===== local : ', stream)
stream.play(stream.getId(), { muted: false, objectFit: 'cover' })
} else {
console.log('===== remote', stream)
stream.play(`player_${stream.getId()}`, { muted: false, objectFit: 'cover' })
}
},
fullPlayer() {
console.log('full')
// document.querySelector('#player').requestFullscreen()
},
clickItm(itm) {
this.mainId = itm.getId()
async clickItm(itm) {
await this.mainStream.stop()
await itm.stop()
const tmp = this.mainStream
this.mainStream = itm;
this.$nextTick(() => {
this.playStream(this.mainStream)
this.playStream(tmp)
})
}
},
async mounted() {
......@@ -126,8 +141,22 @@ export default {
this.rtc = new HWRTC(userId || (new Date().getTime() / 1000).toFixed(0));
this.cameras = await this.rtc.getCameras()
this.micro = await this.rtc.getMicrophones()
this.rtc.subscribedStreamCb((streams) => {
this.streams = streams
// this.rtc.subscribedStreamCb((streams) => {
// this.streams = streams
// })
this.rtc.addStream((stream) => {
this.streams.push(stream)
console.log('add: ', stream)
setTimeout(() => {
this.playStream(stream)
}, 100);
})
this.rtc.removeStream((stream) => {
const index = this.streams.findIndex((itm) => itm.getId() === stream.getId())
console.log('removeStream::::', stream)
if (index > -1) {
this.streams.splice(index, 1)
}
})
},
beforeDestroy() {
......
......@@ -2,14 +2,25 @@
<div class="paint-main" ref="pain_main">
<img :src="currentImg" class="bg"/>
<geek-draw-board ref="draw"
:points="paints[currentIndex]" :paintType="paintType" class="draw-board" />
:points="paints[currentIndex]" paintColor='#FFF' :paintType="paintType" class="draw-board" />
<div class="tools-wrap">
<el-button class="itm" type="info" @click="changeTool(itm.title)"
v-for="itm in paintTypes" :key="itm.title">{{ itm.name }}</el-button>
</div>
<div class="stream-wrap">
<el-button class="itm" type="text" @click="steamAction(itm.title)"
v-for="itm in streamTypes" :key="itm.title">{{ itm.name }}</el-button>
<template v-for="itm in streamTypes">
<el-button class="itm" type="text" v-if="itm.type !== 'down'" @click="steamAction(itm.title)"
:key="itm.title">{{ itm.name }}</el-button>
<el-dropdown v-else :key="itm.title">
<span class="el-dropdown-link">
{{ itm.name }}
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="startAnswer(op)" v-for="op in itm.options"
:key="op.title">{{op.title}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</div>
<div class="reply-wrap">
......@@ -53,7 +64,7 @@ import {
six,
siven,
eight,
nine
nine
} from '@/assets/images/index'
import HWRTC from '@/utils/hwrtc'
import socket from '@/utils/socket'
......@@ -66,10 +77,19 @@ const paintTypes = [
]
const streamTypes = [
{ title: 'ans', name: '学生答题' },
{ title: 'publish', name: '开始推流' },
{ title: 'unpublish', name: '停止推流' },
{ title: 'setting', name: '设置' },
{
title: 'ans',
name: '学生答题',
type: 'down',
options: [
{ title: '选择题', value: 0 },
{ title: '简答题', value: 1 },
{ title: '填空题', value: 2 }
]
},
// { title: 'publish', name: '开始推流' },
// { title: 'unpublish', name: '停止推流' },
// { title: 'setting', name: '设置' },
{ title: 'full', name: '全屏' },
]
......@@ -127,6 +147,9 @@ export default {
}
this.paintType = title
},
startAnswer(opt) {
this.sendAnswerTag(opt.value, opt.title)
},
async steamAction(action) {
if (action === 'setting') {
this.modal = true
......@@ -134,27 +157,27 @@ export default {
if (action === 'publish') {
this.rtc.createStream(this.mico, this.camera)
}
if (action === 'ans') {
this.sendAnswerTag();
}
if (action === 'full') {
// eslint-disable-next-line no-unused-expressions
this.$refs.pain_main && this.$refs.pain_main.requestFullscreen();
}
},
sendAnswerTag() {
sendAnswerTag(type, title) {
this.replyList = []
socket.sendGroupMsg({
type: 'question',
options: ['A', 'B', 'C', 'D'],
message: '请答题'
payload: {
type,
title,
}
}, (res) => {
console.log('teacher send success: ', res);
})
},
registerMsgReceived() {
socket.onMsg((data) => {
this.replyList.push(data);
const { type, payload } = data
if (type === 'answer') this.replyList.push(payload);
})
},
preAction() {
......@@ -210,7 +233,7 @@ export default {
transform: translateY(-50%);
}
.bg {
height: 100vh;
height: 100vh;
width: 100vw;
}
.draw-board {
......@@ -251,8 +274,14 @@ export default {
animation: reply 1.2s linear;
}
}
::v-deep .el-button--text {
color: white;
::v-deep {
.el-button--text {
color: white;
}
.el-dropdown {
margin-right: 20px;
color: white;
}
}
}
......
......@@ -881,8 +881,8 @@
"@geek/geekui@^1.1.2":
version "1.1.2"
resolved "http://git.jksxb.cn:8081/repository/geek/@geek/geekui/-/geekui-1.1.2.tgz#bbe448fbefb1487d4b5f16596458d8062b79700f"
integrity sha512-TBPYSECTJknnBs7dSNdQLM+rnoMItpC3HBILLr3YuQCUdvmJdRsbaxlMokfEKv6a3sceAPWHCsnqEl7S4N+2yw==
resolved "http://git.jksxb.cn:8081/repository/geek/@geek/geekui/-/geekui-1.1.2.tgz#8ef29a981ee01139ee73a9389058619595df2a88"
integrity sha512-bQ5lvdCZfFb8gy4iNsphljJBA/eUgJe6vzrIF+u0JXlS+7aGCvO3nOIqbkUwEEUBJHZfiz/XzISy+59gJCobgw==
dependencies:
"@geek/geek-editor" "^1.0.7"
cos-js-sdk-v5 "^0.5.27"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment