@tencent-rtc/mcp 1.2.9 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/package.json +2 -2
  2. package/resource/doc/chatuikit/faq/common/server.md +44 -0
  3. package/resource/doc/chatuikit/faq/web_sdk/faq.md +57 -0
  4. package/resource/doc/chatuikit/react/integration.md +430 -49
  5. package/resource/doc/chatuikit/react/workflow.md +258 -0
  6. package/resource/doc/chatuikit/vue/integration.md +355 -144
  7. package/resource/doc/chatuikit/vue/workflow.md +395 -0
  8. package/resource/doc/livekit/vue/components/co-guest-panel.md +3 -3
  9. package/resource/doc/livekit/vue/components/live-view.md +4 -4
  10. package/resource/doc/livekit/vue/{components/live-list.md → live-list-integration.md} +7 -7
  11. package/resource/doc/livekit/vue/{components/live-player.md → live-player-desk-integration.md} +8 -8
  12. package/resource/doc/livekit/vue/live-player-h5-integration.md +269 -0
  13. package/resource/doc/livekit/vue/workflow.md +218 -0
  14. package/resource/doc/trtc/C++/ITRTCCloud.md +4119 -0
  15. package/resource/doc/trtc/C++/ITRTCStatistics.md +325 -0
  16. package/resource/doc/trtc/C++/ITXAudioEffectManager.md +1289 -0
  17. package/resource/doc/trtc/C++/ITXDeviceManager.md +1028 -0
  18. package/resource/doc/trtc/C++/TRTCCloudCallback.md +2650 -0
  19. package/resource/doc/trtc/C++/TRTCTypeDef.md +3600 -0
  20. package/resource/doc/trtc/C++/TXLiteAVCode.md +921 -0
  21. package/resource/doc/trtc/android/TRTCCloud.md +3782 -0
  22. package/resource/doc/trtc/android/TRTCCloudDef.md +3880 -0
  23. package/resource/doc/trtc/android/TRTCCloudListener.md +2431 -0
  24. package/resource/doc/trtc/android/TRTCStatistics.md +295 -0
  25. package/resource/doc/trtc/android/TXAudioEffectManager.md +1289 -0
  26. package/resource/doc/trtc/android/TXBeautyManager.md +979 -0
  27. package/resource/doc/trtc/android/TXDeviceManager.md +440 -0
  28. package/resource/doc/trtc/android/TXLiteAVCode.md +905 -0
  29. package/resource/doc/trtc/iOS/TRTCCloud.md +4238 -0
  30. package/resource/doc/trtc/iOS/TRTCCloudDef.md +3730 -0
  31. package/resource/doc/trtc/iOS/TRTCCloudDelegate.md +2531 -0
  32. package/resource/doc/trtc/iOS/TRTCStatistics.md +295 -0
  33. package/resource/doc/trtc/iOS/TXAudioEffectManager.md +1100 -0
  34. package/resource/doc/trtc/iOS/TXBeautyManager.md +985 -0
  35. package/resource/doc/trtc/iOS/TXDeviceManager.md +1024 -0
  36. package/resource/doc/trtc/iOS/TXLiteAVCode.md +928 -0
  37. package/tools/chat/get-web-chat-integration.js +31 -14
  38. package/tools/chat/get-web-chat-integration.js.map +1 -1
  39. package/tools/definitions/get_faq_def.js +4 -0
  40. package/tools/definitions/get_faq_def.js.map +1 -1
  41. package/tools/definitions/get_native_live_api_def.js +1 -1
  42. package/tools/definitions/get_trtc_native_api_def.js +16 -0
  43. package/tools/definitions/get_trtc_native_api_def.js.map +1 -0
  44. package/tools/definitions/get_web_chat_uikit_integration_def.js +19 -12
  45. package/tools/definitions/get_web_chat_uikit_integration_def.js.map +1 -1
  46. package/tools/definitions/get_web_live_uikit_component_detail_def.js +13 -8
  47. package/tools/definitions/get_web_live_uikit_component_detail_def.js.map +1 -1
  48. package/tools/definitions/get_web_live_uikit_integration_def.js +32 -0
  49. package/tools/definitions/get_web_live_uikit_integration_def.js.map +1 -0
  50. package/tools/index.js +6 -4
  51. package/tools/index.js.map +1 -1
  52. package/tools/live/get-web-live-uikit-integration.js +52 -0
  53. package/tools/live/get-web-live-uikit-integration.js.map +1 -0
  54. package/tools/trtc/get-trtc-native-api.js +31 -0
  55. package/tools/trtc/get-trtc-native-api.js.map +1 -0
  56. package/utils/generate-structured-result.js +34 -0
  57. package/utils/generate-structured-result.js.map +1 -0
  58. package/utils/handle-component-name.js +0 -8
  59. package/utils/handle-component-name.js.map +1 -1
  60. package/utils/report-cls-client.js +1 -1
  61. package/utils/report-es-client.js +1 -1
  62. package/resource/doc/chatuikit/react/chat_window_integration.md +0 -94
  63. package/resource/doc/chatuikit/vue/chat_window_integration.md +0 -156
  64. package/tools/chat/get-web-chat-window-integration.js +0 -28
  65. package/tools/chat/get-web-chat-window-integration.js.map +0 -1
  66. package/tools/definitions/get_web_chat_window_integration_def.js +0 -26
  67. package/tools/definitions/get_web_chat_window_integration_def.js.map +0 -1
  68. /package/resource/doc/livekit/vue/{components/broadcast.md → live-pusher-integration.md} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tencent-rtc/mcp",
3
- "version": "1.2.9",
3
+ "version": "1.3.1",
4
4
  "description": "Tencent Cloud MCP Server for SDK",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@grpc/grpc-js": "^1.5.1",
14
14
  "@grpc/proto-loader": "^0.6.6",
15
- "@modelcontextprotocol/sdk": "^1.10.1",
15
+ "@modelcontextprotocol/sdk": "1.10.1",
16
16
  "@tencentcloud/sdk-mcp": "^1.0.3",
17
17
  "@types/express": "^5.0.1",
18
18
  "@types/hashring": "^3.2.1",
@@ -0,0 +1,44 @@
1
+ ---
2
+ product: 'Chat'
3
+ tech_stack: 'server'
4
+ framework: 'common'
5
+ title: 'Common Issues Knowledge Base'
6
+ keywords: ['console', 'server-side userSig generation', 'restapi', 'pre-callback', 'post-callback', 'nodejs/go/java/python and other server-side language userSig generation example code']
7
+ ---
8
+
9
+ # Common Issues Knowledge Base
10
+
11
+ ## UserSig Solutions
12
+
13
+ ### Q: How to generate userSig on the server side?
14
+ **A:** For specific methods of generating userSig on the server side, please refer to: https://trtc.io/document/34385?product=chat&menulabel=uikit&platform=react. The documentation provides solutions for multiple server-side languages.
15
+
16
+ ### Q: What's the difference in message format between pre-send and post-send callbacks in Chat? How to distinguish system messages from user messages?
17
+ **A:**
18
+ 1. Group message pre-send callback content does not include MsgSeq, MsgTime and other information. For details, please refer to the following documentation:
19
+ - One-to-one pre-send callback: https://trtc.io/document/34364?product=chat&menulabel=uikit&platform=react
20
+ - One-to-one post-send callback: https://trtc.io/document/34365?product=chat&menulabel=uikit&platform=react
21
+ - Group pre-send callback: https://trtc.io/document/34374?product=chat&menulabel=uikit&platform=react
22
+ - Group post-send callback: https://trtc.io/document/34375?product=chat&menulabel=uikit&platform=react
23
+ 2. Normal message format: https://trtc.io/document/33527?product=chat&menulabel=uikit&platform=react
24
+
25
+ ### Q: What are group message priorities and group message frequency controls?
26
+ **A:** Group messages are divided into 3 priorities (`High`, `Normal`, `Low`). If messages in a group exceed the frequency limit, the backend will prioritize delivering high-priority messages. Therefore, users should choose an appropriate priority based on the importance of the message. Total message frequency control refers to the limit on the maximum number of messages that can be sent per second across all endpoints for a single group. The default value is 40 messages/second, using average frequency limiting per second. When the number of messages exceeds the limit, the backend prioritizes delivering messages with relatively higher priority, and messages with the same priority are randomly ordered.
27
+
28
+ ### Q: How to intercept messages sent by users?
29
+ **A:** Business servers can intercept through pre-send callbacks. For specific documentation, please refer to:
30
+ - One-to-one pre-send callback: https://trtc.io/document/34364?product=chat&menulabel=uikit&platform=react
31
+ - Group pre-send callback: https://trtc.io/document/34375?product=chat&menulabel=uikit&platform=react
32
+
33
+ ### Q: How to delete and manage accounts?
34
+ **A:** REST API can be used to delete, import, and query accounts. For specific documentation, please refer to:
35
+ - Delete account: https://trtc.io/document/34955?product=chat&menulabel=uikit&platform=react
36
+ - Import single account: https://trtc.io/document/34953?product=chat&menulabel=uikit&platform=react
37
+ - Import multiple accounts: https://trtc.io/document/34954?product=chat&menulabel=uikit&platform=react
38
+ - Query account: https://trtc.io/document/34956?product=chat&menulabel=uikit&platform=react
39
+
40
+ ### Q: How to handle when the number of accounts exceeds the limit?
41
+ **A:** When importing accounts, if the number of accounts exceeds the limit and you need to create more than 100 accounts, you need to upgrade your application to the Professional Edition. For specific operation instructions, please refer to: https://trtc.io/document/55096.
42
+
43
+ ### Q: How to delete conversations on the server side?
44
+ **A:** Server-side conversation deletion can be done using REST API. For specific documentation, please refer to: https://trtc.io/document/34348?product=chat&menulabel=uikit&platform=react.
@@ -103,3 +103,60 @@ promise.then(function(imResponse) {
103
103
 
104
104
  ### Q: How to send file messages with Web SDK?
105
105
  **A:** Use [createFileMessage](https://trtc.io/document/47993?product=chat&menulabel=core%20sdk&platform=javascript#creating-a-file-message) to create a file message instance, then use [sendMessage](https://trtc.io/document/47993?product=chat&menulabel=core%20sdk&platform=javascript#sending-a-message) to send the file message.
106
+
107
+ ### Q: How to implement user online status feature in Chat?
108
+ **A:**
109
+ 1. Chat SDK provides **user status query, subscription, unSubscription APIs and status change event notifications**. For details, please refer to: https://trtc.io/document/49561.
110
+ 2. For server-side **online status change callback**, please refer to: https://trtc.io/document/34357?product=chat&menulabel=core%20sdk&platform=javascript.
111
+
112
+ ### Q: How to implement message list feature without UI in Chat SDK?
113
+ **A:** To implement message list feature without UI, you need to combine SDK's `sendMessage`, `getMessageList` APIs and `MESSAGE_RECEIVED` event.
114
+
115
+ ### Q: How to implement @all and @someone features without UI in Chat SDK?
116
+ **A:** SDK provides `createTextAtMessage` API for implementing @ mentions. For details, please refer to: https://trtc.io/document/47993?product=chat&menulabel=core%20sdk&platform=javascript#creating-an-.40-message.
117
+
118
+ ### Q: How to implement search functionality in Chat SDK?
119
+ **A:** SDK provides **cloud search** capabilities, supporting message search, user search, group search, and group member search. API details can be found in the following links:
120
+ - Search messages: https://trtc.io/document/67677?product=chat&menulabel=core%20sdk&platform=javascript
121
+ - Search users: https://trtc.io/document/67679?product=chat&menulabel=core%20sdk&platform=javascript
122
+ - Search groups: https://trtc.io/document/67681?product=chat&menulabel=core%20sdk&platform=javascript
123
+ - Search group members: https://trtc.io/document/67683?product=chat&menulabel=core%20sdk&platform=javascript
124
+
125
+ ### Q: How to create groups, add group members, and set administrators in Chat SDK?
126
+ **A:** For specific information about creating groups, adding group members, and setting administrators in SDK, please refer to the documentation below:
127
+ - Create group: https://trtc.io/document/48465?product=chat&menulabel=core%20sdk&platform=javascript
128
+ - Add group members: https://trtc.io/document/48180?product=chat&menulabel=core%20sdk&platform=javascript#49b805dd-4898-44a3-89a4-3b201f839fce
129
+ - Modify group member role (can set administrator): https://trtc.io/document/48180?product=chat&menulabel=core%20sdk&platform=javascript#f35fb570-648c-4b97-99a1-cef5b81b1284
130
+
131
+ ### Q: How to create a C2C one-to-one conversation?
132
+ **A:** The UI layer can create a one-to-one conversation by querying conversation profile using `getConversationProfile`. The `conversationID` format is: `C2C${userID}`. After SDK successfully creates the conversation, it will notify the conversation list update through the `CONVERSATION_LIST_UPDATE` event.
133
+
134
+ ### Q: How to get total unread message count and listen to real-time changes?
135
+ **A:** For detailed information about total unread message count, please refer to: https://trtc.io/document/48319?product=chat&menulabel=core%20sdk&platform=javascript.
136
+ 1. To get total unread message count, call `getTotalUnreadMessageCount` API.
137
+ 2. To listen for total unread count changes, monitor the `TOTAL_UNREAD_MESSAGE_COUNT_UPDATED` event.
138
+ Note: During initialization, it's recommended to listen to the `TOTAL_UNREAD_MESSAGE_COUNT_UPDATED` event to get the total unread message count, because the calculation of total unread count depends on the synchronization of cloud conversation list. Calling `getTotalUnreadMessageCount` directly after successful login may return 0 because the cloud conversation list hasn't finished synchronizing yet.
139
+
140
+ ### Q: How to get original and thumbnail images in SDK image messages?
141
+ **A:** For image messages, high-resolution original image (type = 0), thumbnail (type = 1), and large image (type = 2) can be obtained. For details, please refer to the Message structure documentation: https://trtc.io/document/47990?product=chat&menulabel=core%20sdk&platform=javascript#893c75e0-e592-475a-bd9a-0c4ec30114b9.
142
+
143
+ ### Q: How to handle message sending failures in SDK?
144
+ **A:** When SDK message sending fails, the `sendMessage` interface will throw an error, which needs to be caught using `sendMessage().catch()`. The error contains the complete message structure, where message.status is `fail`. You can resend the failed message using `resendMessage`.
145
+
146
+ ### Q: In weak network environments, how does SDK ensure WebSocket stability and reconnection?
147
+ **A:** In weak network environments, if WebSocket disconnects, SDK will automatically reconnect. WebSocket status changes can be monitored through the `NET_STATE_CHANGE` event (https://trtc.io/document/47967?platform=javascript&product=chat&menulabel=sdk#d39fb50f-f0f2-4b67-9b15-acd7e8608105).
148
+
149
+ ### Q: How to delete conversations in SDK?
150
+ **A:** Conversation deletion only supports one-way deletion. SDK delete conversation API is `deleteConversation`. Reference documentation: https://trtc.io/document/48313?product=chat&menulabel=core%20sdk&platform=javascript.
151
+
152
+ ### Q: How to get friend list in SDK?
153
+ **A:** Get friend list using `getFriendList` API. Friend list updates can be monitored through the `FRIEND_LIST_UPDATED` event. Reference documentation: https://trtc.io/document/48158?product=chat&menulabel=core%20sdk&platform=javascript.
154
+
155
+ ### Q: How to listen for friend online status updates in SDK?
156
+ **A:** Friend online status changes can be implemented in two ways:
157
+ 1. If you have enabled automatic friend status notification in the IM Console, when a friend's status changes, SDK will dispatch the `USER_STATUS_UPDATED` event, where you can get the friend's latest status.
158
+ 2. If you haven't enabled automatic friend status notification and still want to sense friend status changes, you need to call `subscribeUserStatus` to actively subscribe to friend status. When a friend's status changes, SDK will dispatch the `USER_STATUS_UPDATED` callback.
159
+ For detailed documentation, please refer to: https://trtc.io/document/49561?product=chat&menulabel=core%20sdk&platform=javascript.
160
+
161
+ ### Q: How to delete conversation history messages in SDK?
162
+ **A:** SDK provides the `clearHistoryMessage` API to clear conversation history messages. For detailed documentation, please refer to: https://trtc.io/document/53498?product=chat&menulabel=core%20sdk&platform=javascript.
@@ -1,38 +1,55 @@
1
- The AI model must comply with the following **hard restrictions**:
2
- * **React Version Restriction:** When creating the project, both React and react-dom versions must be `18.2.0`. React 19 is prohibited.
3
- * **React UIKit Version Restriction:** The latest version of `@tencentcloud/chat-uikit-react` 3.0.0 or higher must be used.
4
- * **Strictly Follow the Documentation Steps and Instructions for Integration:** When integrating components, the steps and instructions in the documentation must be followed precisely.
5
- * **Strictly Use the Sample Code in the Documentation:** When creating files, the sample code in the documentation must be used to populate the files. The PlaceholderEmpty property of the Chat component does not need to be filled in.
6
- * **Open Default Conversation:** The `C2Cadministrator` conversation must be opened using `setActiveConversation`.
7
- * **Retrieve userSig using a tool:** The TUIKit code must be downloaded and integrated according to the documentation before automatically generating a test userID and calling the `get_usersig` tool to retrieve the userSig. The userID does not need to be appended with a timestamp to avoid errors in dynamic calculation.
8
- * **Account Information Filling:** After obtaining the userSig, the SDKAppID, userID, and userSig will be automatically filled into the code.
9
- * **Prohibit Creating User Information Configuration Files:** The `config` directory or file for filling in SDKAppID, userID, and userSig must not be automatically created.
1
+ TUIKit is a UI component library based on the Chat SDK. It enables quick implementation of chat, session, search, relationship chain, group, and other features through UI components. This article introduces how to quickly integrate TUIKit and implement core features
2
+ <iframe src="https://web.sdk.qcloud.com/im/demo/docs-example/sample-chat/index.html#/inbox?page=intergration" style="width:100%;height:700px;border:none" allow="camera; microphone; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="no-referrer-when-downgrade" allowfullscreen></iframe>
10
3
 
11
- # chat-uikit-react Integration
12
4
 
5
+ ## Prerequisites
6
+ - Node.js v18 or higher, recommend using the current LTS v22 version
13
7
 
14
- ## step1:create react project
8
+ - React v18
15
9
 
16
10
 
17
- requirement: react: 18.2.0, react-dom: 18.2.0.
11
+ ## Create a project
18
12
 
13
+ Create a new React project named **chat-app** (select **React 18** during project creation and use the TypeScript Template), and complete project initialization as prompted by the scaffold.
19
14
 
20
- you can use vite or rsbuild to create a react project.
21
15
 
16
+ 【shell】
17
+ ``` bash
18
+ npm create rsbuild@latest
19
+ ```
20
+
21
+ ## Installing and Importing Components
22
+
23
+ ### Step 1: Dependency Installation
22
24
 
23
- ## step2: install chat-uikit-react
25
+ Download [chat-uikit-react](https://www.npmjs.com/package/@tencentcloud/chat-uikit-react) via npm and use it in the project.
24
26
 
25
27
 
26
- use npm or pnpm to install @tencentcloud/chat-uikit-react
28
+ 【shell】
29
+ ``` bash
30
+ npm i @tencentcloud/chat-uikit-react
31
+ ```
32
+
33
+ ### Step 2: Introducing the chat uikit react component
27
34
 
35
+ > **Note:**
36
+ >
37
+ > - The following code does not include `SDKAppID`, `userID`, and `UserSig`. You need to replace them with the relevant information obtained in [Step 4](https://write.woa.com/document/108053210129276928).
38
+ > - To respect the copyright of emoji designs, the Chat Demo/TUIKit project does not include large emoji graphics. Please replace them with your own designs or other emoji packs for which you hold the copyright before officially launching for commercial use. **The default smiley face emoji pack shown below is copyrighted by Tencent RTC**, you can upgrade to [Chat Pro Plus Edition and Enterprise Edition](https://console.trtc.io/subscription/buy/chat?packType=pro) to use it for free.
28
39
 
29
- ## step3: add chat-uikit-react to your project
40
+ > ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027202808/a7c853cf981a11ef834b525400f69702.png)
41
+ >
30
42
 
31
43
 
32
- example code
44
+ Copy the following `App.tsx` code and replace the original content in `App.tsx`.
33
45
 
46
+ Copy the following `App.css` code and replace the `App.css` style file in the same directory.
34
47
 
35
- ```tsx
48
+
49
+
50
+
51
+ 【App.tsx】
52
+ ``` typescript
36
53
  import {
37
54
  UIKitProvider,
38
55
  useLoginState,
@@ -42,54 +59,418 @@ import {
42
59
  ChatHeader,
43
60
  MessageList,
44
61
  MessageInput,
62
+ ContactList,
63
+ ContactInfo,
64
+ useUIKit,
45
65
  useConversationListState,
46
66
  } from "@tencentcloud/chat-uikit-react";
67
+ import { useEffect, useState } from "react";
68
+ import './App.css';
47
69
 
48
- function ChatApp() {
49
- const { setActiveConversation } = useConversationListState();
50
-
51
- useEffect(() => {
52
- // open default conversation
53
- setActiveConversation('C2Cadministrator');
54
- }, [setActiveConversation]);
55
-
70
+ function App() {
71
+ // Language support en-US(default) / zh-CN / ja-JP / ko-KR / zh-TW
72
+ // Theme supports light(default) / dark
56
73
  return (
57
- <div style={{ height: '100vh', width: '100vw', display: 'flex', flexDirection: 'row' }}>
58
- <ConversationList style={{ minWidth: '300px', maxWidth: '350px' }}/>
59
- <Chat PlaceholderEmpty=''>
60
- <ChatHeader />
61
- <MessageList />
62
- <MessageInput />
63
- </Chat>
64
- </div>
74
+ <UIKitProvider theme={'light'} language={'en-US'}>
75
+ <ChatApp />
76
+ </UIKitProvider>
65
77
  );
66
78
  }
67
79
 
68
-
69
- function App() {
70
- const userID = ''; // TODO: Replace with your userID
71
- const SDKAppID = 0; // TODO: Replace with your SDKAppID (Notice: SDKAppID is of type number)
72
- const userSig = ''; // TODO: Replace with your userSig
80
+ function ChatApp() {
81
+ const [activeTab, setActiveTab] = useState('chats');
73
82
 
83
+ const { language } = useUIKit();
84
+
85
+ const texts = language === 'zh-CN'
86
+ ? { chats: '会话', contacts: '联系人', emptyTitle: '暂无会话', emptySub: '选择一个会话开始聊天', error: '请检查 SDKAppID, userID, userSig, 通过开发人员工具(F12)查看具体的错误信息', loading: '登录中...' }
87
+ : { chats: 'Chats', contacts: 'Contacts', emptyTitle: 'No conversation', emptySub: 'Select a conversation to start chatting', error: 'Please check the SDKAppID, userID, and userSig. View the specific error information through the developer tools (F12).', loading: 'Logging in...'};
88
+
89
+
74
90
  const { status } = useLoginState({
75
- SDKAppID,
76
- userID,
77
- userSig,
91
+ SDKAppID: 0, // type: number
92
+ userID: '', // type: string
93
+ userSig: '', // type: string
78
94
  })
95
+ const { setActiveConversation } = useConversationListState();
96
+
97
+ useEffect(() => {
98
+ async function init() {
99
+ // You can switch to another created userID
100
+ const userID = 'administrator';
101
+ const conversationID = `C2C${userID}`;
102
+ setActiveConversation(conversationID);
103
+ }
79
104
 
105
+ if (status === LoginStatus.SUCCESS) {
106
+ init();
107
+ }
108
+ }, [status]);
109
+
110
+ if (status === LoginStatus.ERROR) {
111
+ return (
112
+ <div className="loading-container">
113
+ <div className="loading-spinner"></div>
114
+ <div className="loading-text">{texts.error}</div>
115
+ </div>
116
+ )
117
+ }
80
118
 
81
119
  if (status !== LoginStatus.SUCCESS) {
82
- return <div>Loading...</div>
120
+ return (
121
+ <div className="loading-container">
122
+ <div className="loading-spinner"></div>
123
+ <div className="loading-text">{texts.loading}</div>
124
+ </div>
125
+ )
83
126
  }
84
-
85
- // Language support zh-CN(default) / en-US / ja-JP / ko-KR / zh-TW
86
- // Theme support light(default) / dark
127
+
87
128
  return (
88
- <UIKitProvider language='zh-CN' theme='light'>
89
- <ChatApp />
90
- </UIKitProvider>
129
+ <div className="chat-app">
130
+ <ul className="vertical-tabs">
131
+ <li
132
+ className={`tab-item ${activeTab === 'chats' ? 'active' : ''}`}
133
+ onClick={() => {setActiveTab('chats')}}
134
+ >
135
+ {texts.chats}
136
+ </li>
137
+ <li
138
+ className={`tab-item ${activeTab === 'contacts' ? 'active' : ''}`}
139
+ onClick={() => {setActiveTab('contacts')}}
140
+ >
141
+ {texts.contacts}
142
+ </li>
143
+ </ul>
144
+ {
145
+ activeTab === 'chats' && (
146
+ <>
147
+ <ConversationList style={{ flex: '0 0 300px'}}/>
148
+ <Chat
149
+ className="chat-box"
150
+ PlaceholderEmpty={
151
+ <div className="empty-chat">
152
+ <div className="empty-icon">💬</div>
153
+ <div className="empty-title">{texts.emptyTitle}</div>
154
+ <div className="empty-subtitle">{texts.emptySub}</div>
155
+ </div>
156
+ }
157
+ >
158
+ <ChatHeader />
159
+ <MessageList />
160
+ <MessageInput />
161
+ </Chat>
162
+ </>
163
+ )
164
+ }
165
+ {
166
+ activeTab === 'contacts' && (
167
+ <>
168
+ <ContactList style={{ flex: '0 0 300px'}}/>
169
+ <ContactInfo
170
+ style={{ flex: '1'}}
171
+ onSendMessage={() => {setActiveTab('chats')}}
172
+ onEnterGroup={() => {setActiveTab('chats')}}
173
+ />
174
+ </>
175
+ )
176
+ }
177
+ </div>
91
178
  );
92
179
  }
93
180
 
94
181
  export default App;
95
182
  ```
183
+
184
+
185
+ 【App.css】
186
+ ``` css
187
+ body {
188
+ margin: 0;
189
+ padding: 20px;
190
+ font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
191
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
192
+ min-height: 100vh;
193
+ box-sizing: border-box;
194
+ }
195
+
196
+ .chat-app {
197
+ height: calc(100vh - 40px);
198
+ max-width: 1400px;
199
+ margin: 0 auto;
200
+ display: flex;
201
+ flex-direction: row;
202
+ background: #ffffff;
203
+ border-radius: 16px;
204
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3),
205
+ 0 0 0 1px rgba(0, 0, 0, 0.1);
206
+ overflow: hidden;
207
+ backdrop-filter: blur(10px);
208
+ }
209
+
210
+ .vertical-tabs {
211
+ list-style: none;
212
+ margin: 0;
213
+ padding: 0;
214
+ width: 100px;
215
+ background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
216
+ border-right: 1px solid rgba(0, 0, 0, 0.08);
217
+ }
218
+
219
+ .tab-item {
220
+ padding: 16px 20px;
221
+ cursor: pointer;
222
+ background: transparent;
223
+ color: #495057;
224
+ font-size: 14px;
225
+ text-align: center;
226
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
227
+ position: relative;
228
+ }
229
+
230
+ .tab-item::before {
231
+ content: '';
232
+ position: absolute;
233
+ left: 0;
234
+ top: 50%;
235
+ transform: translateY(-50%);
236
+ width: 3px;
237
+ height: 0;
238
+ background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
239
+ border-radius: 0 3px 3px 0;
240
+ transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
241
+ }
242
+
243
+ .tab-item:hover {
244
+ background: rgba(102, 126, 234, 0.08);
245
+ color: #667eea;
246
+ }
247
+
248
+ .tab-item.active {
249
+ background: linear-gradient(90deg, rgba(102, 126, 234, 0.15) 0%, rgba(102, 126, 234, 0.05) 100%);
250
+ color: #667eea;
251
+ }
252
+
253
+ .tab-item.active::before {
254
+ height: 60%;
255
+ }
256
+
257
+ .chat-box {
258
+ flex: 1;
259
+ border-left: 1px solid rgba(0, 0, 0, 0.08);
260
+ }
261
+
262
+ .empty-chat {
263
+ display: flex;
264
+ flex: 1;
265
+ flex-direction: column;
266
+ align-items: center;
267
+ justify-content: center;
268
+ height: 100%;
269
+ color: #adb5bd;
270
+ gap: 12px;
271
+ text-align: center;
272
+ border-left: 1px solid rgba(0, 0, 0, 0.08);
273
+ }
274
+
275
+ .empty-icon {
276
+ font-size: 64px;
277
+ opacity: 0.3;
278
+ animation: float 3s ease-in-out infinite;
279
+ }
280
+
281
+ .empty-title {
282
+ font-size: 16px;
283
+ font-weight: 600;
284
+ color: #6c757d;
285
+ }
286
+
287
+ .empty-subtitle {
288
+ font-size: 14px;
289
+ color: #868e96;
290
+ }
291
+
292
+ @keyframes float {
293
+ 0%, 100% {
294
+ transform: translateY(0px);
295
+ }
296
+ 50% {
297
+ transform: translateY(-10px);
298
+ }
299
+ }
300
+
301
+ .loading-container {
302
+ display: flex;
303
+ flex-direction: column;
304
+ align-items: center;
305
+ justify-content: center;
306
+ height: 100vh;
307
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
308
+ gap: 24px;
309
+ }
310
+
311
+ .loading-spinner {
312
+ width: 60px;
313
+ height: 60px;
314
+ border: 4px solid rgba(255, 255, 255, 0.2);
315
+ border-top-color: #ffffff;
316
+ border-radius: 50%;
317
+ animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
318
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
319
+ }
320
+
321
+ .loading-text {
322
+ color: #ffffff;
323
+ font-size: 18px;
324
+ font-weight: 500;
325
+ letter-spacing: 0.5px;
326
+ animation: pulse 2s ease-in-out infinite;
327
+ }
328
+
329
+ @keyframes spin {
330
+ 0% {
331
+ transform: rotate(0deg);
332
+ }
333
+ 100% {
334
+ transform: rotate(360deg);
335
+ }
336
+ }
337
+
338
+ @keyframes pulse {
339
+ 0%, 100% {
340
+ opacity: 1;
341
+ }
342
+ 50% {
343
+ opacity: 0.6;
344
+ }
345
+ }
346
+ ```
347
+
348
+ ### Step 3: Obtain SDKAppID, UserID and UserSig
349
+
350
+ In the previously copied `App.tsx` code, the login authentication information is empty. You need to fill in your Tencent Cloud application authentication information in the `useLoginState hook`, as shown below:
351
+ <table>
352
+ <tr>
353
+ <td rowspan="1" colSpan="1" >Parameter</td>
354
+
355
+ <td rowspan="1" colSpan="1" >Type</td>
356
+
357
+ <td rowspan="1" colSpan="1" >Note</td>
358
+ </tr>
359
+
360
+ <tr>
361
+ <td rowspan="1" colSpan="1" >userID</td>
362
+
363
+ <td rowspan="1" colSpan="1" >String</td>
364
+
365
+ <td rowspan="1" colSpan="1" >Unique identifier of the user, defined by you, it is allowed to contain only upper and lower case letters (a-z, A-Z), numbers (0-9), underscores, and hyphens.</td>
366
+ </tr>
367
+
368
+ <tr>
369
+ <td rowspan="1" colSpan="1" >SDKAppID</td>
370
+
371
+ <td rowspan="1" colSpan="1" >Number</td>
372
+
373
+ <td rowspan="1" colSpan="1" >The unique identifier for the audio and video application created in the [Tencent RTC Console](https://console.trtc.io/).</td>
374
+ </tr>
375
+
376
+ <tr>
377
+ <td rowspan="1" colSpan="1" >SDKSecretKey</td>
378
+
379
+ <td rowspan="1" colSpan="1" >String</td>
380
+
381
+ <td rowspan="1" colSpan="1" >The SDKSecretKey of the audio and video application created in the [Tencent RTC Console](https://console.trtc.io/).</td>
382
+ </tr>
383
+
384
+ <tr>
385
+ <td rowspan="1" colSpan="1" >userSig</td>
386
+
387
+ <td rowspan="1" colSpan="1" >String</td>
388
+
389
+ <td rowspan="1" colSpan="1" >A security protection signature used for user log in authentication to confirm the user's identity and prevent malicious attackers from stealing your cloud service usage rights.</td>
390
+ </tr>
391
+ </table>
392
+
393
+
394
+ > **Explanation of UserSig:**
395
+ >
396
+
397
+ > **Development environment**: If you are running a demo locally and developing or debugging, you can use the `genTestUserSig` (Refer to Step 3.2) function in the debug file to generate a 'userSig'. In this method, SDKSecretKey is vulnerable to decompilation and reverse engineering. Once your key is leaked, attackers can steal your Tencent Cloud traffic.
398
+ >
399
+
400
+ > **Production environment**: If your project is going live, please use the [Server-side Generation of UserSig](https://trtc.io/document/34385) method.
401
+ >
402
+
403
+ 1. Log in to [Chat Console](https://console.trtc.io/) .
404
+
405
+ 2. Click **Create Application**, enter your application name, then click **Create**.
406
+
407
+
408
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027119864/cdc5fdb411ec11efa2935254005ac0ca.png)
409
+
410
+ 3. After creation, you can view the Application Status, service version, SDKAppID, creation time, Tag, and expiration time of the new application on the console overview page.
411
+
412
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027862798/c73f215c7cf411f0914f52540099c741.png)
413
+
414
+ 4. [Go to the user management page](https://console.trtc.io/chat/account-management), create 2–3 test accounts for experience in C2C chat and group chat.
415
+
416
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100033438418/0be64336adb311f096c2525400454e06.png)
417
+
418
+ 5. UserSig info. Click [IM console > development tool > UserSig tool](https://console.trtc.io/usersig), fill in the created userID, and just generate userSig.
419
+
420
+
421
+ ### Step 4: Start the Project
422
+
423
+ Replace SDKAppID, UserID, and UserSig in App.tsx, then run the following command:
424
+
425
+
426
+ 【shell】
427
+ ``` bash
428
+ npm run dev
429
+ ```
430
+
431
+ > **Note:**
432
+ >
433
+ > 1. Please ensure that in Step 3 code, SDKAppID, UserID, and UserSig are all successfully replaced. Failure to replace them will result in abnormal project behavior.
434
+ > 2. A `userID` corresponds to a `userSig`, for more information, see [Generating UserSig](https://trtc.io/document/39074?product=consoleguide).
435
+ > 3. If the project fails to start, please check whether the [development environment requirements](https://write.woa.com/document/108053210129276928) are met.
436
+
437
+
438
+ ### Step 6: Send your first message
439
+
440
+ Enter your message in the input box and press Enter to send.
441
+
442
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027119864/efc5e925595711efb36952540075b605.png)
443
+
444
+ ## FAQs
445
+
446
+ #### What is UserSig?
447
+
448
+ A UserSig is a password for users to log in to Chat. It is essentially the ciphertext generated by encrypting information such as the UserID.
449
+
450
+ #### How can I generate a UserSig?
451
+
452
+ The issuance method for UserSig involves integrating the calculation code of UserSig into your server, and providing an interface oriented towards your project. When UserSig is needed, your project sends a request to the business server to access the dynamic UserSig. For more information, please see [How to Generate a UserSig on the Server](https://trtc.io/document/39074?product=consoleguide).
453
+
454
+ > **Note:**
455
+ >
456
+
457
+ > The exemplary code provided in this document retrieves the UserSig by embedding the SECRETKEY in the client code. This approach makes the SECRETKEY highly susceptible to decompilation and reverse engineering. Once your encryption key is compromised, attackers can misappropriate your Tencent Cloud traffic. Hence, **this procedure is exclusively recommended for running functional debugging locally**. For the correct issuance of UserSig, please refer to the previous sections.
458
+ >
459
+
460
+
461
+ ## Communication and Feedback
462
+
463
+ Join the [Telegram Technical Exchange Group](https://t.me/tencent_imsdk) or [WhatsApp Exchange Group](https://chat.whatsapp.com/IVa11ZkVmKTEwSWsAzSyik) to enjoy support from professional engineers and solve your problems.
464
+
465
+ ## Documentation
466
+
467
+ #### UIKit Related:
468
+ - [chat-uikit-react npm](https://www.npmjs.com/package/@tencentcloud/chat-uikit-react)
469
+
470
+ - [Demo Source Code and Running Example](https://github.com/TencentCloud/chat-uikit-react)
471
+
472
+
473
+ #### For more features, refer to the ChatEngine API documentation:
474
+ - [chat-uikit-engine API Manual](https://web.sdk.qcloud.com/im/doc/chat-engine-lite/index.html)
475
+
476
+ - [chat-uikit-engine-lite npm](https://www.npmjs.com/package/@tencentcloud/chat-uikit-engine-lite)