From 187e91f07ac63f68e9deda65ab29bee66a4ab2fa Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Mon, 14 Oct 2024 14:26:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 4 +- .../Meeting/ChatBigWindow/index.module.scss | 133 +++++++++ src/page/Meeting/ChatBigWindow/index.tsx | 263 ++++++++++++++++++ .../Meeting/ChatSmallWindow/index.module.scss | 3 +- src/page/Meeting/ChatSmallWindow/index.tsx | 12 +- src/page/Meeting/ShareScreenWindow/index.tsx | 16 +- src/page/Meeting/index.tsx | 43 ++- 7 files changed, 463 insertions(+), 11 deletions(-) create mode 100644 src/page/Meeting/ChatBigWindow/index.module.scss create mode 100644 src/page/Meeting/ChatBigWindow/index.tsx diff --git a/src/App.tsx b/src/App.tsx index 1066a1d..0e5632a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -21,6 +21,7 @@ import path from "path"; import ShareScreenWindow from "@/page/Meeting/ShareScreenWindow"; import UserListWindow from "@/page/Meeting/UserListWindow"; import ChatSmallWindow from "./page/Meeting/ChatSmallWindow"; +import ChatBigWindow from "./page/Meeting/ChatBigWindow"; const fs = require('fs').promises; const { exec } = require('child_process'); const App: React.FC = () => { @@ -35,7 +36,7 @@ const App: React.FC = () => { }); const [spinning, setSpinning] = useState(false); const [isState, setIsState] = useState(true); - const urlHashArr = ['#/userListWindow', '#/shareScreenWindow', '#/chatSmallWindow'] + const urlHashArr = ['#/userListWindow', '#/shareScreenWindow', '#/chatSmallWindow', '#/chatBigWindow'] if (urlHashArr.indexOf(location.hash) == -1) { useEffect(() => { let userInfo = JSON.parse(storage.getItem('user') as string) @@ -251,6 +252,7 @@ const App: React.FC = () => { } /> } /> } /> + } /> } /> diff --git a/src/page/Meeting/ChatBigWindow/index.module.scss b/src/page/Meeting/ChatBigWindow/index.module.scss new file mode 100644 index 0000000..081b30e --- /dev/null +++ b/src/page/Meeting/ChatBigWindow/index.module.scss @@ -0,0 +1,133 @@ +.chatBigWindow { + height: 100%; + width: 100%; + box-sizing: border-box; + display: flex; + flex-direction: column; + box-sizing: border-box; + padding: 10px 0; + + .chatBigWindowTitle { + background-color: #16191E; + flex-shrink: 0; + display: flex; + align-items: center; + justify-content: space-between; + box-sizing: border-box; + padding: 10px 10px; + + >span { + color: #EEEEEE; + font-size: 18px; + } + + >img { + cursor: pointer; + } + } + + .chatBigWindowContent { + flex-grow: 1; + height: 0px; + overflow-y: auto; + background-color: rgb(31, 33, 37); + padding: 10px; + + .chatBigWindowContentLeft { + display: flex; + flex-direction: column; + align-items: flex-start; + + >div:nth-child(1) { + display: flex; + align-items: center; + + >span { + font-size: 14px; + color: #F3F3F5; + margin-left: 4px; + } + + >div {} + } + + >div:nth-child(2) { + background-color: #5575F2; + color: #F3F3F5; + max-width: 266px; + padding: 10px; + box-sizing: border-box; + border-radius: 0 25px 25px 25px; + margin: 10px 0 10px 40px; + font-size: 14px; + } + } + + .chatBigWindowContentRight { + display: flex; + flex-direction: column; + align-items: flex-end; + + >div:nth-child(1) { + display: flex; + align-items: center; + flex-direction: row-reverse; + + >span { + font-size: 14px; + color: #F3F3F5; + } + + >div { + margin-left: 4px; + } + } + + >div:nth-child(2) { + background-color: #464E6B; + color: #F3F3F5; + max-width: 266px; + padding: 10px; + box-sizing: border-box; + border-radius: 25px 0 25px 25px; + margin: 10px 40px 10px 0; + font-size: 14px; + } + } + } + + .chatBigWindowButton { + display: flex; + flex-shrink: 0; + flex-wrap: wrap; + padding: 10px; + box-sizing: border-box; + background-color: rgb(31, 33, 37); + + >button { + margin: 4px 4px 0; + } + } + + .chatBigWindowInput { + flex-shrink: 0; + padding: 10px 10px; + background-color: #16191E; + display: flex; + flex-direction: column; + align-items: flex-end; + } +} + +.chatBigWindowInputPopover { + display: flex; + flex-direction: column; + + >button { + margin-bottom: 4px; + + &:last-child { + margin-bottom: 0; + } + } +} \ No newline at end of file diff --git a/src/page/Meeting/ChatBigWindow/index.tsx b/src/page/Meeting/ChatBigWindow/index.tsx new file mode 100644 index 0000000..c33f626 --- /dev/null +++ b/src/page/Meeting/ChatBigWindow/index.tsx @@ -0,0 +1,263 @@ +import styles from '@/page/Meeting/ChatBigWindow/index.module.scss' +import ImageUrl from '@/utils/package/imageUrl'; +import { useEffect, useState } from "react"; +import { storage } from '@/utils'; +import { setKeyOpenChildWindow } from '@/utils/package/public'; +import { Button, Input, Modal, Popover } from 'antd'; +import { role } from '@/config/role'; +import { GetRoomUserItem } from '@/api/Meeting'; +import Avatar from '@/components/Avatar'; +import dayjs from 'dayjs'; +import { ExclamationCircleFilled } from '@ant-design/icons'; +const { confirm } = Modal; +const ChatBigWindow: React.FC = () => { + const [inputValue, setInputValue] = useState('') + const [chatLists, setChatLists] = useState([]) + const [user, setUser] = useState({}); + const [roomUserItem, setRoomUserItem] = useState(null) + const [commonlyChatList] = useState([ + '能听到我说话吗?', + '听得到', + '听不到', + '我要发言', + ]) + const userInfo = JSON.parse(storage.getItem('user') as string) + const stateInfo = JSON.parse(storage.getItem('stateInfo') as string) + const channel = new BroadcastChannel('meeting_channel'); + useEffect(() => { + setUser(userInfo) + channel.onmessage = function (event) { + const { type, chatList } = event.data; + switch (type) { + case 'chatList': + setChatLists(chatList) + setTimeout(() => { + const chatBigWindowView = document.getElementById('chatBigWindowView') as HTMLElement; + if (chatBigWindowView) { + chatBigWindowView.scrollTop = chatBigWindowView.scrollHeight; + } + }, 100) + break; + } + } + }, []); + + return ( + <> +
+
+ 聊天 + { + window.electron.closeChildWindow('chatBigWindow') + setKeyOpenChildWindow('chatBigWindow', false) + }} /> +
+
+ {chatLists.map((item: any, index: number) => +
+ {role.ID.includes(user.roleId) ? { + if (e) { + GetRoomUserItem(stateInfo.channelId, item.uid).then((res: any) => { + if (res.code === 200) { + setRoomUserItem(res.data) + } + }) + } else { + setRoomUserItem(null) + } + }} + content={ + roomUserItem ?
+ {roomUserItem.isRoomManager || role.ID.includes(roomUserItem.roleId) ? : null} + {roomUserItem.uid !== user.uid && !role.ID.includes(roomUserItem.roleId) ? : null} + {roomUserItem.isRoomManager ? : null} + {roomUserItem.isRoomManager ? : null} + {roomUserItem.uid !== user.uid ? : null} + {roomUserItem.uid !== user.uid ? : null} +
:
用户不在房间内
+ }> +
+
+ {item.uid !== user.uid ? + {item.userName} {dayjs(item.timestamp).format('HH:mm:ss')} : + {dayjs(item.timestamp).format('HH:mm:ss')} {item.userName} + } + +
+
:
+
+ {item.uid !== user.uid ? + {item.userName}{dayjs(item.timestamp).format('HH:mm:ss')} : + {dayjs(item.timestamp).format('HH:mm:ss')} {item.userName} + } +
} +
{item.message}
+
+ )} +
+
+ { + commonlyChatList.map((item: string, index: number) => { + return + }) + } +
+
+ { + setInputValue(e.target.value) + }} + autoSize={{ minRows: 3, maxRows: 3 }} /> + +
+
+ + ) +} + +export default ChatBigWindow diff --git a/src/page/Meeting/ChatSmallWindow/index.module.scss b/src/page/Meeting/ChatSmallWindow/index.module.scss index dc71b19..5e8896c 100644 --- a/src/page/Meeting/ChatSmallWindow/index.module.scss +++ b/src/page/Meeting/ChatSmallWindow/index.module.scss @@ -8,10 +8,9 @@ >div:nth-child(1) { flex-grow: 1; overflow-y: hidden; - height: 80%; + max-height: 80%; padding: 4px; box-sizing: border-box; - overflow-y: auto; .chatSmallWindowContentLeft { display: flex; diff --git a/src/page/Meeting/ChatSmallWindow/index.tsx b/src/page/Meeting/ChatSmallWindow/index.tsx index 13e1c16..2d2c47b 100644 --- a/src/page/Meeting/ChatSmallWindow/index.tsx +++ b/src/page/Meeting/ChatSmallWindow/index.tsx @@ -14,10 +14,12 @@ const ChatSmallWindow: React.FC = () => { switch (type) { case 'chatList': setChatLists(chatList) - const chatSmallWindowView = document.getElementById('chatSmallWindowView') as HTMLElement; - if (chatSmallWindowView) { - chatSmallWindowView.scrollTop = chatSmallWindowView.scrollHeight; - } + setTimeout(() => { + const chatSmallWindowView = document.getElementById('chatSmallWindowView') as HTMLElement; + if (chatSmallWindowView) { + chatSmallWindowView.scrollTop = chatSmallWindowView.scrollHeight; + } + }, 100) break; } } @@ -27,7 +29,7 @@ const ChatSmallWindow: React.FC = () => { return ( <>
-
+
{chatLists.map((item: any) =>
diff --git a/src/page/Meeting/ShareScreenWindow/index.tsx b/src/page/Meeting/ShareScreenWindow/index.tsx index a6fcbaa..f588682 100644 --- a/src/page/Meeting/ShareScreenWindow/index.tsx +++ b/src/page/Meeting/ShareScreenWindow/index.tsx @@ -132,9 +132,21 @@ const ShareScreenWindow: React.FC = () => { type: 'shareScreenWindowSetting' }); break; + case '聊天': + const chatBigWindow = await getKeyOpenChildWindow('chatBigWindow') + if (!chatBigWindow) { + window.electron.createChildWindow({ + url: location.origin + `/#/chatBigWindow`, + width: 440, + height: 640, + key: 'chatBigWindow', + }) + setKeyOpenChildWindow('chatBigWindow', true) + } + break; case '成员列表': - const isOpen = await getKeyOpenChildWindow('userListWindow') - if (!isOpen) { + const userListWindow = await getKeyOpenChildWindow('userListWindow') + if (!userListWindow) { window.electron.createChildWindow({ url: location.origin + `/#/userListWindow`, width: 340, diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index 345fab2..60825df 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -212,7 +212,15 @@ const Meeting: React.FC = () => { userListWindowPostRoomManager, userListWindowGetRoomKickout, shareScreenWindowEquipmentManagement, - chatSmallWindowSendChannelMsg + chatSmallWindowSendChannelMsg, + chatBigWindowSetAllUserLook, + chatBigWindowDeleteRoomManager, + chatBigWindowPostRoomManager, + chatBigWindowPostOpenMicr, + chatBigWindowPostOpenCamera, + chatBigWindowEquipmentManagement, + chatBigWindowGetRoomKickout, + chatBigWindowSendChannelMsg, } = event.data; switch (type) { case 'shareScreenWindowClose': @@ -278,6 +286,39 @@ const Meeting: React.FC = () => { case 'chatSmallWindowSendChannelMsg': sendMsg(chatSmallWindowSendChannelMsg.msg) break; + case 'chatBigWindowSetAllUserLook': + setAllUserLook(chatBigWindowSetAllUserLook.roomUserItem) + break; + case 'chatBigWindowDeleteRoomManager': + DeleteRoomManager({ + roomId: state.roomId, + roomNum: state.channelId, + userId: chatBigWindowDeleteRoomManager.uid + }) + break; + case 'chatBigWindowPostRoomManager': + postRoomManager({ + roomId: state.roomId, + roomNum: state.channelId, + userId: chatBigWindowPostRoomManager.uid + }) + break; + case 'chatBigWindowPostOpenMicr': + postOpenMicr(chatBigWindowPostOpenMicr.enableMicr, chatBigWindowPostOpenMicr.uid) + break; + case 'chatBigWindowPostOpenCamera': + postOpenCamera(chatBigWindowPostOpenCamera.enableCamera, chatBigWindowPostOpenCamera.uid) + break; + case 'chatBigWindowEquipmentManagement': + equipmentManagement(chatBigWindowEquipmentManagement.uid, chatBigWindowEquipmentManagement.userName) + window.electron.mainWindowCenter() + break; + case 'chatBigWindowGetRoomKickout': + GetRoomKickout(state.channelId, chatBigWindowGetRoomKickout.uid) + break; + case 'chatBigWindowSendChannelMsg': + sendMsg(chatBigWindowSendChannelMsg.msg) + break; } } time = setInterval(() => {