ChatSetting 是一个智能的聊天设置组件,它能够根据当前激活的会话类型自动渲染相应的设置界面。该组件内部集成了 C2C(1 对 1)聊天设置和群聊设置两种模式,为用户提供了统一的聊天设置入口。参数 | 类型 | 默认值 | 描述 |
className | string | undefined | undefined | 自定义 CSS 类名 |
style | React.CSSProperties | undefined | undefined | 自定义内联样式 |
ChatSetting 是一个可自由使用的独立组件,默认的开关控制在 ChatHeader 组件上,也可以使用 useUIOpenControlState Hook 自定义 ChatSetting 的开关。import { useState } from 'react';import {ChatSetting,Search,useChatContext,VariantType,} from '@tencentcloud/chat-uikit-react';import './styles.css';function ChatSidePanelsBasicDemo() {const [isChatSettingShow, setIsChatSettingShow] = useState(false);const [isSearchShow, setIsSearchShow] = useState(false);const [targetID, setTargetID] = useState('');const [conversationType, setConversationType] = useState<'C2C' | 'GROUP'>('C2C');const { activeConversationID, setActiveConversation } = useChatContext();const handleActivateConversation = () => {const normalizedID = targetID.trim();if (!normalizedID) {return;}setActiveConversation(`${conversationType}${normalizedID}`);};return (<div className="chat-side-panels-basic-demo"><div className="chat-side-panels-basic-demo__header"><h2>Chat Side Panels</h2><p>Activate a conversation, then open or close ChatSetting and Search.</p></div><div className="chat-side-panels-basic-demo__frame"><div className="chat-side-panels-basic-demo__actions"><inputonChange={event => setTargetID(event.target.value)}placeholder="User ID or group ID"value={targetID}/><selectonChange={event => setConversationType(event.target.value as 'C2C' | 'GROUP')}value={conversationType}><option value="C2C">C2C</option><option value="GROUP">GROUP</option></select><button onClick={handleActivateConversation} type="button">Activate Conversation</button><span className="chat-side-panels-basic-demo__active">Active: {activeConversationID || 'None'}</span><buttononClick={() => setIsChatSettingShow(show => !show)}type="button">{isChatSettingShow ? 'Hide Setting' : 'Show Setting'}</button><buttononClick={() => setIsSearchShow(show => !show)}type="button">{isSearchShow ? 'Hide Search' : 'Show Search'}</button></div>{isChatSettingShow && (<div className="chat-side-panels-basic-demo__panel"><ChatSetting /></div>)}{isSearchShow && (<div className="chat-side-panels-basic-demo__panel"><Search variant={VariantType.EMBEDDED} /></div>)}</div></div>);}
文档反馈