yangjie #22

Merged
yangqiang merged 99 commits from yangjie into master 2024-10-22 16:11:46 +08:00
2 changed files with 32 additions and 32 deletions
Showing only changes of commit 004e566964 - Show all commits

View File

@ -1,16 +1,11 @@
import styles from '@/page/Meeting/CurrentSpeakUserWindow/index.module.scss'
import { storage } from '@/utils';
import { useEffect, useState } from "react";
const CurrentSpeakUserWindow: React.FC = () => {
const [inputValue, setInputValue] = useState('')
const [user, setUser] = useState<any>({});
const [isMeSpeack, setIsMeSpeack] = useState(false)
const channel = new BroadcastChannel('meeting_channel');
const userInfo = JSON.parse(storage.getItem('user') as string)
useEffect(() => {
setUser(userInfo)
channel.onmessage = function (event) {
const { type, currentSpeakUser, uidArr } = event.data;
const { type, currentSpeakUser } = event.data;
switch (type) {
case 'currentSpeakUser':
if (currentSpeakUser.length) {
@ -18,7 +13,6 @@ const CurrentSpeakUserWindow: React.FC = () => {
} else {
setInputValue('')
}
setIsMeSpeack(uidArr.find((item: any) => item === 0) === 0 ? true : false)
break;
}
}
@ -28,8 +22,8 @@ const CurrentSpeakUserWindow: React.FC = () => {
return (
<>
<div className={styles.currentSpeakUserWindow}>
<div title={`正在说话:${isMeSpeack ? user.userName + ';' : ''} ${inputValue}`}>
{`正在说话:${isMeSpeack ? user.userName + ';' : ''} ${inputValue}`}
<div title={`正在说话: ${inputValue}`}>
{`正在说话: ${inputValue}`}
</div>
</div >
</>

View File

@ -144,6 +144,7 @@ const Meeting: React.FC = () => {
rowIndex: 0,
});
const [roomUserList, setRoomUserList] = useState<any>([])
const [_speackUid, setSpeackUid] = useState<any>([])
const [chatList, setChatList] = useState<any>([])
const [currentVideoId, setCurrentVideoId] = useState('')
let [currentSeconds, setCurrentSeconds] = useState(0)
@ -359,6 +360,24 @@ const Meeting: React.FC = () => {
}
time = setInterval(() => {
setCurrentSeconds(currentSeconds++)
setSpeackUid((uids: any) => {
const usernames: string[] = [];
setRoomUserList((res: any) => {
uids.forEach((uid: any) => {
const user = res.find((item: any) => item.uid == uid);
if (user) {
usernames.push(user.userName);
}
})
channel.postMessage({
type: 'currentSpeakUser',
currentSpeakUser: usernames,
});
return res
});
return []
})
}, 1000)
// 首次加载图标更新
const firstFooterList = [...footerList]
@ -382,9 +401,13 @@ const Meeting: React.FC = () => {
okText: '确定',
cancelText: '取消',
async onOk() {
if (stateInfo) {
changeStatusList({
title: '录制'
}, 1, 3)
} else {
message.error('当前不在会议室!')
}
},
onCancel() {
}
@ -916,27 +939,10 @@ const Meeting: React.FC = () => {
}
},
onAudioVolumeIndication: async (speakers: AudioVolumeInfo[]) => {
function checkUidsInUsers(uids: number[]): string[] {
const usernames: string[] = [];
setRoomUserList((res: any) => {
uids.forEach(uid => {
const user = res.find((item: any) => item.uid == uid);
if (user) {
usernames.push(user.userName);
}
})
return res
});
return usernames
}
if (speakers.length) {
const uidArr = (speakers.filter((item: any) => item.volume)).map(item => item.uid) as number[];
const currentSpeakUser = checkUidsInUsers(uidArr)
channel.postMessage({
type: 'currentSpeakUser',
currentSpeakUser,
uidArr
});
setSpeackUid((res: any) => {
return [...new Set([...res, ...(speakers.filter((item: any) => item.volume)).map(item => item.uid || userInfo.uid)])]
})
speakers.forEach((item: any) => {
let domMe = document.getElementById(`micr-item-${userInfo.uid}`);
let dom = document.getElementById(`micr-${item.uid ? item.uid : userInfo.uid}`);