From 3b61578baaf39e9ccc31ca00f0312d0265ad3eba Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Mon, 24 Feb 2025 16:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=91=98=E8=A7=82=E7=9C=8B-=E6=B4=BB?= =?UTF-8?q?=E8=B7=83=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/meeting/index.ts | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/pages/meeting/index.ts b/pages/meeting/index.ts index c2866b8..7a4e617 100644 --- a/pages/meeting/index.ts +++ b/pages/meeting/index.ts @@ -10,6 +10,7 @@ const computedBehavior = require('miniprogram-computed').behavior; let reconnectTime = "" as any; let refreshTime = "" as any; let isAutoApplySpeakTime = "" as any; +let isSpeakTime = "" as any; Page({ behaviors: [computedBehavior], data: { @@ -114,7 +115,8 @@ Page({ userNumer: roomUserList.filter((item: any) => item.isRoom).length, audioList: roomUserList.map(item => { return { - volume: 0, + volume: item.volume || '0%', + volumeNumber: item.volumeNumber || 0, uid: item.uid, } }) @@ -282,6 +284,25 @@ Page({ } else { this.reconnecFun() } + isSpeakTime = setInterval(() => { + function getMaxObject(arr) { + let maxObject = arr[0]; + for (let i = 1; i < arr.length; i++) { + if (arr[i].volumeNumber > maxObject.volumeNumber) { + maxObject = arr[i]; + } + } + return maxObject; + } + const isShare = this.data.roomUserList.find(item => item.shareSrc) + const item = getMaxObject(this.data.audioList) + const user = this.data.roomUserList.find(row => item.uid === row.uid) + if (this.data.currentUid !== item.uid && !isShare && (user && user.isRoom)) { + this.setData({ + currentUid: item.uid + }) + } + }, 3000) }, // 隐藏 onHide() { @@ -377,6 +398,10 @@ Page({ clearTimeout(isAutoApplySpeakTime) isAutoApplySpeakTime = '' } + if (isSpeakTime) { + clearTimeout(isSpeakTime) + isSpeakTime = '' + } }, // 显示聊天输入框 showInputPopup() { @@ -1023,6 +1048,7 @@ Page({ const item = audioListTemp.find(row => row.uid == uid) if (item) { item.volume = Math.floor(percentage) + '%' + item.volumeNumber = Math.floor(percentage) } this.setData({ audioList: audioListTemp, @@ -1032,9 +1058,14 @@ Page({ // 切换视频 clickChangeVideo(e) { const { item } = e.currentTarget.dataset; - this.setData({ - currentUid: item.uid - }) + const isShare = this.data.roomUserList.find(item => item.shareSrc) + if (isShare) { + this.message(`正在进行屏幕共享,不允许切换画面。`).error() + } else { + this.setData({ + currentUid: item.uid + }) + } }, // 悬浮提示 message(content: string) {