This commit is contained in:
parent
fc24cb4948
commit
961a64ef6c
|
|
@ -108,6 +108,7 @@ const Meeting: React.FC = () => {
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
})
|
})
|
||||||
const [roomUserList, setRoomUserList] = useState<any>([])
|
const [roomUserList, setRoomUserList] = useState<any>([])
|
||||||
|
const [chatList, setChatList] = useState<any>([])
|
||||||
|
|
||||||
const [list] = useState<number[]>([1, 2, 3, 4, 5, 6, 7])
|
const [list] = useState<number[]>([1, 2, 3, 4, 5, 6, 7])
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
|
@ -134,7 +135,8 @@ const Meeting: React.FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
roomUserList.forEach((item: any) => {
|
roomUserList.forEach((item: any) => {
|
||||||
let dom = document.getElementById(`video-${item.account}`) as HTMLElement
|
let dom = document.getElementById(`video-${item.account}`) as HTMLElement
|
||||||
if (!dom.hasChildNodes()) {
|
if (!dom.getAttribute('load')) {
|
||||||
|
dom.setAttribute('load', 'true')
|
||||||
agora.setVideo({
|
agora.setVideo({
|
||||||
account: Number(item.account),
|
account: Number(item.account),
|
||||||
view: dom,
|
view: dom,
|
||||||
|
|
@ -145,8 +147,11 @@ const Meeting: React.FC = () => {
|
||||||
}, [roomUserList]);
|
}, [roomUserList]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onSignalr((message: any) => {
|
onSignalr((item: any) => {
|
||||||
console.log(message,'嘻嘻嘻');
|
console.log(item);
|
||||||
|
const newChatList = [...chatList]
|
||||||
|
newChatList.push(item)
|
||||||
|
setChatList(newChatList)
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
// 操作按钮
|
// 操作按钮
|
||||||
|
|
@ -401,18 +406,20 @@ const Meeting: React.FC = () => {
|
||||||
}} />
|
}} />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.meetingUserChatContent}>
|
<div className={styles.meetingUserChatContent}>
|
||||||
{list.map((item: number) =>
|
{chatList.map((item: any, index: number) =>
|
||||||
<div key={item} className={`${styles.meetingUserChatContentLeft} drag`}>
|
<div
|
||||||
|
key={index}
|
||||||
|
className={`${item.uid !== state.uid ? styles.meetingUserChatContentLeft : styles.meetingUserChatContentRight} drag`}>
|
||||||
<div>
|
<div>
|
||||||
<div><img src={ImageUrl.avatar} alt="" /></div>
|
<div><img src={ImageUrl.avatar} alt="" /></div>
|
||||||
<span>潇潇</span>
|
<span>{item.userName}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>哈哈哈哈</div>
|
<div>{item.message}</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={`${styles.meetingUserChatInput} drag`}>
|
<div className={`${styles.meetingUserChatInput} drag`}>
|
||||||
<Input.TextArea placeholder="请输入消息" style={{ flexGrow: 1 }} onChange={(e) => {
|
<Input.TextArea placeholder="请输入消息" value={textMsg} style={{ flexGrow: 1 }} onChange={(e) => {
|
||||||
setTextMsg(e.target.value)
|
setTextMsg(e.target.value)
|
||||||
}}></Input.TextArea>
|
}}></Input.TextArea>
|
||||||
<Button type="primary" className='m-ant-btn' style={{ flexShrink: 0, marginTop: '4px' }} onClick={() => {
|
<Button type="primary" className='m-ant-btn' style={{ flexShrink: 0, marginTop: '4px' }} onClick={() => {
|
||||||
|
|
@ -420,6 +427,7 @@ const Meeting: React.FC = () => {
|
||||||
roomNum: state.channelId,
|
roomNum: state.channelId,
|
||||||
msg: textMsg,
|
msg: textMsg,
|
||||||
})
|
})
|
||||||
|
setTextMsg('')
|
||||||
}}>发送</Button>
|
}}>发送</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,10 @@ export const startSignalr = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const onSignalr = (callBack: Function) => {
|
export const onSignalr = (callBack: Function) => {
|
||||||
connection.on("ReceiveMessage", (message: any) => {
|
connection.on("ReceiveMessage", (uid: string, userName: string, message: string) => {
|
||||||
callBack(message)
|
callBack({
|
||||||
|
uid, message, userName
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export const onInvoke = (str: string, data: any) => {
|
export const onInvoke = (str: string, data: any) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue