@@ -2,6 +2,7 @@ import useChatStore, { chatEvents } from '@/store/useChatStore'
22import { Chat , GroupChat } from '@/types/chat'
33import { cleanRoomId } from '@/utils/roomUtils'
44import { Content , Description , Overlay , Portal , Root , Title } from '@radix-ui/react-dialog'
5+ import { Provider as TooltipProvider , Root as TooltipRoot , Trigger as TooltipTrigger , Content as TooltipContent } from '@radix-ui/react-tooltip'
56import React , { useEffect , useState } from 'react'
67import toast from 'react-hot-toast'
78import ChatListItem from './ChatListItem'
@@ -169,47 +170,78 @@ const Sidebar: React.FC = () => {
169170 < div className = "h-full flex flex-col" >
170171 < div className = "p-4 border-b border-gray-200 flex items-center justify-between" >
171172 < h1 className = "text-xl font-semibold text-gray-800" > 聊天</ h1 >
172- < div className = "flex space-x-2" >
173- < button
174- onClick = { ( ) => setJoinDialogOpen ( true ) }
175- disabled = { isConnecting }
176- className = { `p-2 text-gray-500 hover:bg-gray-100 rounded-full
177- ${ isConnecting ? 'opacity-50 cursor-not-allowed' : '' } ` }
178- title = "加入群聊"
179- >
180- < svg className = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
181- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 }
182- d = "M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"
183- />
184- </ svg >
185- </ button >
186- < button
187- onClick = { handleCreateGroupChat }
188- disabled = { isConnecting }
189- className = { `p-2 text-gray-500 hover:bg-gray-100 rounded-full
190- ${ isConnecting ? 'opacity-50 cursor-not-allowed' : '' } ` }
191- title = "创建群聊"
192- >
193- < svg className = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
194- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 }
195- d = "M12 4v16m8-8H4"
196- />
197- </ svg >
198- </ button >
199- < button
200- onClick = { ( ) => setNameDialogOpen ( true ) }
201- disabled = { isConnecting }
202- className = { `p-2 text-gray-500 hover:bg-gray-100 rounded-full
203- ${ isConnecting ? 'opacity-50 cursor-not-allowed' : '' } ` }
204- title = { userName ? "修改用户名" : "设置用户名" }
205- >
206- < svg className = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
207- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 }
208- d = "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
209- />
210- </ svg >
211- </ button >
212- </ div >
173+ < TooltipProvider >
174+ < div className = "flex space-x-2" >
175+ < TooltipRoot >
176+ < TooltipTrigger asChild >
177+ < button
178+ onClick = { handleCreateGroupChat }
179+ disabled = { isConnecting }
180+ className = { `p-2 text-gray-500 hover:bg-gray-100 rounded-full
181+ ${ isConnecting ? 'opacity-50 cursor-not-allowed' : '' } ` }
182+ >
183+ < svg className = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
184+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 }
185+ d = "M12 4v16m8-8H4"
186+ />
187+ </ svg >
188+ </ button >
189+ </ TooltipTrigger >
190+ < TooltipContent
191+ className = "bg-gray-800 text-white px-3 py-1.5 rounded text-sm animate-fadeIn z-50"
192+ sideOffset = { 5 }
193+ >
194+ 创建群聊
195+ </ TooltipContent >
196+ </ TooltipRoot >
197+
198+ < TooltipRoot >
199+ < TooltipTrigger asChild >
200+ < button
201+ onClick = { ( ) => setNameDialogOpen ( true ) }
202+ disabled = { isConnecting }
203+ className = { `p-2 text-gray-500 hover:bg-gray-100 rounded-full
204+ ${ isConnecting ? 'opacity-50 cursor-not-allowed' : '' } ` }
205+ >
206+ < svg className = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
207+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 }
208+ d = "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
209+ />
210+ </ svg >
211+ </ button >
212+ </ TooltipTrigger >
213+ < TooltipContent
214+ className = "bg-gray-800 text-white px-3 py-1.5 rounded text-sm animate-fadeIn z-50"
215+ sideOffset = { 5 }
216+ >
217+ { userName ? "修改用户名" : "设置用户名" }
218+ </ TooltipContent >
219+ </ TooltipRoot >
220+
221+ < TooltipRoot >
222+ < TooltipTrigger asChild >
223+ < button
224+ onClick = { ( ) => setJoinDialogOpen ( true ) }
225+ disabled = { isConnecting }
226+ className = { `p-2 text-gray-500 hover:bg-gray-100 rounded-full
227+ ${ isConnecting ? 'opacity-50 cursor-not-allowed' : '' } ` }
228+ >
229+ < svg className = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
230+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 }
231+ d = "M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"
232+ />
233+ </ svg >
234+ </ button >
235+ </ TooltipTrigger >
236+ < TooltipContent
237+ className = "bg-gray-800 text-white px-3 py-1.5 rounded text-sm animate-fadeIn z-50"
238+ sideOffset = { 5 }
239+ >
240+ 加入群聊
241+ </ TooltipContent >
242+ </ TooltipRoot >
243+ </ div >
244+ </ TooltipProvider >
213245 </ div >
214246
215247 { /* 聊天列表 */ }
0 commit comments