Commit e83e7380 authored by huanglu's avatar huanglu

feat: update

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