@tencentcloud/sdk-mcp 1.3.7 → 1.3.9

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 (77) hide show
  1. package/package.json +2 -1
  2. package/resource/doc/chatuikit/android/integration.md +466 -484
  3. package/resource/doc/chatuikit/android/workflow.md +713 -0
  4. package/resource/doc/livekit/live/flutter/live-integration.md +208 -167
  5. package/resource/doc/livekit/voice/android/voice-audience-list.md +335 -0
  6. package/resource/doc/livekit/voice/android/voice-audio-effect.md +384 -0
  7. package/resource/doc/livekit/voice/android/voice-barrage.md +569 -0
  8. package/resource/doc/livekit/voice/android/voice-co-guest-interaction.md +748 -0
  9. package/resource/doc/livekit/voice/android/voice-gift.md +833 -0
  10. package/resource/doc/livekit/voice/android/voice-host-interaction.md +728 -0
  11. package/resource/doc/livekit/voice/android/voice-integration.md +886 -0
  12. package/resource/doc/livekit/voice/android/voice-room-list.md +493 -0
  13. package/resource/doc/livekit/voice/android/workflow.md +333 -0
  14. package/resource/doc/livekit/voice/flutter/voice-audience-list.md +337 -0
  15. package/resource/doc/livekit/voice/flutter/voice-audio-effect.md +739 -0
  16. package/resource/doc/livekit/voice/flutter/voice-barrage.md +578 -0
  17. package/resource/doc/livekit/voice/flutter/voice-co-guest-interaction.md +673 -0
  18. package/resource/doc/livekit/voice/flutter/voice-gift.md +812 -0
  19. package/resource/doc/livekit/voice/flutter/voice-integration.md +925 -0
  20. package/resource/doc/livekit/voice/flutter/voice-room-list.md +842 -0
  21. package/resource/doc/livekit/voice/flutter/workflow.md +359 -0
  22. package/resource/doc/livekit/voice/ios/voice-audience-list.md +335 -0
  23. package/resource/doc/livekit/voice/ios/voice-audio-effect.md +373 -0
  24. package/resource/doc/livekit/voice/ios/voice-barrage.md +529 -0
  25. package/resource/doc/livekit/voice/ios/voice-co-guest-interaction.md +701 -0
  26. package/resource/doc/livekit/voice/ios/voice-gift.md +785 -0
  27. package/resource/doc/livekit/voice/ios/voice-host-interaction.md +820 -0
  28. package/resource/doc/livekit/voice/ios/voice-integration.md +853 -0
  29. package/resource/doc/livekit/voice/ios/voice-room-list.md +467 -0
  30. package/resource/doc/livekit/voice/ios/workflow.md +358 -0
  31. package/resource/doc/livekit/voice/uni-app/voice-audience-list.md +264 -0
  32. package/resource/doc/livekit/voice/uni-app/voice-audio-effect.md +332 -0
  33. package/resource/doc/livekit/voice/uni-app/voice-barrage.md +482 -0
  34. package/resource/doc/livekit/voice/uni-app/voice-co-guest-interaction.md +944 -0
  35. package/resource/doc/livekit/voice/uni-app/voice-gift.md +716 -0
  36. package/resource/doc/livekit/voice/uni-app/voice-integration.md +613 -0
  37. package/resource/doc/livekit/voice/uni-app/voice-room-list.md +562 -0
  38. package/resource/doc/livekit/voice/uni-app/workflow.md +369 -0
  39. package/resource/doc/roomkit/vue/integration.md +119 -224
  40. package/resource/doc/roomkit/vue/workflow.md +472 -226
  41. package/resource/doc/tuicallkit/android/integration.md +675 -90
  42. package/resource/doc/tuicallkit/android/workflow.md +432 -0
  43. package/tools/common/present-scenario-choice.js +16 -0
  44. package/tools/common/present-scenario-choice.js.map +1 -0
  45. package/tools/common/record-prompt.js +31 -0
  46. package/tools/common/record-prompt.js.map +1 -1
  47. package/tools/common/record-result.js +32 -0
  48. package/tools/common/record-result.js.map +1 -1
  49. package/tools/definitions/get_native_call_uikit_integration_def.js +18 -2
  50. package/tools/definitions/get_native_call_uikit_integration_def.js.map +1 -1
  51. package/tools/definitions/get_native_chat_uikit_integration_def.js +29 -7
  52. package/tools/definitions/get_native_chat_uikit_integration_def.js.map +1 -1
  53. package/tools/definitions/get_native_live_uikit_integration_def.js +65 -40
  54. package/tools/definitions/get_native_live_uikit_integration_def.js.map +1 -1
  55. package/tools/definitions/get_native_live_uikit_interaction_def.js +42 -94
  56. package/tools/definitions/get_native_live_uikit_interaction_def.js.map +1 -1
  57. package/tools/definitions/get_web_room_feature_detail_def.js +29 -32
  58. package/tools/definitions/get_web_room_feature_detail_def.js.map +1 -1
  59. package/tools/definitions/get_web_room_uikit_integration_def.js +25 -9
  60. package/tools/definitions/get_web_room_uikit_integration_def.js.map +1 -1
  61. package/tools/definitions/present_scenario_choice_def.js +53 -0
  62. package/tools/definitions/present_scenario_choice_def.js.map +1 -0
  63. package/tools/definitions/record_prompt_def.js +6 -1
  64. package/tools/definitions/record_prompt_def.js.map +1 -1
  65. package/tools/definitions/record_result_def.js +34 -10
  66. package/tools/definitions/record_result_def.js.map +1 -1
  67. package/tools/index.js +2 -0
  68. package/tools/index.js.map +1 -1
  69. package/tools/live/get-native-live-uikit-integration.js +110 -34
  70. package/tools/live/get-native-live-uikit-integration.js.map +1 -1
  71. package/tools/live/get_native_live_uikit_interaction.js +128 -35
  72. package/tools/live/get_native_live_uikit_interaction.js.map +1 -1
  73. package/utils/get-device-identifier.js +58 -0
  74. package/utils/get-device-identifier.js.map +1 -0
  75. package/utils/report-cls-client.js +4 -2
  76. package/utils/report-cls-client.js.map +1 -1
  77. package/utils/report-es-client.js +1 -1
@@ -0,0 +1,716 @@
1
+ `GiftState` 是 `AtomicXCore` 中专门负责管理直播间礼物功能的模块。通过它,您可以为您的直播应用构建一套完整的礼物系统,实现丰富的营收和互动场景。
2
+ <table>
3
+ <tr>
4
+ <td rowspan="1" colSpan="1" >礼物面板</td>
5
+
6
+ <td rowspan="1" colSpan="1" >弹幕礼物</td>
7
+
8
+ <td rowspan="1" colSpan="1" >全屏礼物</td>
9
+ </tr>
10
+
11
+ <tr>
12
+ <td rowspan="1" colSpan="1" ><br>![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100028028022/92743423bbbc11f0b4c35254001c06ec.png)</td>
13
+
14
+ <td rowspan="1" colSpan="1" ><br>![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100028028022/98aa70f4bbbc11f0b4c35254001c06ec.png)</td>
15
+
16
+ <td rowspan="1" colSpan="1" ><br>![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100028028022/9c60d5edbbbc11f085a55254007c27c5.png)</td>
17
+ </tr>
18
+ </table>
19
+
20
+
21
+ ## 核心功能
22
+ - **礼物列表获取**:从服务端拉取礼物面板所需的数据,包括礼物分类和礼物详情。
23
+
24
+ - **发送礼物**:观众可以向主播发送选定的礼物,并附带数量。
25
+
26
+ - **礼物事件广播**:实时接收房间内发生的礼物赠送事件,用于展示礼物动画和弹幕通知。
27
+
28
+
29
+ ## 实现步骤
30
+
31
+ ### 步骤1:组件集成
32
+
33
+ > **说明:**
34
+ >
35
+
36
+ > 使用**礼物系统**要求开通TUILiveKit **多人连麦版**、**大规模直播版**,不同套餐中可配置的礼物数量有所不同,详细参见 [功能与计费说明](https://write.woa.com/document/141302177829593088) 中的**礼物系统**说明。
37
+ >
38
+
39
+ - **视频直播**:请参考 [快速接入](https://write.woa.com/document/191127271985012736) 集成 **AtomicXCore**,完成接入。
40
+
41
+ - **语聊房**:请参考 [快速接入](https://write.woa.com/document/191656297444069376) 集成 **AtomicXCore**,完成接入。
42
+
43
+
44
+ ### 步骤2:初始化并监听礼物事件
45
+
46
+ 获取 `GiftState` 实例,并设置订阅者以接收礼物事件和礼物列表更新。
47
+
48
+ #### 实现方式:
49
+ 1. **获取实例**:使用 `useGiftState(liveID)` 获取与当前直播间绑定的 `GiftState` 实例。
50
+
51
+ 2. **订阅事件**:使用 `addGiftListener` 以订阅 `'onReceiveGift'`事件。
52
+
53
+ 3. **监听状态**:监听 响应式数据`usableGifts `礼物列表,来驱动 `UI` 更新。
54
+
55
+
56
+ #### 代码示例:
57
+ ``` typescript
58
+ import { useGiftState } from "@/uni_modules/tuikit-atomic-x/state/GiftState";
59
+ import { onMounted, watch } from 'vue';
60
+
61
+ // liveID 是语聊房的唯一标识
62
+ const liveID = 'your_live_id'; // 替换为实际的语聊房 liveID
63
+
64
+ // 通过 liveID 获取 GiftState 的实例
65
+ const { addGiftListener, usableGifts } = useGiftState(liveID);
66
+
67
+ onMounted(() => {
68
+ addGiftListener(liveID, 'onReceiveGift', {
69
+ callback: (event) => {
70
+ const gift = JSON.parse(event)
71
+ console.log('收到礼物', gift)
72
+ // 在此进行礼物的处理逻辑,例如 svga 格式的礼物进行播放,其他格式的进行弹窗提示
73
+ }
74
+ })
75
+ })
76
+
77
+ // 监听 usableGifts 的实时变更,用于驱动 UI 变更
78
+ watch(usableGifts, (newVal, oldVal) => {
79
+ console.log(newVal)
80
+ })
81
+ ```
82
+
83
+ #### 礼物列表结构体参数
84
+ - `GiftCategory`**参数说明**
85
+
86
+ <table>
87
+ <tr>
88
+ <td rowspan="1" colSpan="1" >**参数**</td>
89
+
90
+ <td rowspan="1" colSpan="1" >**类型**</td>
91
+
92
+ <td rowspan="1" colSpan="1" >**描述**</td>
93
+ </tr>
94
+
95
+ <tr>
96
+ <td rowspan="1" colSpan="1" >`categoryID`</td>
97
+
98
+ <td rowspan="1" colSpan="1" >`string`</td>
99
+
100
+ <td rowspan="1" colSpan="1" >礼物分类的唯一 ID。</td>
101
+ </tr>
102
+
103
+ <tr>
104
+ <td rowspan="1" colSpan="1" >`name`</td>
105
+
106
+ <td rowspan="1" colSpan="1" >`string`</td>
107
+
108
+ <td rowspan="1" colSpan="1" >礼物分类的显示名称。</td>
109
+ </tr>
110
+
111
+ <tr>
112
+ <td rowspan="1" colSpan="1" >`desc`</td>
113
+
114
+ <td rowspan="1" colSpan="1" >`string`</td>
115
+
116
+ <td rowspan="1" colSpan="1" >礼物分类的描述信息。</td>
117
+ </tr>
118
+
119
+ <tr>
120
+ <td rowspan="1" colSpan="1" >`extensionInfo`</td>
121
+
122
+ <td rowspan="1" colSpan="1" >`[string: string]`</td>
123
+
124
+ <td rowspan="1" colSpan="1" >扩展信息字段。</td>
125
+ </tr>
126
+
127
+ <tr>
128
+ <td rowspan="1" colSpan="1" >`giftList`</td>
129
+
130
+ <td rowspan="1" colSpan="1" >`[string]`</td>
131
+
132
+ <td rowspan="1" colSpan="1" >该分类下包含的 Gift 礼物对象数组。</td>
133
+ </tr>
134
+ </table>
135
+
136
+ - `Gift`** 参数说明**
137
+
138
+ <table>
139
+ <tr>
140
+ <td rowspan="1" colSpan="1" >**参数**</td>
141
+
142
+ <td rowspan="1" colSpan="1" >**类型**</td>
143
+
144
+ <td rowspan="1" colSpan="1" >**描述**</td>
145
+ </tr>
146
+
147
+ <tr>
148
+ <td rowspan="1" colSpan="1" >`giftID`</td>
149
+
150
+ <td rowspan="1" colSpan="1" >`string`</td>
151
+
152
+ <td rowspan="1" colSpan="1" > 礼物的唯一 ID。</td>
153
+ </tr>
154
+
155
+ <tr>
156
+ <td rowspan="1" colSpan="1" >`name`</td>
157
+
158
+ <td rowspan="1" colSpan="1" >`string`</td>
159
+
160
+ <td rowspan="1" colSpan="1" > 礼物的显示名称。</td>
161
+ </tr>
162
+
163
+ <tr>
164
+ <td rowspan="1" colSpan="1" >`desc`</td>
165
+
166
+ <td rowspan="1" colSpan="1" >`string`</td>
167
+
168
+ <td rowspan="1" colSpan="1" > 礼物的描述信息。</td>
169
+ </tr>
170
+
171
+ <tr>
172
+ <td rowspan="1" colSpan="1" >`iconURL`</td>
173
+
174
+ <td rowspan="1" colSpan="1" >`string`</td>
175
+
176
+ <td rowspan="1" colSpan="1" > 礼物图标 URL。</td>
177
+ </tr>
178
+
179
+ <tr>
180
+ <td rowspan="1" colSpan="1" >`resourceURL`</td>
181
+
182
+ <td rowspan="1" colSpan="1" >`string`</td>
183
+
184
+ <td rowspan="1" colSpan="1" > 礼物动画资源 URL。</td>
185
+ </tr>
186
+
187
+ <tr>
188
+ <td rowspan="1" colSpan="1" >`level`</td>
189
+
190
+ <td rowspan="1" colSpan="1" >`number`</td>
191
+
192
+ <td rowspan="1" colSpan="1" > 礼物等级。</td>
193
+ </tr>
194
+
195
+ <tr>
196
+ <td rowspan="1" colSpan="1" >`coins`</td>
197
+
198
+ <td rowspan="1" colSpan="1" >`number`</td>
199
+
200
+ <td rowspan="1" colSpan="1" > 礼物价格。</td>
201
+ </tr>
202
+
203
+ <tr>
204
+ <td rowspan="1" colSpan="1" >`extensionInfo`</td>
205
+
206
+ <td rowspan="1" colSpan="1" >`[string: string]`</td>
207
+
208
+ <td rowspan="1" colSpan="1" > 扩展信息字段。</td>
209
+ </tr>
210
+ </table>
211
+
212
+
213
+ ### 步骤3:获取礼物列表
214
+
215
+ 调用 `refreshUsableGifts` 方法,从服务端拉取礼物数据。
216
+
217
+ #### 实现方式:
218
+ 1. **调用接口**:在合适的时机(例如页面加载时)调用 `refreshUsableGifts()`。
219
+
220
+ 2. **处理回调**:可选地处理 `success`,`fail` 回调以获知拉取结果。
221
+
222
+ 3. **接收数据**:拉取成功后,通过步骤二中对 `usableGifts` 的监听,自动接收到更新后的 `usableGifts` 列表。
223
+
224
+
225
+ #### 代码示例:
226
+ ``` typescript
227
+ import { useGiftState } from "@/uni_modules/tuikit-atomic-x/state/GiftState";
228
+ import { onMounted } from 'vue';
229
+ 
230
+ // liveID 是语聊房的唯一标识
231
+ const liveID = 'your_live_id'; // 替换为实际的语聊房 liveID
232
+
233
+ // 通过 liveID 获取 GiftState 的实例
234
+ const { addGiftListener, usableGifts } = useGiftState(liveID);
235
+ 
236
+ onMounted(() => {
237
+ refreshUsableGifts({
238
+ liveID: 'xxx', // 当前直播间的 liveID
239
+ success: () => {
240
+ console.log('礼物列表拉取成功')
241
+ // 成功后,state 响应式数据会自动更新
242
+ },
243
+ faile: (error) => {
244
+ console.log('礼物列表拉取失败', error)
245
+ }
246
+ })
247
+ })
248
+ ```
249
+
250
+ ### 步骤4:发送礼物
251
+
252
+ 当用户在礼物面板选择一个礼物并点击发送时,调用 `sendGift` 接口将礼物发送出去。
253
+
254
+ #### 实现方式:
255
+ 1. **获取参数**:从 UI 获取用户选择的 `giftID` 和发送数量 `count`。
256
+
257
+ 2. **调用接口**:调用 `sendGift(giftID,count)`。
258
+
259
+ 3. **处理回调**:在 `fail` 回调中处理发送失败的情况(例如余额不足提示);发送成功后的 UI 更新(动画、弹幕)应由 `'onReceiveGift'` 事件驱动。
260
+
261
+
262
+ #### 代码示例:
263
+ ``` typescript
264
+
265
+ import { useGiftState } from "@/uni_modules/tuikit-atomic-x/state/GiftState";
266
+ 
267
+ // liveID 是语聊房的唯一标识
268
+ const liveID = 'your_live_id'; // 替换为实际的语聊房 liveID
269
+
270
+ // 通过 liveID 获取 GiftState 的实例
271
+ const { sendGift } = useGiftState(liveID);
272
+
273
+ // 用户发送一个礼物
274
+ const sendGift = () => {
275
+ sendGift({
276
+ liveID: 'xxx', // 当前直播间 liveID
277
+ giftID: giftID,
278
+ count: 1,
279
+ success: () => {
280
+ console.log('礼物 ${giftID} 发送成功')
281
+ },
282
+ fail: (error) => {
283
+ console.log('礼物发送失败', error)
284
+ // 可以在此提示用户,例如“余额不足”或“网络错误”
285
+ },
286
+ })
287
+ }
288
+ ```
289
+
290
+ #### `sendGift`接口参数
291
+ <table>
292
+ <tr>
293
+ <td rowspan="1" colSpan="1" >**参数名**</td>
294
+
295
+ <td rowspan="1" colSpan="1" >**类型**</td>
296
+
297
+ <td rowspan="1" colSpan="1" >**描述**</td>
298
+ </tr>
299
+
300
+ <tr>
301
+ <td rowspan="1" colSpan="1" >`liveID`</td>
302
+
303
+ <td rowspan="1" colSpan="1" >`string`</td>
304
+
305
+ <td rowspan="1" colSpan="1" >当前直播间的`liveID`。</td>
306
+ </tr>
307
+
308
+ <tr>
309
+ <td rowspan="1" colSpan="1" >`giftID`</td>
310
+
311
+ <td rowspan="1" colSpan="1" >`string`</td>
312
+
313
+ <td rowspan="1" colSpan="1" >要发送的礼物的唯一 ID。</td>
314
+ </tr>
315
+
316
+ <tr>
317
+ <td rowspan="1" colSpan="1" >`count`</td>
318
+
319
+ <td rowspan="1" colSpan="1" >`number`</td>
320
+
321
+ <td rowspan="1" colSpan="1" >发送的数量。</td>
322
+ </tr>
323
+
324
+ <tr>
325
+ <td rowspan="1" colSpan="1" >`success`</td>
326
+
327
+ <td rowspan="1" colSpan="1" >`Function`</td>
328
+
329
+ <td rowspan="1" colSpan="1" >发送成功的回调。</td>
330
+ </tr>
331
+
332
+ <tr>
333
+ <td rowspan="1" colSpan="1" >`fail`</td>
334
+
335
+ <td rowspan="1" colSpan="1" >`Function`</td>
336
+
337
+ <td rowspan="1" colSpan="1" >发送失败的回调。</td>
338
+ </tr>
339
+ </table>
340
+
341
+
342
+ ## 功能进阶
343
+
344
+ `GiftState` 的功能高度依赖于您的业务后台服务。本章将指导您如何通过服务端配置和客户端实现,构建功能丰富、体验卓越的礼物互动系统。
345
+
346
+ ### **礼物素材配置**
347
+
348
+ 您需要自定义直播间可用的礼物种类、分类、名称、图标、价格以及动画效果,以满足运营需求和品牌特色。
349
+
350
+ #### **实现方式 **
351
+ 1. **服务端配置**:使用 LiveKit 服务端 REST API 管理礼物信息、分类、多语言等。请参考 [礼物配置指引文档](https://cloud.tencent.com/document/product/647/121321)。
352
+
353
+ 2. **客户端拉取**:在客户端调用 `refreshUsableGifts` 获取配置数据。
354
+
355
+ 3. **UI 展示**:使用拉取到的 `[GiftCategory]` 数据填充礼物面板。
356
+
357
+
358
+ #### **配置时序图**
359
+
360
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100028028022/bd9fcf8dbbbc11f0a808525400bf7822.png)
361
+
362
+
363
+ #### **涉及 REST API 接口一览**
364
+ <table>
365
+ <tr>
366
+ <td rowspan="1" colSpan="1" >接口分类</td>
367
+
368
+ <td rowspan="1" colSpan="1" >接口</td>
369
+
370
+ <td rowspan="1" colSpan="1" >请求示例</td>
371
+ </tr>
372
+
373
+ <tr>
374
+ <td rowspan="3" colSpan="1" >​礼物管理​</td>
375
+
376
+ <td rowspan="1" colSpan="1" >添加礼物信息</td>
377
+
378
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341527570997248)</td>
379
+ </tr>
380
+
381
+ <tr>
382
+ <td rowspan="1" colSpan="1" >删除礼物信息</td>
383
+
384
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341544133693440)</td>
385
+ </tr>
386
+
387
+ <tr>
388
+ <td rowspan="1" colSpan="1" >查询礼物信息</td>
389
+
390
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341539054186496)</td>
391
+ </tr>
392
+
393
+ <tr>
394
+ <td rowspan="3" colSpan="1" >礼物​分类管理​</td>
395
+
396
+ <td rowspan="1" colSpan="1" >添加礼物分类信息</td>
397
+
398
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180807825764642816)</td>
399
+ </tr>
400
+
401
+ <tr>
402
+ <td rowspan="1" colSpan="1" >删除指定礼物分类信息</td>
403
+
404
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180807830209925120)</td>
405
+ </tr>
406
+
407
+ <tr>
408
+ <td rowspan="1" colSpan="1" >获取指定礼物分类信息</td>
409
+
410
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180807827909746688)</td>
411
+ </tr>
412
+
413
+ <tr>
414
+ <td rowspan="3" colSpan="1" >​礼物关系管理​</td>
415
+
416
+ <td rowspan="1" colSpan="1" >添加指定礼物分类和礼物间的关系</td>
417
+
418
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341551420928000)</td>
419
+ </tr>
420
+
421
+ <tr>
422
+ <td rowspan="1" colSpan="1" >删除指定礼物分类和礼物间的关系</td>
423
+
424
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341562381627392)</td>
425
+ </tr>
426
+
427
+ <tr>
428
+ <td rowspan="1" colSpan="1" >获取指定礼物分类下的礼物关系</td>
429
+
430
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341571868094464)</td>
431
+ </tr>
432
+
433
+ <tr>
434
+ <td rowspan="6" colSpan="1" >​礼物多语言​管理</td>
435
+
436
+ <td rowspan="1" colSpan="1" >添加礼物多语言信息</td>
437
+
438
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341579611611136)</td>
439
+ </tr>
440
+
441
+ <tr>
442
+ <td rowspan="1" colSpan="1" >删除指定礼物多语言信息</td>
443
+
444
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341598501920768)</td>
445
+ </tr>
446
+
447
+ <tr>
448
+ <td rowspan="1" colSpan="1" >获取礼物多语言信息</td>
449
+
450
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341588810166272)</td>
451
+ </tr>
452
+
453
+ <tr>
454
+ <td rowspan="1" colSpan="1" >添加礼物分类多语言信息</td>
455
+
456
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341603609534464)</td>
457
+ </tr>
458
+
459
+ <tr>
460
+ <td rowspan="1" colSpan="1" >删除指定礼物分类多语言信息</td>
461
+
462
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341624911425536)</td>
463
+ </tr>
464
+
465
+ <tr>
466
+ <td rowspan="1" colSpan="1" >获取礼物分类多语言信息</td>
467
+
468
+ <td rowspan="1" colSpan="1" >[请求示例](https://write.woa.com/document/180341612525645824)</td>
469
+ </tr>
470
+ </table>
471
+
472
+
473
+ ### 计费与送礼扣费流程
474
+
475
+ 当观众赠送礼物时,需要确保其账户余额充足,并完成实际的扣费操作,然后才能触发礼物特效的播放和广播。
476
+
477
+ #### 实现方式
478
+ 1. **后台配置回调**:在 LiveKit 后台配置您的自建计费系统的回调 URL。参考 [回调配置文档](https://write.woa.com/document/183772947196690432)。
479
+
480
+ 2. **客户端发送**:客户端调用 `sendGift`。
481
+
482
+ 3. **后台交互**:LiveKit 后台调用您的回调 URL,您的计费系统执行扣费并返回结果。
483
+
484
+ 4. **结果同步**:扣费成功,AtomicXCore 广播 `'onReceiveGift'` 事件。扣费失败,`sendGift` 的 `fail` 收到错误。
485
+
486
+
487
+ #### 调用流程图
488
+
489
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100028028022/cb539aa9bbbc11f0a808525400bf7822.png)
490
+
491
+
492
+ #### 涉及 REST API 接口一览
493
+ <table>
494
+ <tr>
495
+ <td rowspan="1" colSpan="1" >接口</td>
496
+
497
+ <td rowspan="1" colSpan="1" >说明</td>
498
+
499
+ <td rowspan="1" colSpan="1" >请求示例</td>
500
+ </tr>
501
+
502
+ <tr>
503
+ <td rowspan="1" colSpan="1" >回调配置 - 发送礼物之前回调</td>
504
+
505
+ <td rowspan="1" colSpan="1" >客户后台可以通过该回调决定是否通过送礼前校验等场景</td>
506
+
507
+ <td rowspan="1" colSpan="1" >[调用示例](https://write.woa.com/document/183772947196690432)</td>
508
+ </tr>
509
+ </table>
510
+
511
+
512
+ ### 实现全屏礼物动画播放
513
+
514
+ 当直播间有用户(包括自己)发送了“火箭”、“嘉年华”等豪华礼物时,全屏播放一个酷炫的礼物动画(例如 SVGA 动画),营造热烈的氛围。
515
+
516
+ #### 实现方式
517
+
518
+ `AtomicXCore` 本身包含礼物动画播放器,您可以根据业务需求选择并集成第三方库。以下是两种方案的对比:
519
+ <table>
520
+ <tr>
521
+ <td rowspan="1" colSpan="1" >**对比项**</td>
522
+
523
+ <td rowspan="1" colSpan="1" >**内置方案 (SVGAPlayer)**</td>
524
+
525
+ <td rowspan="1" colSpan="1" >**高级方案 (TCEffectPlayerKit)**</td>
526
+ </tr>
527
+
528
+ <tr>
529
+ <td rowspan="1" colSpan="1" >计费</td>
530
+
531
+ <td rowspan="1" colSpan="1" >免费 </td>
532
+
533
+ <td rowspan="1" colSpan="1" >付费 (需购买 License),请参见 [付费指引](https://cloud.tencent.com/document/product/616/116461)</td>
534
+ </tr>
535
+
536
+ <tr>
537
+ <td rowspan="1" colSpan="1" >集成方式</td>
538
+
539
+ <td rowspan="1" colSpan="1" >AtomicXCore 内置</td>
540
+
541
+ <td rowspan="1" colSpan="1" >需额外集成 TCEffectPlayerKit 并进行鉴权</td>
542
+ </tr>
543
+
544
+ <tr>
545
+ <td rowspan="1" colSpan="1" >动画格式支持</td>
546
+
547
+ <td rowspan="1" colSpan="1" >仅支持 SVGA</td>
548
+
549
+ <td rowspan="1" colSpan="1" >SVGA、PAG、WebP、Lottie、MP4 等多种格式</td>
550
+ </tr>
551
+
552
+ <tr>
553
+ <td rowspan="1" colSpan="1" >性能</td>
554
+
555
+ <td rowspan="1" colSpan="1" >建议 SVGA 文件 ≤ 10MB</td>
556
+
557
+ <td rowspan="1" colSpan="1" >支持更大的动画文件,复杂特效/多动画并发/低端机表现更优</td>
558
+ </tr>
559
+
560
+ <tr>
561
+ <td rowspan="1" colSpan="1" >推荐场景</td>
562
+
563
+ <td rowspan="1" colSpan="1" >礼物动画格式统一为 SVGA,且文件大小可控</td>
564
+
565
+ <td rowspan="1" colSpan="1" >需要支持多种动画格式,或对动画性能/设备兼容性有更高要求</td>
566
+ </tr>
567
+ </table>
568
+
569
+
570
+ 本章节主要演示基础方案的集成。如果您选择高级方案,请参考 [TCEffectPlayer 集成指引](https://cloud.tencent.com/document/product/616/116474)。
571
+
572
+ #### 基础方案实现:使用 SVGAPlayer
573
+ 1. **使用 SVGAPlayer**:在您的项目中,引入 `svga-player `组件
574
+
575
+ ``` typescript
576
+ <svga-player :url="xxx"></svga-player>
577
+ ```
578
+ 2. **监听礼物事件**:使用 `addGiftListener` 以订阅 `'onReceiveGift'`事件。
579
+
580
+ 3. **解析并播放**:当收到 `'onReceiveGift'`事件时,检查 `gift.resourceURL`是否有效且指向一个 SVGA 文件。如果是,则将`gift.resourceURL`传给`svga-player` 进行播放
581
+
582
+
583
+ #### 代码示例
584
+ ``` typescript
585
+ <template>
586
+ <svga-player :url="giftUrl"></svga-player>
587
+ </template>
588
+
589
+ <script setup lang="ts">
590
+ import { useGiftState } from "@/uni_modules/tuikit-atomic-x/state/GiftState";
591
+ import { onMounted } from 'vue';
592
+
593
+ // 通过 liveID 获取 GiftState 的实例
594
+ const { addGiftListener } = useGiftState(liveID);
595
+ const giftUrl = ref('')
596
+
597
+ onMounted(() => {
598
+ addGiftListener(liveID, 'onReceiveGift', {
599
+ callback: (event) => {
600
+ const gift = JSON.parse(event)
601
+ if( gift.resourceURL ) {
602
+ giftUrl.value = gift.resourceURL
603
+ }
604
+ }
605
+ })
606
+ })
607
+ </script>
608
+
609
+ ```
610
+
611
+ ### 在弹幕区展示礼物赠送消息
612
+
613
+ 当有用户发送礼物时,不仅播放动画,同时在公屏弹幕区域显示一条系统消息,例如:“【观众昵称】送出了【礼物名称】x【数量】”,让所有观众都能看到。
614
+
615
+ #### 实现方式
616
+ 1. **监听事件: **使用 `addGiftListener` 以订阅 `'onReceiveGift'`事件。
617
+
618
+ 2. **获取弹幕 State**:使用 `useBarrageState(liveID)`获取与当前房间绑定的实例。
619
+
620
+ 3. **拼接消息**:创建一条消息结构体,设置 `messageType = 'text'`,textContent 为拼接好的字符串(例如 “[`sender.userName`] 送出了 [`gift.name`] x [`count`]”)。
621
+
622
+ 4. **本地插入**:调用 `barrageState`的`appendLocalTip(message: giftTip) `将消息插入本地列表。
623
+
624
+
625
+ #### 代码示例
626
+ ``` typescript
627
+ import { useGiftState } from "@/uni_modules/tuikit-atomic-x/state/GiftState";
628
+ import { useBarrageState } from "@/uni_modules/tuikit-atomic-x/state/BarrageState";
629
+ import { onMounted } from 'vue';
630
+
631
+ // 通过 liveID 获取 GiftState 的实例
632
+ const { addGiftListener } = useGiftState(liveID);
633
+ // 通过 liveID 获取 BarrageState 的实例
634
+ const { appendLocalTip } = useBarrageState(liveID);
635
+
636
+ onMounted(() => {
637
+ addGiftListener(liveID, 'onReceiveGift', {
638
+ callback: (event) => {
639
+ const gift = JSON.parse(event)
640
+ let giftTip = {}
641
+ const tipText = "${ gift.sender.userName } 送出了 ${gift.name} x ${gift.count}"
642
+ giftTip.messageType = 'text'
643
+ giftTip.textContent = tipText
644
+ appendLocalTip({
645
+ liveID: 'xxx', // 当前直播间 liveID
646
+ message: giftTip
647
+ })
648
+ if( gift.resourceURL ) {
649
+ giftUrl.value = gift.resourceURL
650
+ }
651
+ }
652
+ })
653
+ })
654
+ </script>
655
+ ```
656
+
657
+ ## API 文档
658
+
659
+ 关于 [GiftState](https://liteav.sdk.qcloud.com/doc/product/tuikit/atomic-x/uni-app/zh/v1.0/api/index.html#module-GiftState) 及其相关类的所有公开接口、属性和方法的详细信息,请参阅随 [AtomicXCore](https://write.woa.com/document/192223419814899712) 框架的官方 API 文档。本指南使用到的相关 Store 如下:
660
+ <table>
661
+ <tr>
662
+ <td rowspan="1" colSpan="1" >**State**</td>
663
+
664
+ <td rowspan="1" colSpan="1" >**功能描述**</td>
665
+
666
+ <td rowspan="1" colSpan="1" >**API 文档**</td>
667
+ </tr>
668
+
669
+ <tr>
670
+ <td rowspan="1" colSpan="1" >GiftState</td>
671
+
672
+ <td rowspan="1" colSpan="1" >礼物互动:获取礼物列表,发送 / 接收礼物,监听礼物事件(含发送者、礼物详情)。</td>
673
+
674
+ <td rowspan="1" colSpan="1" >[API 文档](https://liteav.sdk.qcloud.com/doc/product/tuikit/atomic-x/uni-app/zh/v1.0/api/index.html#module-GiftState)</td>
675
+ </tr>
676
+
677
+ <tr>
678
+ <td rowspan="1" colSpan="1" >BarrageState</td>
679
+
680
+ <td rowspan="1" colSpan="1" >弹幕功能:发送文本 / 自定义弹幕,维护弹幕列表,实时监听弹幕状态。</td>
681
+
682
+ <td rowspan="1" colSpan="1" >[API 文档](https://liteav.sdk.qcloud.com/doc/product/tuikit/atomic-x/uni-app/zh/v1.0/api/index.html#module-BarrageState)</td>
683
+ </tr>
684
+ </table>
685
+
686
+
687
+ ## 常见问题
688
+
689
+ ### `GiftState` 的礼物列表是空的,我该怎么办?
690
+
691
+ 您必须主动调用 `refreshUsableGifts()`来从您的业务后台拉取礼物数据。这些礼物数据需要在您的业务后台通过服务端 REST API 进行配置。
692
+
693
+ ### 如何实现礼物的多语言展示(例如中文、英文)?
694
+
695
+ `GiftState` 提供了 `setLanguage(language: string)`接口。您可以在 `refreshUsableGifts` 之前调用此方法,传入目标语言代码(例如 "en" 或 "zh-CN")。服务端会根据此语言代码,返回对应语言的礼物名称和描述。
696
+
697
+ ### 我调用 sendGift 发送了礼物,礼物动画为什么重复播放了两次?
698
+
699
+ `onReceiveGift` 事件是对房间内所有成员的广播(包括发送者自己)。如果您在 `sendGift` 的 `success` 成功回调里执行了一次UI操作,同时又在 `onReceiveGift` 订阅中执行了相同的 UI 操作,就会造成重复。
700
+ - **实践教程**:UI 的更新(例如播放动画、弹幕提示)只在 `onReceiveGift` 事件的订阅中处理。`sendGift` 的 `success` 回调仅用于处理发送失败的逻辑(例如提示用户“发送失败”或“余额不足”)。
701
+
702
+
703
+ ### 礼物扣费逻辑在哪里实现?
704
+
705
+ 礼物扣费逻辑完全由您的自建计费系统负责。`AtomicXCore` 通过后台回调机制与您的计费系统对接。客户端调用 `sendGift` 触发回调,您的后台服务完成扣费后,将结果返回给 `AtomicXCore` 后台,从而决定礼物事件是否广播。
706
+
707
+ ### 送礼通知会被禁言或频控拦截吗?
708
+
709
+ 不会。送礼通知(`'onReceiveGift'`事件)不受禁言或消息频控影响,确保可靠投递。
710
+
711
+ ### 礼物动画播放卡顿怎么办?
712
+
713
+ 请检查您的 `SVGA` 文件大小,基础播放器建议不要超过 10MB。如果文件过大或动画复杂,您可以考虑集成 `TUILiveKit` 提供的高级特效播放器,以获得更优的性能表现。
714
+
715
+
716
+