@tencentcloud/sdk-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.
- package/package.json +2 -2
- package/resource/doc/chatuikit/faq/common/server.md +54 -0
- package/resource/doc/chatuikit/faq/web_sdk/faq.md +60 -0
- package/resource/doc/chatuikit/react/integration.md +516 -48
- package/resource/doc/chatuikit/react/workflow.md +254 -0
- package/resource/doc/chatuikit/uniapp-app/faq.md +0 -0
- package/resource/doc/chatuikit/uniapp-app/integration.md +619 -0
- package/resource/doc/chatuikit/uniapp-app/workflow.md +576 -0
- package/resource/doc/chatuikit/vue/integration.md +511 -129
- package/resource/doc/chatuikit/vue/workflow.md +395 -0
- package/resource/doc/livekit/vue/components/co-guest-panel.md +5 -5
- package/resource/doc/livekit/vue/components/live-view.md +16 -49
- package/resource/doc/livekit/vue/{components/live-list.md → live-list-integration.md} +13 -44
- package/resource/doc/livekit/vue/live-player-desk-integration.md +293 -0
- package/resource/doc/livekit/vue/{components/live-player.md → live-player-h5-integration.md} +118 -110
- package/resource/doc/livekit/vue/{components/broadcast.md → live-pusher-integration.md} +77 -82
- package/resource/doc/livekit/vue/workflow.md +219 -0
- package/resource/doc/trtc/C++/ITRTCCloud.md +4131 -0
- package/resource/doc/trtc/C++/ITRTCStatistics.md +326 -0
- package/resource/doc/trtc/C++/ITXAudioEffectManager.md +1306 -0
- package/resource/doc/trtc/C++/ITXDeviceManager.md +1029 -0
- package/resource/doc/trtc/C++/TRTCCloudCallback.md +2743 -0
- package/resource/doc/trtc/C++/TRTCTypeDef.md +3703 -0
- package/resource/doc/trtc/C++/TXLiteAVCode.md +930 -0
- package/resource/doc/trtc/android/TRTCCloud.md +3832 -0
- package/resource/doc/trtc/android/TRTCCloudDef.md +3945 -0
- package/resource/doc/trtc/android/TRTCCloudListener.md +2480 -0
- package/resource/doc/trtc/android/TRTCStatistics.md +296 -0
- package/resource/doc/trtc/android/TXAudioEffectManager.md +1344 -0
- package/resource/doc/trtc/android/TXBeautyManager.md +980 -0
- package/resource/doc/trtc/android/TXDeviceManager.md +441 -0
- package/resource/doc/trtc/android/TXLiteAVCode.md +914 -0
- package/resource/doc/trtc/iOS/TRTCCloud.md +4256 -0
- package/resource/doc/trtc/iOS/TRTCCloudDelegate.md +2580 -0
- package/resource/doc/trtc/iOS/TRTCStatistics.md +296 -0
- package/resource/doc/trtc/iOS/TXAudioEffectManager.md +1117 -0
- package/resource/doc/trtc/iOS/TXBeautyManager.md +986 -0
- package/resource/doc/trtc/iOS/TXDeviceManager.md +1025 -0
- package/resource/doc/trtc/iOS/TXLiteAVCode.md +929 -0
- package/resource/doc/trtc/iOS/TXLiveSDKTypeDef.md +3798 -0
- package/tools/chat/get-web-chat-integration.js +31 -14
- package/tools/chat/get-web-chat-integration.js.map +1 -1
- package/tools/definitions/get_faq_def.js +4 -0
- package/tools/definitions/get_faq_def.js.map +1 -1
- package/tools/definitions/get_trtc_native_api_def.js +17 -0
- package/tools/definitions/get_trtc_native_api_def.js.map +1 -0
- package/tools/definitions/get_web_chat_uikit_integration_def.js +18 -11
- package/tools/definitions/get_web_chat_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_web_live_uikit_component_detail_def.js +9 -3
- package/tools/definitions/get_web_live_uikit_component_detail_def.js.map +1 -1
- package/tools/definitions/get_web_live_uikit_integration_def.js +32 -0
- package/tools/definitions/get_web_live_uikit_integration_def.js.map +1 -0
- package/tools/definitions/present_framework_choice_def.js +1 -1
- package/tools/definitions/record_result_def.js +1 -1
- package/tools/definitions/record_result_def.js.map +1 -1
- package/tools/index.js +6 -4
- package/tools/index.js.map +1 -1
- package/tools/live/get-web-live-uikit-integration.js +52 -0
- package/tools/live/get-web-live-uikit-integration.js.map +1 -0
- package/tools/trtc/get-trtc-native-api.js +31 -0
- package/tools/trtc/get-trtc-native-api.js.map +1 -0
- package/utils/generate-structured-result.js +34 -0
- package/utils/generate-structured-result.js.map +1 -0
- package/utils/handle-component-name.js +0 -8
- package/utils/handle-component-name.js.map +1 -1
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
- package/resource/doc/chatuikit/react/chat_window_integration.md +0 -83
- package/resource/doc/chatuikit/vue/chat_window_integration.md +0 -131
- package/tools/chat/get-web-chat-window-integration.js +0 -28
- package/tools/chat/get-web-chat-window-integration.js.map +0 -1
- package/tools/definitions/get_web_chat_window_integration_def.js +0 -26
- package/tools/definitions/get_web_chat_window_integration_def.js.map +0 -1
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
chat-uikit-uniapp 是一款基于腾讯云 Chat SDK 的 uniapp UI 组件库,提供了一些通用的 UI 组件,包含会话、聊天、群组等功能。基于这些精心设计的 UI 组件,您可以快速构建优雅的、可靠的、可扩展的 Chat 应用。 chat-uikit-uniapp 界面效果如下图所示:
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## 前提条件
|
|
7
|
+
|
|
8
|
+
### 开通服务
|
|
9
|
+
|
|
10
|
+
#### 步骤1:创建 IM 应用
|
|
11
|
+
|
|
12
|
+
登录 [即时通信 IM 控制台](https://console.cloud.tencent.com/im),在**应用管理**页面,单击**创建新应用**。如果您已有应用,可省略创建应用过程。
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#### 步骤2:获取 SDKAppID 与密钥
|
|
18
|
+
|
|
19
|
+
在**应用管理**的应用列表中,获取新应用的 `SDKAppID` 和 `SecretKey` (密钥) 信息。
|
|
20
|
+
|
|
21
|
+
> **注意:**
|
|
22
|
+
>
|
|
23
|
+
> - 查看密钥信息需要验证身份。
|
|
24
|
+
> - 密钥信息为敏感信息,为防止他人盗用,请妥善保管,谨防泄露。
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
#### 步骤3:创建测试账号
|
|
31
|
+
|
|
32
|
+
在**账号管理**中创建两个预设账号用于互相发送消息,以便后续的开发和调试。
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
### 环境要求
|
|
37
|
+
- **IDE**: HBuilderX,需升级到新版本。
|
|
38
|
+
|
|
39
|
+
- **语言**: TypeScript / JavaScript。TUIKit 使用 TS 开发,支持在 JS 或 TS 项目中集成。
|
|
40
|
+
|
|
41
|
+
- **框架**: Vue2 / Vue3。
|
|
42
|
+
|
|
43
|
+
- **CSS 预处理器**: sass (sass-loader 版本 $\le$ 10.1.1)。
|
|
44
|
+
|
|
45
|
+
- **运行环境**: Node.js v12 版本及以上。
|
|
46
|
+
|
|
47
|
+
- **包管理**: npm (版本需与 Node 版本匹配)。
|
|
48
|
+
|
|
49
|
+
- **支持平台**: Uniapp 打包 App。
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
> **说明:**
|
|
53
|
+
>
|
|
54
|
+
> - Uniapp 打包微信小程序请另外参考 [uniapp 精简版](https://write.woa.com/document/187938582089838592)。
|
|
55
|
+
> - TUIKit **v2.2.0** 起,请按照本文所述步骤接入。
|
|
56
|
+
> - TUIKit **v2.1.3** 起,支持通过 cli 脚手架工具创建的项目集成,集成指引请点击 [uniapp vue2/vue3(cli 脚手架)](https://cloud.tencent.com/document/product/269/106501)查看。
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## 集成步骤
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
完成以下步骤即可发送您的第一条消息。
|
|
64
|
+
|
|
65
|
+
### 步骤1:创建项目
|
|
66
|
+
|
|
67
|
+
打开 HBuilderX,在菜单栏中选择 “**文件 > 新建 > 项目**”,创建一个名为 `chat-example` 的 uni-app 项目。
|
|
68
|
+
|
|
69
|
+
### 步骤2:下载 TUIKit 组件
|
|
70
|
+
1. 创建 `package.json` 文件:HBuilderX 默认不创建该文件,请在项目根目录下执行命令:
|
|
71
|
+
|
|
72
|
+
``` bash
|
|
73
|
+
npm init -y
|
|
74
|
+
```
|
|
75
|
+
2. **下载 TUIKit 和依赖**:通过 [NPM](https://www.npmjs.com/package/@tencentcloud/chat-uikit-uniapp) 方式下载 TUIKit 组件和 unplugin-vue2-script-setup 依赖:
|
|
76
|
+
|
|
77
|
+
``` bash
|
|
78
|
+
npm i @tencentcloud/chat-uikit-uniapp unplugin-vue2-script-setup
|
|
79
|
+
```
|
|
80
|
+
3. **拷贝 TUIKit 源码**:为了方便开发者对 UI 进行扩展,需要将 TUIKit 源码复制到项目目录中的 ./TUIKit 文件夹下。
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
【macOS 端】
|
|
87
|
+
``` bash
|
|
88
|
+
mkdir -p ./TUIKit && rsync -av --exclude={'node_modules','excluded-list.txt'} ./node_modules/@tencentcloud/chat-uikit-uniapp/ ./TUIKit && rsync -av ./node_modules/@tencentcloud/chat-uikit-uniapp/static ./
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
【Windows 端】
|
|
93
|
+
``` bash
|
|
94
|
+
xcopy .\node_modules\@tencentcloud\chat-uikit-uniapp .\TUIKit /i /e /exclude:.\node_modules\@tencentcloud\chat-uikit-uniapp\excluded-list.txt && xcopy node_modules\@tencentcloud\chat-uikit-uniapp\static .\static /i /e
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### 步骤3:集成 TUIKit 组件
|
|
99
|
+
1. **工程配置**:本步骤配置 `manifest.json` 和 `vue.config.js` 文件,确保 TUIKit 运行的环境正常。
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
【manifest.json 文件】
|
|
105
|
+
|
|
106
|
+
在 `manifest.json `文件的源码视图中手动关闭 H5 `treeShaking` 选项。
|
|
107
|
+
``` json
|
|
108
|
+
{
|
|
109
|
+
"name" : "chat-example",
|
|
110
|
+
/* 其他配置 */
|
|
111
|
+
"h5" : {
|
|
112
|
+
"optimization" : {
|
|
113
|
+
"treeShaking" : {
|
|
114
|
+
"enable" : false
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
/* 其他配置 */
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
【vue.config.js(仅 Vue2 项目)】
|
|
123
|
+
|
|
124
|
+
**Vue2 项目**必须在根目录下修改 vue.config.js (如果没有该文件,请创建该文件并写入以下代码)。
|
|
125
|
+
``` javascript
|
|
126
|
+
const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default;
|
|
127
|
+
|
|
128
|
+
module.exports = {
|
|
129
|
+
parallel: false,
|
|
130
|
+
configureWebpack: {
|
|
131
|
+
plugins: [
|
|
132
|
+
ScriptSetup({
|
|
133
|
+
/* options */
|
|
134
|
+
}),
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
chainWebpack(config) {
|
|
138
|
+
// disable type check and let `vue-tsc` handles it
|
|
139
|
+
config.plugins.delete('fork-ts-checker');
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
2. **集成 TUIKit**:本步骤配置 `app.vue`、`pages.json` 和 `main.js` 文件,确保 TUIKit 可以正常加载。
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
【App.vue 文件】
|
|
150
|
+
|
|
151
|
+
在 App.vue 中引入并初始化 `TUIChatKit`。
|
|
152
|
+
``` javascript
|
|
153
|
+
<script lang="ts">
|
|
154
|
+
import { TUIChatKit } from './TUIKit';
|
|
155
|
+
TUIChatKit.init();
|
|
156
|
+
|
|
157
|
+
export default {
|
|
158
|
+
onLaunch: function () {}
|
|
159
|
+
};
|
|
160
|
+
</script>
|
|
161
|
+
<style>
|
|
162
|
+
/* common css for page */
|
|
163
|
+
uni-page-body,html,body,page {
|
|
164
|
+
width: 100% !important;
|
|
165
|
+
height: 100% !important;
|
|
166
|
+
overflow: hidden;
|
|
167
|
+
}
|
|
168
|
+
</style>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
【pages.json 文件】
|
|
172
|
+
|
|
173
|
+
配置 `pages.json` 路由是集成 TUIKit 的必备步骤。同时,配置 `TabBar` 以展示“消息”、“通讯录”和“个人中心”。
|
|
174
|
+
``` json
|
|
175
|
+
{
|
|
176
|
+
"pages": [
|
|
177
|
+
{
|
|
178
|
+
"path": "pages/index/index", // 您的项目首页
|
|
179
|
+
"style": {
|
|
180
|
+
"navigationBarTitleText": "腾讯云 IM",
|
|
181
|
+
"navigationBarBackgroundColor": "#EBF0F6"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"path": "pages/profile/profile",
|
|
186
|
+
"style": {
|
|
187
|
+
"navigationBarTitleText": "腾讯云 IM",
|
|
188
|
+
"navigationBarBackgroundColor": "#EBF0F6"
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"path": "TUIKit/components/TUIConversation/index",
|
|
193
|
+
"style": {
|
|
194
|
+
"navigationStyle": "custom"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"path": "TUIKit/components/TUIChat/index",
|
|
199
|
+
"style": {
|
|
200
|
+
"navigationStyle": "custom",
|
|
201
|
+
"app-plus": {
|
|
202
|
+
"softinputMode": "adjustResize"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"path": "TUIKit/components/TUIContact/index",
|
|
208
|
+
"style": {
|
|
209
|
+
"navigationStyle": "custom"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"path": "TUIKit/components/TUIChat/video-play",
|
|
214
|
+
"style": {
|
|
215
|
+
"navigationBarTitleText": "腾讯云 IM",
|
|
216
|
+
"navigationBarBackgroundColor": "#EBF0F6"
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"path": "TUIKit/components/TUIChat/web-view",
|
|
221
|
+
"style": {
|
|
222
|
+
"navigationBarTitleText": "腾讯云 IM",
|
|
223
|
+
"navigationBarBackgroundColor": "#EBF0F6"
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"path": "TUIKit/components/TUIGroup/index",
|
|
228
|
+
"style": {
|
|
229
|
+
"navigationStyle": "custom"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"path": "TUIKit/components/TUISearch/index",
|
|
234
|
+
"style": {
|
|
235
|
+
"navigationBarTitleText": "聊天记录",
|
|
236
|
+
"navigationBarBackgroundColor": "#EBF0F6"
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
],
|
|
240
|
+
"tabBar": {
|
|
241
|
+
"backgroundColor": "#EBF0F6",
|
|
242
|
+
"height": "70px",
|
|
243
|
+
"list": [
|
|
244
|
+
{
|
|
245
|
+
"pagePath": "TUIKit/components/TUIConversation/index",
|
|
246
|
+
"text": "消息",
|
|
247
|
+
"iconPath": "./static/message.png",
|
|
248
|
+
"selectedIconPath": "./static/message-selected.png"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"pagePath": "TUIKit/components/TUIContact/index",
|
|
252
|
+
"text": "通讯录",
|
|
253
|
+
"iconPath": "./static/relation.png",
|
|
254
|
+
"selectedIconPath": "./static/relation-selected.png"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"pagePath": "pages/profile/profile",
|
|
258
|
+
"text": "个人中心",
|
|
259
|
+
"iconPath": "./static/profile.png",
|
|
260
|
+
"selectedIconPath": "./static/profile-selected.png"
|
|
261
|
+
}
|
|
262
|
+
]
|
|
263
|
+
},
|
|
264
|
+
"globalStyle": {
|
|
265
|
+
"navigationBarTextStyle": "black",
|
|
266
|
+
"navigationBarTitleText": "uni-app",
|
|
267
|
+
"navigationBarBackgroundColor": "#F8F8F8",
|
|
268
|
+
"backgroundColor": "#F8F8F8"
|
|
269
|
+
},
|
|
270
|
+
"uniIdRouter": {}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
【main.js(仅 Vue2 项目)】
|
|
275
|
+
|
|
276
|
+
如果您是 Vue2 项目,请在 `main.js`** 中引入组合式API**。
|
|
277
|
+
``` javascript
|
|
278
|
+
// #ifndef VUE3
|
|
279
|
+
import VueCompositionAPI from '@vue/composition-api';
|
|
280
|
+
Vue.use(VueCompositionAPI);
|
|
281
|
+
// #endif
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
### **步骤4:配置登录和登出**
|
|
286
|
+
1. **登录配置**:请将以下内容复制到首页文件 `pages/index/index.vue` 中并配置[前提条件 > 开通服务 > 步骤2:获取 SDKAppID 与密钥](https://write.woa.com/#57149ca5-0bc6-478c-a6df-2ca51f38514a) 中获取的SDKAppID、secretKey 完成登录逻辑配置。
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
> **说明:**
|
|
290
|
+
>
|
|
291
|
+
> - 代码中使用的 `genTestUserSig` 是通过本地脚本使用 `secretKey` 生成 `UserSig`。**用于方便开发和调试,不适合生成环境**。
|
|
292
|
+
> - 该方法仅适用于本地 Demo 运行和功能调试,因为 `secretKey` 容易被反编译逆向破解,一旦密钥泄露,攻击者可以盗用您的腾讯云流量,**绝对不能用于生产环境**。
|
|
293
|
+
> - **生产环境**下,请将 `UserSig` 的计算代码集成到您的服务端,并提供面向项目的接口, 正确的`UserSig`签发方式参见 [服务端生成 UserSig](https://cloud.tencent.com/document/product/269/32688)。
|
|
294
|
+
|
|
295
|
+
``` javascript
|
|
296
|
+
<template>
|
|
297
|
+
<view class="login-container">
|
|
298
|
+
<view class="login-form">
|
|
299
|
+
<view class="title-section">
|
|
300
|
+
<text class="title">登录</text>
|
|
301
|
+
</view>
|
|
302
|
+
|
|
303
|
+
<view class="input-section">
|
|
304
|
+
<view class="input-group">
|
|
305
|
+
<text class="input-label">用户ID</text>
|
|
306
|
+
<input
|
|
307
|
+
class="input-field"
|
|
308
|
+
type="text"
|
|
309
|
+
v-model="userID"
|
|
310
|
+
placeholder="请输入用户ID"
|
|
311
|
+
/>
|
|
312
|
+
</view>
|
|
313
|
+
</view>
|
|
314
|
+
|
|
315
|
+
<view class="button-section">
|
|
316
|
+
<button
|
|
317
|
+
class="login-btn"
|
|
318
|
+
:disabled="!canLogin || isLoading"
|
|
319
|
+
@tap="handleLogin"
|
|
320
|
+
>
|
|
321
|
+
{{ isLoading ? '登录中...' : '登录' }}
|
|
322
|
+
</button>
|
|
323
|
+
</view>
|
|
324
|
+
</view>
|
|
325
|
+
</view>
|
|
326
|
+
</template>
|
|
327
|
+
|
|
328
|
+
<script>
|
|
329
|
+
import { TUILogin } from '@tencentcloud/tui-core-lite';
|
|
330
|
+
import { genTestUserSig } from '../../TUIKit/debug';
|
|
331
|
+
|
|
332
|
+
let vueVersion = 2;
|
|
333
|
+
// #ifdef VUE3
|
|
334
|
+
vueVersion = 3;
|
|
335
|
+
// #endif
|
|
336
|
+
|
|
337
|
+
const SDKAppID = 0; // Your SDKAppID
|
|
338
|
+
const secretKey = ''; // Your secretKey
|
|
339
|
+
|
|
340
|
+
export default {
|
|
341
|
+
data() {
|
|
342
|
+
return {
|
|
343
|
+
userID: '',
|
|
344
|
+
isLoading: false,
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
computed: {
|
|
348
|
+
canLogin() {
|
|
349
|
+
return this.userID.trim().length > 0
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
methods: {
|
|
353
|
+
async handleLogin() {
|
|
354
|
+
if (!this.canLogin || this.isLoading) return;
|
|
355
|
+
this.isLoading = true;
|
|
356
|
+
try {
|
|
357
|
+
const { userSig } = genTestUserSig({
|
|
358
|
+
SDKAppID: SDKAppID,
|
|
359
|
+
userID: this.userID,
|
|
360
|
+
secretKey: secretKey,
|
|
361
|
+
});
|
|
362
|
+
TUILogin.login({
|
|
363
|
+
SDKAppID: SDKAppID,
|
|
364
|
+
userID: this.userID,
|
|
365
|
+
userSig: userSig,
|
|
366
|
+
framework: `vue${vueVersion}` // framework used vue2 / vue3
|
|
367
|
+
})
|
|
368
|
+
.then(() => {
|
|
369
|
+
uni?.switchTab({
|
|
370
|
+
url: '/TUIKit/components/TUIConversation/index',
|
|
371
|
+
});
|
|
372
|
+
})
|
|
373
|
+
.catch((error) => {
|
|
374
|
+
console.error(error);
|
|
375
|
+
});
|
|
376
|
+
} catch (error) {
|
|
377
|
+
uni.showToast({
|
|
378
|
+
title: '登录失败',
|
|
379
|
+
icon: 'error'
|
|
380
|
+
})
|
|
381
|
+
} finally {
|
|
382
|
+
this.isLoading = false
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
</script>
|
|
388
|
+
|
|
389
|
+
<style lang="scss" scoped>
|
|
390
|
+
.login-container{display:flex;align-items:center;justify-content:center;}.login-form{width:100%;padding:80rpx 60rpx;}.title-section{text-align:center;margin-bottom:80rpx;}.title{font-size:48rpx;font-weight:bold;color:#333333;}.input-section{margin-bottom:60rpx;}.input-group{margin-bottom:40rpx;}.input-label{display:block;font-size:28rpx;color:#666666;margin-bottom:16rpx;}.input-field{width:100%;height:88rpx;border:2rpx solid #e0e0e0;border-radius:8rpx;padding:0 24rpx;font-size:32rpx;color:#333333;box-sizing:border-box;&:focus{border-color:#007aff;}}.button-section{margin-top:40rpx;}.login-btn{width:100%;height:88rpx;background-color:#007aff;color:#ffffff;border:none;border-radius:8rpx;font-size:32rpx;font-weight:600;}
|
|
391
|
+
</style>
|
|
392
|
+
```
|
|
393
|
+
2. **登出配置:**在项目 `pages` 目录下新建 `profile` 页面,并将以下代码复制到 `pages/profile/profile.vue`,完成个人中心和登出逻辑配置。
|
|
394
|
+
|
|
395
|
+
``` java
|
|
396
|
+
<template>
|
|
397
|
+
<div class="profile">
|
|
398
|
+
<div class="profile-basic">
|
|
399
|
+
<img
|
|
400
|
+
class="profile-basic-avatar"
|
|
401
|
+
:src="
|
|
402
|
+
userProfile.avatar ||
|
|
403
|
+
'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'
|
|
404
|
+
"
|
|
405
|
+
>
|
|
406
|
+
<div class="profile-basic-info">
|
|
407
|
+
<div class="profile-basic-info-nick"
|
|
408
|
+
>
|
|
409
|
+
{{ userProfile.nick || "-" }}
|
|
410
|
+
</div>
|
|
411
|
+
<div class="profile-basic-info-id">
|
|
412
|
+
<label class="profile-basic-info-id-label"
|
|
413
|
+
>{{ "用户ID" }}:</label>
|
|
414
|
+
<div class="profile-basic-info-id-value">
|
|
415
|
+
{{ userProfile.userID }}
|
|
416
|
+
</div>
|
|
417
|
+
</div>
|
|
418
|
+
</div>
|
|
419
|
+
</div>
|
|
420
|
+
<div class="profile-footer">
|
|
421
|
+
<button class="logout-btn" @click="logout">
|
|
422
|
+
退出登录
|
|
423
|
+
</button>
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
</template>
|
|
427
|
+
<script>
|
|
428
|
+
import { TUIUserService } from '@tencentcloud/chat-uikit-engine-lite';
|
|
429
|
+
import { TUILogin } from '@tencentcloud/tui-core-lite';
|
|
430
|
+
|
|
431
|
+
export default {
|
|
432
|
+
data() {
|
|
433
|
+
return {
|
|
434
|
+
userProfile: {}
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
methods: {
|
|
438
|
+
logout() {
|
|
439
|
+
TUILogin.logout().then(() => {
|
|
440
|
+
uni.reLaunch({
|
|
441
|
+
url: '/pages/index/index',
|
|
442
|
+
})
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
mounted() {
|
|
447
|
+
TUIUserService.getUserProfile().then((res) => {
|
|
448
|
+
this.userProfile = res.data;
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
</script>
|
|
453
|
+
|
|
454
|
+
<style lang="scss" scoped>
|
|
455
|
+
.profile{height:100%;flex:1;display:flex;flex-direction:column;&-basic{display:flex;gap:10px;box-sizing:border-box;padding:14px 18px;flex-direction:row;align-items:flex-start;border-bottom:10px solid #f5f5f5;&-avatar{flex:0 0 auto;width:78px;height:78px;border-radius:8px;}&-info{padding:10px 0;box-sizing:border-box;height:100%;flex:1;display:flex;flex-direction:column;justify-content:space-between;min-width:0;&-nick{font-size:14px;word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:PingFangSC-Medium;font-weight:500;color:#000;letter-spacing:0;}&-id{display:flex;align-items:center;font-family:PingFangSC-Regular;color:#999;letter-spacing:0;font-size:14px;word-break:keep-all;&-value{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}}}}&-footer{flex:1;display:flex;align-items:center;padding:20px 18px;margin-top:auto;.logout-btn{width:100%;padding:10px 20px;background-color:#ff4757;color:#ffffff;border:none;border-radius:8px;font-size:16px;font-weight:500;text-align:center;}}}
|
|
456
|
+
</style>
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
## 运行和测试
|
|
460
|
+
|
|
461
|
+
### 步骤1:运行项目
|
|
462
|
+
|
|
463
|
+
使用 HBuilderX 启动该项目,单击菜单栏中的:**运行** > **运行到手机或模拟器** > **运行到“指定”基座**。
|
|
464
|
+
|
|
465
|
+

|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
### 步骤2:发送您的第一条消息
|
|
469
|
+
- 登录页输入 [前提条件 > 开通服务 > 步骤3:创建测试账号](https://write.woa.com/#be7f0bca-1672-4a37-8653-aa8dd6a17547) 中创建的测试账号,点击登录进入 TUIKit。
|
|
470
|
+
|
|
471
|
+
- 点击**发起单聊**后并在**搜索栏**输入 [前提条件 > 开通服务 > 步骤3:创建测试账号](https://write.woa.com/#be7f0bca-1672-4a37-8653-aa8dd6a17547) 中创建的另一个测试账号 `userID`。
|
|
472
|
+
|
|
473
|
+
- 选中后单击**完成**,即可进入聊天界面并发送您的第一条消息。
|
|
474
|
+
|
|
475
|
+

|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
## 更多高级特性(强烈推荐)
|
|
479
|
+
|
|
480
|
+
### [消息推送](https://cloud.tencent.com/document/product/269/103522)
|
|
481
|
+
|
|
482
|
+
> **说明:**
|
|
483
|
+
>
|
|
484
|
+
|
|
485
|
+
> 如果您的 app 需要推送功能,推荐您接入 [uni-app 腾讯云推送服务(Push)](https://cloud.tencent.com/document/product/269/103522),支持 iOS 和 Android 推送,同时适配各大厂商推送。对 FCM 也有完善的支持,**出海必备**。
|
|
486
|
+
>
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+

|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
### [消息云端搜索](https://console.cloud.tencent.com/im/plugin/TUICloudSearch)
|
|
493
|
+
|
|
494
|
+
> **说明:**
|
|
495
|
+
>
|
|
496
|
+
|
|
497
|
+
> @tencentcloud/chat-uikit-uniapp ≥ 2.0.6 默认支持, 只需要进入 [控制台 > 插件市场 > 云端搜索](https://cloud.tencent.com/login?s_url=https%3A%2F%2Fconsole.cloud.tencent.com%2Fim%2Fplugin%2FTUICloudSearch) ,单击**免费试用**或**购买插件**即可使用消息云端搜索功能。
|
|
498
|
+
>
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+

|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
### 音视频通话 TUICallKit 插件
|
|
505
|
+
|
|
506
|
+
> **说明:**
|
|
507
|
+
>
|
|
508
|
+
> - **TUIKit 中默认没有集成 TUICallKit 音视频组件**。
|
|
509
|
+
> - TUICallKit 主要负责语音、视频通话。
|
|
510
|
+
|
|
511
|
+
<table>
|
|
512
|
+
<tr>
|
|
513
|
+
<td rowspan="1" colSpan="1" >运行平台</td>
|
|
514
|
+
|
|
515
|
+
<td rowspan="1" colSpan="1" >集成方案</td>
|
|
516
|
+
|
|
517
|
+
<td rowspan="1" colSpan="1" >文档链接</td>
|
|
518
|
+
</tr>
|
|
519
|
+
|
|
520
|
+
<tr>
|
|
521
|
+
<td rowspan="1" colSpan="1" >移动端应用 (App)</td>
|
|
522
|
+
|
|
523
|
+
<td rowspan="1" colSpan="1" >请集成 **uni-app (客户端) TUICallKit**。</td>
|
|
524
|
+
|
|
525
|
+
<td rowspan="1" colSpan="1" >[音视频通话(客户端)](https://cloud.tencent.com/document/product/269/83857)</td>
|
|
526
|
+
</tr>
|
|
527
|
+
|
|
528
|
+
<tr>
|
|
529
|
+
<td rowspan="1" colSpan="1" >H5 环境</td>
|
|
530
|
+
|
|
531
|
+
<td rowspan="1" colSpan="1" >请集成 **uni-app (H5) TUICallKit**。</td>
|
|
532
|
+
|
|
533
|
+
<td rowspan="1" colSpan="1" >[音视频通话(H5)](https://cloud.tencent.com/document/product/269/97872)</td>
|
|
534
|
+
</tr>
|
|
535
|
+
</table>
|
|
536
|
+
|
|
537
|
+
- 客户端通话示意图:
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+

|
|
541
|
+
|
|
542
|
+
- H5 通话示意图:
|
|
543
|
+
|
|
544
|
+

|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
### [智能客服](https://cloud.tencent.com/document/product/269/97537)
|
|
548
|
+
|
|
549
|
+
> **说明:**
|
|
550
|
+
>
|
|
551
|
+
> - 进入[智能客服控制台](https://console.cloud.tencent.com/im/ai-desk),选择应用后,通过领取试用(每个应用都可领取2次、每次有效期7天的免费试用)或者直接购买,开通智能客服。如果您没有可选择的应用,可参见 [创建应用](https://cloud.tencent.com/document/product/269/32577) 步骤操作,再为新建应用开通智能客服。
|
|
552
|
+
> - 单独购买智能客服时,仅支持用户和客服号收发消息,账号数和 DAU 无上限。如需 C2C 聊天、群聊等功能,请加购 IM 套餐包。
|
|
553
|
+
> - 集成请参考 [用户端 SDK 轻量接入](https://cloud.tencent.com/document/product/269/97537)。
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+

|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
### 云端审核
|
|
560
|
+
|
|
561
|
+
在消息发送、资料修改场景中,很有可能会扩散不合适的内容,特别是与敏感事件/人物相关、黄色不良内容等令人反感的内容,不仅严重损害了用户们的身心健康,更很有可能违法并导致业务被监管部门查封。即时通信 IM 支持云端内容审核(反垃圾信息)功能,可针对不安全、不适宜的内容进行自动识别、处理,为您的产品体验和业务安全保驾护航。
|
|
562
|
+
|
|
563
|
+
[云端审核](https://write.woa.com/document/107052219630235648):在服务端检测由单聊、群聊、资料场景中产生的文本、图片、音频、视频内容,支持针对不同场景的不同内容分别配置审核策略,并对识别出的不安全内容进行拦截。此功能已提供默认预设拦截词库和审核场景,只需在 IM 控制台打开功能开关,即可直接使用。
|
|
564
|
+
|
|
565
|
+
## 常见问题
|
|
566
|
+
|
|
567
|
+
### Debug 文件的作用?
|
|
568
|
+
|
|
569
|
+
主要作用:在开发阶段,TUIKit 提供了 debug 文件夹中的本地 UserSig 生成脚本,**用于方便开发和调试**。
|
|
570
|
+
|
|
571
|
+
> **警告:(该方法仅适合本地跑通 Demo 和功能调试)**
|
|
572
|
+
>
|
|
573
|
+
> - 该方法中的 `SECRETKEY` 容易被反编译逆向破解。
|
|
574
|
+
> - 一旦密钥泄露,攻击者可以盗用您的腾讯云流量。
|
|
575
|
+
> - 仅适用于本地 Demo 运行和功能调试,**绝对不能用于生产环境**。
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
**请在项目发布前删除 Debug 脚本,使用后台生成 UserSig**,具体原因和操作步骤请参考文档:[生成 UserSig](https://cloud.tencent.com/document/product/269/32688)。
|
|
579
|
+
|
|
580
|
+
### uniapp 打包 App 中 Chat 的实例是 web 实例还是 native 实例?
|
|
581
|
+
|
|
582
|
+
chat-uikit-uniapp 即使打包为 App,其 Chat 实例依然是 web 实例,而非 native 实例。
|
|
583
|
+
|
|
584
|
+
### Conversation 中 groupProfile 或 userProfile 信息不全是为什么,如何获取?
|
|
585
|
+
|
|
586
|
+
原因:会话(Conversation)中携带的群组资料(groupProfile)或用户资料(userProfile)通常是简化版本,主要包含最核心的信息,例如基本的群名称、群头像或用户的昵称、头像等。这样设计的首要目的是为了提升性能和应用响应速度。
|
|
587
|
+
|
|
588
|
+
解决方案:
|
|
589
|
+
- **获取完整的群组资料**:通过 [TUIGroupService.getGroupProfile](https://web.sdk.qcloud.com/im/doc/chat-engine-lite/ITUIGroupService.html#getGroupProfile) 获取。
|
|
590
|
+
|
|
591
|
+
- **获取完整的用户资料**:通过 [TUIUserService.getUserProfile](https://web.sdk.qcloud.com/im/doc/chat-engine-lite/ITUIUserService.html#getUserProfile) 获取。
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
> **说明:**
|
|
595
|
+
>
|
|
596
|
+
|
|
597
|
+
> 群组或用户的自定义字段的获取都需要在完整信息中获取。
|
|
598
|
+
>
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
**更多常见问题请参见:**[**uni-app 相关问题**](https://write.woa.com/document/107052248780648448)**。**
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
## 参考信息
|
|
605
|
+
|
|
606
|
+
TUIKit GitHub 源码:
|
|
607
|
+
- [chat-uikit-uniapp (vue2/vue3) GitHub 源码](https://github.com/TencentCloud/chat-uikit-uniapp)
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
实现更多功能,请参考 ChatEngine API 文档:
|
|
611
|
+
|
|
612
|
+
- [ChatEngine API 手册](https://web.sdk.qcloud.com/im/doc/chat-engine-lite/index.html)
|
|
613
|
+
|
|
614
|
+
- [ChatEngine Lite npm](https://www.npmjs.com/package/@tencentcloud/chat-uikit-engine-lite)
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
## 联系我们
|
|
618
|
+
|
|
619
|
+
如遇任何问题,可联系 [官网售后](https://cloud.tencent.com/act/event/connect-service#/) 反馈,享有专业工程师的支持,解决您的难题。
|