mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-17 14:42:51 +00:00
perf: 优化会议
This commit is contained in:
parent
1acfd7ee34
commit
8a4b0c57f9
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="meeting-warp">
|
<div class="meeting-warp" :class="{'meeting-full': $isSubElectron}">
|
||||||
<!-- 加入/新建 -->
|
<!-- 加入/新建 -->
|
||||||
<Modal
|
<Modal
|
||||||
v-model="addShow"
|
v-model="addShow"
|
||||||
@ -121,6 +121,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.meeting-full {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
import {mapState} from 'vuex'
|
import {mapState} from 'vuex'
|
||||||
import Player from "./player.vue";
|
import Player from "./player.vue";
|
||||||
@ -486,11 +496,7 @@ export default {
|
|||||||
content: '确定要离开会议吗?',
|
content: '确定要离开会议吗?',
|
||||||
cancelText: '继续',
|
cancelText: '继续',
|
||||||
okText: '退出',
|
okText: '退出',
|
||||||
onOk: async _ => {
|
onOk: this.onBeforeClose
|
||||||
await this.leave()
|
|
||||||
this.onBeforeClose()
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -500,14 +506,16 @@ export default {
|
|||||||
const modal = type === 'warning' ? $A.modalWarning : $A.modalError;
|
const modal = type === 'warning' ? $A.modalWarning : $A.modalError;
|
||||||
modal({
|
modal({
|
||||||
content: msg,
|
content: msg,
|
||||||
onOk: async _ => {
|
onOk: this.onBeforeClose
|
||||||
this.onBeforeClose()
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onBeforeClose() {
|
async onBeforeClose() {
|
||||||
|
try {
|
||||||
|
await this.leave()
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
if ($A.isSubElectron) {
|
if ($A.isSubElectron) {
|
||||||
this.$Electron.sendMessage('windowDestroy');
|
this.$Electron.sendMessage('windowDestroy');
|
||||||
} else if (this.addData.sharekey) {
|
} else if (this.addData.sharekey) {
|
||||||
@ -580,27 +588,33 @@ export default {
|
|||||||
const localTracks = [];
|
const localTracks = [];
|
||||||
try {
|
try {
|
||||||
this.localUser.uid = await this.agoraClient.join(options.appid, options.channel, options.token, options.uid)
|
this.localUser.uid = await this.agoraClient.join(options.appid, options.channel, options.token, options.uid)
|
||||||
if (this.addData.tracks.includes("audio")) {
|
// 创建本地音频和视频轨道
|
||||||
localTracks.push(this.localUser.audioTrack = await AgoraRTC.createMicrophoneAudioTrack())
|
await Promise.all(['audio', 'video'].map(async (trackType) => {
|
||||||
}
|
const createTrack = trackType === 'audio' ? AgoraRTC.createMicrophoneAudioTrack : AgoraRTC.createCameraVideoTrack;
|
||||||
if (this.addData.tracks.includes("video")) {
|
const trackKey = `${trackType}Track`;
|
||||||
localTracks.push(this.localUser.videoTrack = await AgoraRTC.createCameraVideoTrack())
|
try {
|
||||||
}
|
this.localUser[trackKey] = await createTrack();
|
||||||
|
localTracks.push(this.localUser[trackKey]);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code === 'DEVICE_NOT_FOUND') {
|
||||||
|
console.warn(`${trackType} device not found:`, e);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
// 将本地视频曲目播放到本地浏览器、将本地音频和视频发布到频道。
|
// 将本地视频曲目播放到本地浏览器、将本地音频和视频发布到频道。
|
||||||
if (localTracks.length > 0) {
|
if (localTracks.length > 0) {
|
||||||
await this.agoraClient.publish(localTracks);
|
await this.agoraClient.publish(localTracks);
|
||||||
}
|
}
|
||||||
//
|
// 显示会议组件
|
||||||
this.meetingShow = true;
|
this.meetingShow = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
$A.modalError({
|
$A.modalError({
|
||||||
language: false,
|
language: false,
|
||||||
content: getErrorMessage(error.code, getLanguage()) || this.$L("会议组件加载失败!"),
|
content: getErrorMessage(error.code, getLanguage()) || this.$L("会议组件加载失败!"),
|
||||||
onOk: async _ => {
|
onOk: this.onBeforeClose
|
||||||
this.onBeforeClose()
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
@ -633,9 +647,17 @@ export default {
|
|||||||
async openAudio() {
|
async openAudio() {
|
||||||
if (this.audioLoad || this.localUser.audioTrack) return;
|
if (this.audioLoad || this.localUser.audioTrack) return;
|
||||||
this.audioLoad = true;
|
this.audioLoad = true;
|
||||||
this.localUser.audioTrack = await AgoraRTC.createMicrophoneAudioTrack()
|
try {
|
||||||
await this.agoraClient.publish([this.localUser.audioTrack]);
|
this.localUser.audioTrack = await AgoraRTC.createMicrophoneAudioTrack()
|
||||||
this.audioLoad = false;
|
await this.agoraClient.publish([this.localUser.audioTrack]);
|
||||||
|
} catch (e) {
|
||||||
|
$A.modalError({
|
||||||
|
language: false,
|
||||||
|
content: getErrorMessage(e.code, getLanguage()) || this.$L("开启麦克风失败!"),
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
this.audioLoad = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async closeAudio() {
|
async closeAudio() {
|
||||||
@ -651,9 +673,17 @@ export default {
|
|||||||
async openVideo() {
|
async openVideo() {
|
||||||
if (this.videoLoad || this.localUser.videoTrack) return;
|
if (this.videoLoad || this.localUser.videoTrack) return;
|
||||||
this.videoLoad = true;
|
this.videoLoad = true;
|
||||||
this.localUser.videoTrack = await AgoraRTC.createCameraVideoTrack()
|
try {
|
||||||
await this.agoraClient.publish([this.localUser.videoTrack]);
|
this.localUser.videoTrack = await AgoraRTC.createCameraVideoTrack()
|
||||||
this.videoLoad = false;
|
await this.agoraClient.publish([this.localUser.videoTrack]);
|
||||||
|
} catch (e) {
|
||||||
|
$A.modalError({
|
||||||
|
language: false,
|
||||||
|
content: getErrorMessage(e.code, getLanguage()) || this.$L("开启摄像头失败!"),
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
this.videoLoad = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async closeVideo() {
|
async closeVideo() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user