Commit e83e7380 authored by huanglu's avatar huanglu

feat: update

parent 4d7d9208
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title> <title>直播课堂</title></title>
<% for (var i in htmlWebpackPlugin.options.cdn && <% for (var i in htmlWebpackPlugin.options.cdn &&
htmlWebpackPlugin.options.cdn.js) { %> htmlWebpackPlugin.options.cdn.js) { %>
<script type="text/javascript" src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script> <script type="text/javascript" src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
......
...@@ -15,6 +15,19 @@ export default { ...@@ -15,6 +15,19 @@ export default {
name: 'sfsfs' name: 'sfsfs'
} }
}, },
watch: {
$route(N) {
if (!this._title) {
this._title = window.document.title;
}
if (N.meta && N.meta.title) {
window.document.title = N.meta.title;
} else {
window.document.title = this._title;
this._title = null;
}
}
},
mounted() { mounted() {
}, },
methods: { methods: {
......
...@@ -19,27 +19,42 @@ const routes = [ ...@@ -19,27 +19,42 @@ const routes = [
{ {
path: '/home', path: '/home',
name: 'online-room', name: 'online-room',
component: OnlineRoom component: OnlineRoom,
meta: {
title: '直播页面'
}
}, },
{ {
path: '/paint', path: '/paint',
name: 'paint', name: 'paint',
component: PainScreen component: PainScreen,
meta: {
title: '老师课件页面'
}
}, },
{ {
path: '/ans-screen', path: '/ans-screen',
name: 'ans-screen', name: 'ans-screen',
component: AnswerScreen component: AnswerScreen,
meta: {
title: '学生答题页面'
}
}, },
{ {
path: '/big-screen', path: '/big-screen',
name: 'big-screen', name: 'big-screen',
component: DashScreen component: DashScreen,
meta: {
title: '教室大屏'
}
}, },
{ {
path: '/', path: '/',
name: 'home', name: 'home',
component: Home component: Home,
meta: {
title: '首页'
}
}, },
]; ];
......
...@@ -78,6 +78,10 @@ export default class HWOnline { ...@@ -78,6 +78,10 @@ export default class HWOnline {
}) })
} }
switchRole(role) {
this.client.switchRole(role)
}
leaveRoom() { leaveRoom() {
this.localStream && this.localStream.close() this.localStream && this.localStream.close()
this.client && this.client.leave() this.client && this.client.leave()
...@@ -110,7 +114,7 @@ export default class HWOnline { ...@@ -110,7 +114,7 @@ export default class HWOnline {
/** 创建本地流并发布 */ /** 创建本地流并发布 */
createStream = async (microphoneId, cameraId) => { createStream = async (microphoneId, cameraId) => {
const stream = HRTC.createStream({ const stream = HRTC.createStream({
audio: !!microphoneId, audio: false,
microphoneId, microphoneId,
video: !!cameraId, video: !!cameraId,
cameraId, cameraId,
...@@ -167,7 +171,7 @@ export default class HWOnline { ...@@ -167,7 +171,7 @@ export default class HWOnline {
const {stream} = event const {stream} = event
this.client.subscribe(stream, { video: true, audio: true}) this.client.subscribe(stream, { video: true, audio: true})
console.log('stream-added: addCb') console.log('stream-added: addCb')
this.addCb(stream) this.addCb && this.addCb(stream)
}) })
// 远端流删除事件,当取消选看远端用户或者原来已经选看的远端用户退出房间后会收到该事件通知。 // 远端流删除事件,当取消选看远端用户或者原来已经选看的远端用户退出房间后会收到该事件通知。
this.client.on('stream-removed', (event) => { this.client.on('stream-removed', (event) => {
...@@ -177,7 +181,7 @@ export default class HWOnline { ...@@ -177,7 +181,7 @@ export default class HWOnline {
this.streams.splice(index, 1) this.streams.splice(index, 1)
} }
this.subscribedCb && this.subscribedCb(this.streams); this.subscribedCb && this.subscribedCb(this.streams);
this.removeCb(stream) this.removeCb && this.removeCb(stream)
}) })
// 远端流更新事件,当远端用户的流发生变化,例如添加或者移除音视频轨,视频轨规格变化时会收到该事件通知。 // 远端流更新事件,当远端用户的流发生变化,例如添加或者移除音视频轨,视频轨规格变化时会收到该事件通知。
this.client.on('stream-updated', (event) => { this.client.on('stream-updated', (event) => {
......
...@@ -3,7 +3,7 @@ import axios from 'axios' ...@@ -3,7 +3,7 @@ import axios from 'axios'
// const socketUrl = 'ws://payx.jkwljy.com/socket.io' // const socketUrl = 'ws://payx.jkwljy.com/socket.io'
const socketUrl = 'http://172.10.1.201:7001/' const socketUrl = 'http://192.168.32.53:7001/'
const http = axios.create({ const http = axios.create({
baseURL: socketUrl, baseURL: socketUrl,
......
...@@ -185,12 +185,13 @@ export default { ...@@ -185,12 +185,13 @@ export default {
text-align: center; text-align: center;
.ans-itm { .ans-itm {
font-size: 40px; font-size: 40px;
width: 20vw; width: 15vw;
height: 20vh; height: 20vh;
margin: 10px 30px; margin: 10px 30px;
background: rgb(135, 162, 192);
} }
.ans-itm-select { .ans-itm-select {
background-color: rgb(29, 126, 236); background-color: rgb(10, 66, 131);
} }
} }
.ans-commit { .ans-commit {
......
...@@ -43,11 +43,13 @@ import socket from '@/utils/socket' ...@@ -43,11 +43,13 @@ import socket from '@/utils/socket'
const joinTypes = [ const joinTypes = [
{title: '学生大屏', value: 'student', path: 'big-screen'}, {title: '学生大屏', value: 'student', path: 'big-screen'},
{title: '老师课件', value: 'teacher', path: 'paint'},
// 老师预览的效果应该和学生的效果一样 // 老师预览的效果应该和学生的效果一样
{title: '老师预览', value: 'teacher-pre', path: 'big-screen'}, {title: '老师预览', value: 'teacher-pre', path: 'big-screen'},
{title: '普通直播', value: 'online', path: 'online-room'}, {title: '普通直播', value: 'online', path: 'online-room'},
{title: '学习答题', value: 'student-ans', path: 'ans-screen'}, {title: '学习答题', value: 'student-ans', path: 'ans-screen'},
{title: '老师课件', value: 'teacher', path: 'paint'},
] ]
export default { export default {
...@@ -69,12 +71,13 @@ export default { ...@@ -69,12 +71,13 @@ export default {
} }
const joinObj = this.joinTypes.find((itm) => itm.title === this.joinType) const joinObj = this.joinTypes.find((itm) => itm.title === this.joinType)
let userId = null let userId = null
if (joinObj.value.includes('teacher')) { if (joinObj.value.includes('teacher') || this.username.includes('teacher') > -1) {
userId = `teacher-${new Date().getTime()}` userId = `teacher-${new Date().getTime()}`
} else { } else {
userId = `${new Date().getTime()}` userId = `${new Date().getTime()}`
} }
const routeName = joinObj.path const routeName = joinObj.path
if (joinObj.value === 'student-ans' || joinObj.value === 'teacher') {
socket.connect(userId, () => { socket.connect(userId, () => {
this.$router.push({ this.$router.push({
name: routeName, name: routeName,
...@@ -83,6 +86,14 @@ export default { ...@@ -83,6 +86,14 @@ export default {
} }
}) })
}) })
} else {
this.$router.push({
name: routeName,
query: {
userId, roomId: this.roomId, username: this.username
}
})
}
} }
}, },
mounted() { mounted() {
......
...@@ -106,10 +106,10 @@ export default { ...@@ -106,10 +106,10 @@ export default {
const isLocal = stream.getType() === 'local'; const isLocal = stream.getType() === 'local';
if (isLocal) { if (isLocal) {
console.log('===== local : ', stream) console.log('===== local : ', stream)
stream.play(stream.getId(), { muted: false, objectFit: 'cover' }) stream.play(stream.getId(), { muted: false, objectFit: 'contain' })
} else { } else {
console.log('===== remote', stream) console.log('===== remote', stream)
stream.play(`player_${stream.getId()}`, { muted: false, objectFit: 'cover' }) stream.play(`player_${stream.getId()}`, { muted: false, objectFit: 'contain' })
} }
}, },
fullPlayer() { fullPlayer() {
...@@ -149,7 +149,7 @@ export default { ...@@ -149,7 +149,7 @@ export default {
console.log('add: ', stream) console.log('add: ', stream)
setTimeout(() => { setTimeout(() => {
this.playStream(stream) this.playStream(stream)
}, 100); }, 500);
}) })
this.rtc.removeStream((stream) => { this.rtc.removeStream((stream) => {
const index = this.streams.findIndex((itm) => itm.getId() === stream.getId()) const index = this.streams.findIndex((itm) => itm.getId() === stream.getId())
......
...@@ -2,31 +2,21 @@ ...@@ -2,31 +2,21 @@
<div class="paint-main" ref="pain_main"> <div class="paint-main" ref="pain_main">
<img :src="currentImg" class="bg"/> <img :src="currentImg" class="bg"/>
<geek-draw-board ref="draw" draw-type="mouse" <geek-draw-board ref="draw" draw-type="mouse"
:points="paints[currentIndex]" paintColor='#F0F' :paintType="paintType" class="draw-board" /> :paints="paints[currentIndex]" paintColor='#F0F' :paintType="paintType" class="draw-board" />
<div class="tools-wrap"> <div class="tools-wrap">
<el-button class="itm" type="info" @click="changeTool(itm.title)" <template v-for="itm in paintTypes">
v-for="itm in paintTypes" :key="itm.title">{{ itm.name }}</el-button> <el-button class="itm" v-if="itm.type !== 'down'" type="info" @click="changeTool(itm.title)"
</div>
<div class="stream-wrap">
<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> :key="itm.title">{{ itm.name }}</el-button>
<el-dropdown v-else :key="itm.title"> <div v-else :key="itm.title" style="position: relative;">
<span class="el-dropdown-link"> <el-button type="info"
{{ itm.name }} class="itm" @click.stop="ansModal = true">{{ itm.name }}</el-button>
</span> <div v-if="ansModal" class="down-item">
<el-dropdown-menu slot="dropdown"> <span class="item" @click.stop="handleToolItm(opt)"
<el-dropdown-item @click.native="startAnswer(op)" v-for="op in itm.options" v-for="opt in itm.options" :key="opt.title">{{ opt.title }}</span>
:key="op.title">{{op.title}}</el-dropdown-item> </div>
</el-dropdown-menu> </div>
</el-dropdown>
</template> </template>
</div> </div>
<!-- <div class="reply-wrap">
<span class="itm" v-for="(itm, index) in replyList"
:key="index">{{ JSON.stringify(itm) }}</span>
</div> -->
<el-dialog title="推流设置" <el-dialog title="推流设置"
width="400px" width="400px"
:visible.sync="modal"> :visible.sync="modal">
...@@ -50,26 +40,26 @@ ...@@ -50,26 +40,26 @@
</el-dialog> </el-dialog>
<el-button type="text" @click="preAction" class="pre">上一页</el-button> <el-button type="text" @click="preAction" class="pre">上一页</el-button>
<el-button type="text" @click="nextAction" class="next">下一页</el-button> <el-button type="text" @click="nextAction" class="next">下一页</el-button>
<el-popover <!--
placement="bottom" <div class="down-item">
title="" <span class="item" @click.stop="handleToolItm(opt)"
width="100" v-for="opt in itm.options" :key="opt.title">{{ opt.title }}</span>
trigger="click" </div> -->
content="回答内容">
<div slot="reference" class="reply-tips"> <div class="reply-tips">
<el-badge :value="(replyList || []).length" class="item"> <el-badge :value="(replyList || []).length" class="item">
<el-button size="small">回答</el-button> <el-button @click.stop="showAnsModal = !showAnsModal" size="small">回答</el-button>
</el-badge> </el-badge>
</div> <div class="std-ans" v-if="showAnsModal">
<template v-for="(itm, index) in replyList"> <template v-for="(itm, index) in replyList">
<p v-if="itm.type === 1 || itm.type === 2" :key="index"> <p class="st-itm" v-if="itm.type === 1 || itm.type === 2" :key="index">
<span>{{ itm.username }} 回答</span> <span>{{ itm.username }} 回答</span>
<img style="width: 50px; height: 50px; vertical-align: middle; background: white" <img class="img" :src="itm.answer" alt="" />
:src="itm.answer" alt="" />
</p> </p>
<p v-else :key="index">{{ itm.username }} 回答: {{ itm.answer }}</p> <p class="st-itm" v-else :key="index">{{ itm.username }} 回答: {{ itm.answer }}</p>
</template> </template>
</el-popover> </div>
</div>
</div> </div>
</template> </template>
<script> <script>
...@@ -94,9 +84,6 @@ const paintTypes = [ ...@@ -94,9 +84,6 @@ const paintTypes = [
{ title: 'redo', name: '撤回' }, { title: 'redo', name: '撤回' },
{ title: 'erase', name: '橡皮擦', width: 50 }, { title: 'erase', name: '橡皮擦', width: 50 },
{ title: 'clear', name: '清空' }, { title: 'clear', name: '清空' },
]
const streamTypes = [
{ {
title: 'ans', title: 'ans',
name: '学生答题', name: '学生答题',
...@@ -107,12 +94,12 @@ const streamTypes = [ ...@@ -107,12 +94,12 @@ const streamTypes = [
{ title: '填空题', value: 2 } { title: '填空题', value: 2 }
] ]
}, },
// { title: 'publish', name: '开始推流' },
// { title: 'unpublish', name: '停止推流' },
// { title: 'setting', name: '设置' },
{ title: 'full', name: '全屏' }, { title: 'full', name: '全屏' },
] ]
const streamTypes = [
]
const imgs = [ const imgs = [
one, one,
two, two,
...@@ -145,7 +132,9 @@ export default { ...@@ -145,7 +132,9 @@ export default {
replyList: [], replyList: [],
paints: [], paints: [],
imgs, imgs,
currentIndex: 0 currentIndex: 0,
ansModal: false,
showAnsModal: false
}; };
}, },
computed: { computed: {
...@@ -165,9 +154,16 @@ export default { ...@@ -165,9 +154,16 @@ export default {
this.$refs.draw && this.$refs.draw[title](); this.$refs.draw && this.$refs.draw[title]();
return return
} }
if (title === 'pencil' || title === 'erase') {
this.paintType = title this.paintType = title
}
if (title === 'full') {
// eslint-disable-next-line no-unused-expressions
this.$refs.pain_main && this.$refs.pain_main.requestFullscreen();
}
}, },
startAnswer(opt) { handleToolItm(opt) {
this.ansModal = false
this.sendAnswerTag(opt.value, opt.title) this.sendAnswerTag(opt.value, opt.title)
}, },
async steamAction(action) { async steamAction(action) {
...@@ -199,7 +195,14 @@ export default { ...@@ -199,7 +195,14 @@ export default {
const { type, payload } = data || {} const { type, payload } = data || {}
const { username = '' } = payload || {} const { username = '' } = payload || {}
if (type === 'answer') { if (type === 'answer') {
this.$message(`${username} 提交答案`) // this.$notify.info({
// title: `${username}`,
// message: '提交了答案'
// });
this.$notify({
dangerouslyUseHTMLString: true,
message: `<h1>${username} 提交了答案</h1>`
});
this.replyList.push(payload); this.replyList.push(payload);
} }
}) })
...@@ -220,16 +223,9 @@ export default { ...@@ -220,16 +223,9 @@ export default {
async mounted() { async mounted() {
this.paintType = 'pencil' this.paintType = 'pencil'
const { roomId } = this.$route.query const { roomId } = this.$route.query
const ok = await HWRTC.getAuthUserMedia() // const ok = await HWRTC.getAuthUserMedia()
if (!ok) {
this.$alert('无摄像头和和麦克风权限');
return;
}
this.rtc = new HWRTC(`teacher${(new Date().getTime() / 1000).toFixed(0)}`); this.rtc = new HWRTC(`teacher${(new Date().getTime() / 1000).toFixed(0)}`);
this.cameras = await this.rtc.getCameras() await this.rtc.joinRoom(roomId, 2)
this.camera = (this.cameras[0] || {}).deviceId
this.micros = await this.rtc.getMicrophones()
await this.rtc.joinRoom(roomId)
this.isJoin = true this.isJoin = true
this.mico = (this.micros[0] || {}).deviceId this.mico = (this.micros[0] || {}).deviceId
this.registerMsgReceived() this.registerMsgReceived()
...@@ -237,6 +233,10 @@ export default { ...@@ -237,6 +233,10 @@ export default {
document.body.addEventListener('touchmove', (e) => { document.body.addEventListener('touchmove', (e) => {
e.preventDefault(); e.preventDefault();
}, { passive: false }); }, { passive: false });
this.$el.addEventListener('click', () => {
this.ansModal = false
this.showAnsModal = false
}, false)
} }
} }
</script> </script>
...@@ -278,10 +278,26 @@ export default { ...@@ -278,10 +278,26 @@ export default {
.itm { .itm {
display: inline-block; display: inline-block;
font-size: 12px; font-size: 12px;
width: 70px; width: 80px;
margin-top: 10px; margin-top: 10px;
margin-left: 0; margin-left: 0;
} }
.down-item {
position: absolute;
left: 120%;
top: -50%;
background: white;
border-radius: 5px;
display: flex;
flex-flow: column;
width: 140px;
align-items: stretch;
.item {
padding: 10px;
font-size: 16px;
text-align: center;
}
}
} }
.stream-wrap { .stream-wrap {
position: fixed; position: fixed;
...@@ -297,11 +313,34 @@ export default { ...@@ -297,11 +313,34 @@ export default {
.itm { .itm {
animation: reply 1.2s linear; animation: reply 1.2s linear;
} }
} }
.reply-tips { .reply-tips {
position: absolute; position: absolute;
top: 50px; top: 50px;
right: 10px; right: 50px;
.std-ans {
position: absolute;
background: white;
right: 0;
top: 50px;
width: 300px;
max-height: 400px;
overflow: auto;
border-radius: 5px;
box-shadow: 0px 10px 20px 0px rgba(221, 221, 221, 0.3);
.st-itm {
padding: 15px;
font-size: 32px;
}
.img {
height: 100px;
width: 100px;
border: 1px solid #647181;
background: lightgray;
vertical-align: middle;
}
}
} }
::v-deep { ::v-deep {
.el-button--text { .el-button--text {
...@@ -327,3 +366,21 @@ export default { ...@@ -327,3 +366,21 @@ export default {
} }
} }
</style> </style>
<style lang="scss">
.down-item {
display: flex;
flex-flow: column;
align-items: stretch;
.item {
padding: 10px;
color: rgb(138, 102, 102);
font-size: 16px;
cursor: pointer;
text-align: center;
&:hover {
background: lightcyan;
}
}
}
</style>
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