From c38d1bbdad7c9e464de00aa1893ce69975d67038 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Sun, 7 Dec 2025 21:35:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=88=BF=E4=B8=BB=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=87=AA=E5=B7=B1=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/watch-room/ChatFloatingWindow.tsx | 8 +------- src/hooks/useWatchRoom.ts | 7 +++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/watch-room/ChatFloatingWindow.tsx b/src/components/watch-room/ChatFloatingWindow.tsx index 5313f6d..4a30c74 100644 --- a/src/components/watch-room/ChatFloatingWindow.tsx +++ b/src/components/watch-room/ChatFloatingWindow.tsx @@ -25,7 +25,6 @@ export default function ChatFloatingWindow() { useEffect(() => { const roomId = watchRoom?.currentRoom?.id || null; if (roomId !== currentRoomIdRef.current) { - console.log('[ChatFloatingWindow] Room changed:', currentRoomIdRef.current, '->', roomId); currentRoomIdRef.current = roomId; lastMessageCountRef.current = 0; setUnreadCount(0); @@ -66,15 +65,10 @@ export default function ChatFloatingWindow() { if (currentCount > lastMessageCountRef.current) { // 有新消息 const newMessageCount = currentCount - lastMessageCountRef.current; - console.log('[ChatFloatingWindow] New messages:', newMessageCount, 'isOpen:', isOpenRef.current, 'isMinimized:', isMinimizedRef.current); if (!isOpenRef.current && !isMinimizedRef.current) { // 只有在聊天窗口完全关闭时才增加未读计数 - setUnreadCount(prev => { - const newCount = prev + newMessageCount; - console.log('[ChatFloatingWindow] Updating unread count:', prev, '->', newCount); - return newCount; - }); + setUnreadCount(prev => prev + newMessageCount); } } lastMessageCountRef.current = currentCount; diff --git a/src/hooks/useWatchRoom.ts b/src/hooks/useWatchRoom.ts index 20adfd0..0026232 100644 --- a/src/hooks/useWatchRoom.ts +++ b/src/hooks/useWatchRoom.ts @@ -107,6 +107,13 @@ export function useWatchRoom(onRoomDeleted?: (data?: { reason?: string }) => voi if (response.success && response.room) { setCurrentRoom(response.room); setIsOwner(true); + // 创建房间时,手动设置房主的成员信息 + setMembers([{ + id: sock.id!, + name: data.userName, + isOwner: true, + lastHeartbeat: Date.now(), + }]); storeRoomInfo({ roomId: response.room.id, roomName: response.room.name,