atomicx-core sdk API 文档
atomicx-core sdk
atomicx-core sdk 是腾讯云最新推出的面向即时通信、音视频通话、视频直播、语聊房等场景的全新一代基于响应式的 API,您可以非常快速的在基于这组 API 构建自己的 UI 页面,它支持房间管理、屏幕分享、成员管理、麦位控制、基础美颜等丰富功能,同时确保720P和1080P高清画质,在70%丢包率的弱网环境下仍能保持高质量音视频传输。此外,SDK 采用48kHz高音质采样,结合腾讯天籁实验室的3A处理算法,消除回声和啸叫,实现全链路128kbps高音质立体声,为用户带来清晰沉浸的互动体验,本页面包含 atomicx-core sdk 的所有API接口,按功能模块分类展示。
State 模块列表
🔐 基础模块
- LoginState - 用户身份认证与登录管理
- DeviceState - 设备状态管理(摄像头、麦克风、扬声器)
🏠 房间模块
- RoomState - 房间状态管理(创建、加入、预约等)
- RoomParticipantState - 房间参与者管理(成员列表、权限控制)
📺 直播模块
- LiveListState - 直播列表与直播间管理
- LiveSeatState - 直播麦位管理
- LiveAudienceState - 直播观众管理
- LiveMonitorState - 直播监控管理
🎤 连麦与互动
- CoGuestState - 观众连麦管理
- CoHostState - 主播连麦管理
- BattleState - 主播 PK 对战管理
- BarrageState - 弹幕消息管理
💬 即时通信模块
- MessageListState - 消息列表管理
- MessageInputState - 消息输入管理
- MessageActionState - 消息操作管理
- ConversationListState - 会话列表管理
- ContactListState - 联系人列表管理
- SearchState - 搜索功能管理
⚙️ 设置模块
- C2CSettingState - 单聊设置管理
- GroupSettingState - 群聊设置管理
🎨 高级功能
- VideoMixerState - 视频混流管理
- VirtualBackgroundState - 虚拟背景管理
- ASRState - 语音识别(ASR)管理
- SeatStore - 麦位存储管理
- FreeBeautyState - 免费美颜功能管理
Event 事件列表
📡 Asr
- Asr - asr 模块事件定义(4 个事件)
📡 Participant
- Participant - participant 模块事件定义(24 个事件)
📡 Room
- Room - room 模块事件定义(12 个事件)
📡 VirtualBackground
- VirtualBackground - virtualBackground 模块事件定义(1 个事件)
Type 类型列表
📋 Asr
- Asr - asr 模块类型定义(2 个类型)
📋 Beauty
- Beauty - beauty 模块类型定义(2 个类型)
📋 Participant
- Participant - participant 模块类型定义(8 个类型)
📋 Room
- Room - room 模块类型定义(11 个类型)
📋 VirtualBackground
- VirtualBackground - virtualBackground 模块类型定义(2 个类型)
Component 组件列表
🧩 ASRTools
- ASRTools - 语音识别工具组件 * 用于在视频会议中显示实时字幕和转录消息列表的语音识别组件。
🧩 AudioSettingPanel
- AudioSettingPanel - 音频设置面板组件 * 用于展示音频设置面板,支持自定义视图展示。
🧩 Avatar
- Avatar - 头像组件 * 用于展示用户或群组头像,支持图片、文字、在线状态和未读消息徽章等功能。
🧩 FreeBeautyPanel
- FreeBeautyPanel - 美颜设置面板组件,用于配置视频通话中的美颜效果,支持磨皮、美白、红润等美颜功能。
🧩 RoomParticipantList
- RoomParticipantList - 房间参与者列表组件 * 用于展示房间参与者列表,支持分页获取参与者列表,支持搜索参与者,支持呼叫参与者,支持踢出参与者,支持设置参与者为管理员,支持设置参与者为房主等功能。
🧩 RoomParticipantView
- RoomParticipantView - 房间参与者视图组件 * 用于展示房间参与者视频流及屏幕共享流,支持自定义视图展示。 * * @props
🧩 RoomView
- RoomView - 房间视图组件 * 用于展示房间参与者视频流及屏幕共享流,支持自定义视图展示,支持自定义布局模板。
🧩 ScheduleRoomPanel
- ScheduleRoomPanel - 预约房间管理组件,用于创建和管理预约房间,支持房间预约、参与者管理、安全设置等功能。
🧩 VideoSettingPanel
- VideoSettingPanel - 视频设置面板组件 * 用于展示视频设置面板,支持自定义视图展示。
🧩 VirtualBackgroundPanel
- VirtualBackgroundPanel - 虚拟背景设置面板组件 * 用于配置视频通话中的虚拟背景效果,支持背景模糊和自定义背景图片。
Interface 接口列表
📝 接口定义
- Interface - 接口类型定义
LiveListState
响应式数据
currentLive
Ref<LiveInfo | null>
示例
const tuiLiveInfo = await roomEngine.getLiveInfo();
const liveInfo = getLiveInfo(tuiLiveInfo);
console.log('转换后的直播信息:', liveInfo);
liveList
Ref<any>
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { liveList } = useLiveListState();
// 监听数据变化
watch(liveList, (newValue) => {
console.log('liveList 更新:', newValue);
});
// 直接访问数据
console.log('当前 liveList:', liveList.value);
liveListCursor
Ref<any>
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { liveListCursor } = useLiveListState();
// 监听数据变化
watch(liveListCursor, (newValue) => {
console.log('liveListCursor 更新:', newValue);
});
// 直接访问数据
console.log('当前 liveListCursor:', liveListCursor.value);
接口函数
createLive
参数 (CreateLiveParams)
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 直播间ID |
| liveName | string |
是 | 直播间名称 |
| notice | string |
否 | 直播间公告 |
| isMessageDisableForAllUser | boolean |
否 | 是否禁止所有用户发送消息 |
| isGiftEnabled | boolean |
否 | 是否启用礼物功能 |
| isLikeEnabled | boolean |
否 | 是否启用点赞功能 |
| isPublicVisible | boolean |
否 | 是否公开可见 |
| isSeatEnabled | boolean |
否 | 是否启用麦位功能 |
| keepOwnerOnSeat | boolean |
否 | 是否保持房主在麦位上 |
| seatLayoutTemplateId | number |
否 | 麦位布局模板ID |
| maxSeatCount | number |
否 | 最大麦位数量 |
| seatMode | TUISeatMode |
否 | 麦位模式 |
| coverUrl | string |
否 | 直播间封面URL |
| backgroundUrl | string |
否 | 直播间背景URL |
| categoryList | Array<number> |
否 | 分类列表 |
| activityStatus | number |
否 | 活动状态 |
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { createLive } = useLiveListState();
// 创建带有自定义设置的直播间
await createLive({
liveId: 'live_room_123456',
liveName: 'My Live Room',
coverUrl: 'https://example.com/cover.jpg',
backgroundUrl: 'https://example.com/bg.jpg',
isSeatEnabled: true,
maxSeatCount: 8,
isPublicVisible: true,
isGiftEnabled: true
});
joinLive
参数 (JoinLiveParams)
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 直播间ID |
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { joinLive } = useLiveListState();
// 通过ID加入直播间
await joinLive({
liveId: 'live_room_123456'
});
leaveLive
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { leaveLive } = useLiveListState();
// 离开直播间
try {
await leaveLive();
console.log('成功离开直播间');
} catch (error) {
console.error('离开直播间失败:', error);
}
endLive
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { endLive } = useLiveListState();
// 结束直播(主播操作)
try {
await endLive();
console.log('直播已结束');
} catch (error) {
console.error('结束直播失败:', error);
}
updateLiveInfo
参数 (UpdateLiveInfoParams)
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
否 | 直播间ID |
| activityStatus | number |
否 | 活动状态 |
| categoryList | Array<number> |
否 | 分类列表 |
| coverUrl | string |
否 | 直播间封面URL |
| backgroundUrl | string |
否 | 直播间背景URL |
| isPublicVisible | boolean |
否 | 是否公开可见 |
| layoutTemplate | number |
否 | 布局模板 |
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { updateLiveInfo } = useLiveListState();
// 更新直播间信息
await updateLiveInfo({
coverUrl: 'https://example.com/new-cover.jpg',
backgroundUrl: 'https://example.com/new-bg.jpg',
categoryList: [1, 2],
isPublicVisible: true,
activityStatus: 1
});
queryMetaData
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| keys | string[] |
是 | 要查询的元数据键名列表 |
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { queryMetaData } = useLiveListState();
// 通过键查询元数据
await queryMetaData({
keys: ['roomTitle', 'announcement', 'customData']
});
updateLiveMetaData
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| metaData | Record<string, string> |
是 | 要更新的元数据键值对 |
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { updateLiveMetaData } = useLiveListState();
// 更新直播间元数据
await updateLiveMetaData({
metaData: {
roomTitle: 'New Room Title',
announcement: 'Welcome to my live room!'
}
});
fetchLiveList
参数
| 参数名 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| category | string |
否 | - | 直播间分类 |
| cursor | string |
否 | '' | 分页游标,首次获取传空字符串 |
| count | number |
否 | 20 | 每次获取的数量 |
示例
import { useLiveListState } from 'tuikit-atomicx-vue3';
const { fetchLiveList, liveListCursor } = useLiveListState();
// 首次获取 - 获取初始列表
await fetchLiveList({
cursor: '',
count: 20
});
// 加载更多 - 使用游标进行分页
await fetchLiveList({
cursor: liveListCursor.value,
count: 20
});
LiveSeatState
响应式数据
seatList
Ref<any>
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { seatList } = useLiveSeatState();
// 监听数据变化
watch(seatList, (newValue) => {
console.log('seatList 更新:', newValue);
});
// 直接访问数据
console.log('当前 seatList:', seatList.value);
canvas
Ref<any>
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { canvas } = useLiveSeatState();
// 监听数据变化
watch(canvas, (newValue) => {
console.log('canvas 更新:', newValue);
});
// 直接访问数据
console.log('当前 canvas:', canvas.value);
speakingUsers
Ref<any>
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { speakingUsers } = useLiveSeatState();
// 监听数据变化
watch(speakingUsers, (newValue) => {
console.log('speakingUsers 更新:', newValue);
});
// 直接访问数据
console.log('当前 speakingUsers:', speakingUsers.value);
networkQualities
Ref<any>
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { networkQualities } = useLiveSeatState();
// 监听数据变化
watch(networkQualities, (newValue) => {
console.log('networkQualities 更新:', newValue);
});
// 直接访问数据
console.log('当前 networkQualities:', networkQualities.value);
接口函数
takeSeat
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| seatIndex | number |
是 | 麦位索引 |
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { takeSeat } = useLiveSeatState();
// 上第1个麦位
await takeSeat({
seatIndex: 1
});
leaveSeat
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| seatIndex | number |
是 | 麦位索引 |
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { leaveSeat } = useLiveSeatState();
// 离开第1个麦位
await leaveSeat({
seatIndex: 1
});
lockSeat
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| seatIndex | number |
是 | 麦位索引 |
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { lockSeat } = useLiveSeatState();
// 锁定第2个麦位
await lockSeat({
seatIndex: 2
});
unLockSeat
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| seatIndex | number |
是 | 麦位索引 |
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { unLockSeat } = useLiveSeatState();
// 解锁第2个麦位
await unLockSeat({
seatIndex: 2
});
kickUserOutOfSeat
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| seatIndex | number |
是 | 麦位索引 |
| userId | string |
是 | 用户ID |
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { kickUserOutOfSeat } = useLiveSeatState();
// 将用户踢下麦位
await kickUserOutOfSeat({
seatIndex: 1,
userId: 'user_123'
});
moveUserToSeat
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 要移动的用户ID |
| targetIndex | number |
是 | 目标麦位索引 |
| policy | MoveSeatPolicy |
是 | 移动策略:AbortWhenOccupied(0) - 目标麦位被占用时中止;ForceReplace(1) - 强制替换目标麦位用户;SwapPosition(2) - 与目标麦位用户交换位置 |
示例
import { useLiveSeatState, MoveSeatPolicy } from 'tuikit-atomicx-vue3';
const { moveUserToSeat } = useLiveSeatState();
// 将用户移动到目标麦位(强制替换策略)
await moveUserToSeat({
userId: 'user_123',
targetIndex: 3,
policy: MoveSeatPolicy.ForceReplace
});
openRemoteCamera
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 要开启摄像头的用户ID |
| policy | DeviceControlPolicy |
是 | 设备控制策略:UnlockOnly(1) - 仅解锁设备 |
示例
import { useLiveSeatState, DeviceControlPolicy } from 'tuikit-atomicx-vue3';
const { openRemoteCamera } = useLiveSeatState();
// 允许用户打开摄像头
try {
await openRemoteCamera({
userId: 'user123',
policy: DeviceControlPolicy.UnlockOnly
});
console.log('Camera unlocked');
} catch (error) {
console.error('Failed to unlock camera:', error);
}
closeRemoteCamera
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 要关闭摄像头的用户ID |
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { closeRemoteCamera } = useLiveSeatState();
// 关闭远端用户的摄像头
try {
await closeRemoteCamera({ userId: 'user123' });
console.log('Camera closed');
} catch (error) {
console.error('Failed to close camera:', error);
}
openRemoteMicrophone
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 要开启麦克风的用户ID |
| policy | DeviceControlPolicy |
是 | 设备控制策略:UnlockOnly(1) - 仅解锁设备 |
示例
import { useLiveSeatState, DeviceControlPolicy } from 'tuikit-atomicx-vue3';
const { openRemoteMicrophone } = useLiveSeatState();
// 允许用户打开麦克风
try {
await openRemoteMicrophone({
userId: 'user123',
policy: DeviceControlPolicy.UnlockOnly
});
console.log('Microphone unlocked');
} catch (error) {
console.error('Failed to unlock microphone:', error);
}
closeRemoteMicrophone
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 要关闭麦克风的用户ID |
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { closeRemoteMicrophone } = useLiveSeatState();
// 关闭远端用户的麦克风
try {
await closeRemoteMicrophone({ userId: 'user123' });
console.log('Microphone closed');
} catch (error) {
console.error('Failed to close microphone:', error);
}
muteMicrophone
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { muteMicrophone } = useLiveSeatState();
// 静音本地麦克风
await muteMicrophone();
console.log('Microphone muted');
unmuteMicrophone
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { unmuteMicrophone } = useLiveSeatState();
// 取消静音本地麦克风
await unmuteMicrophone();
console.log('Microphone unmuted');
startPlayStream
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| view | string |
是 | 视频容器元素ID |
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { startPlayStream } = useLiveSeatState();
// 开始在指定容器中播放流
try {
await startPlayStream({ view: 'video-container' });
console.log('Stream playing');
} catch (error) {
console.error('Failed to play stream:', error);
}
stopPlayStream
示例
import { useLiveSeatState } from 'tuikit-atomicx-vue3';
const { stopPlayStream } = useLiveSeatState();
// 停止播放流
try {
await stopPlayStream();
console.log('Stream stopped');
} catch (error) {
console.error('Failed to stop stream:', error);
}
LiveMonitorState
响应式数据
monitorLiveInfoList
Ref<any>
示例
import { useLiveMonitorState } from 'tuikit-atomicx-vue3';
const { monitorLiveInfoList } = useLiveMonitorState();
// 监听数据变化
watch(monitorLiveInfoList, (newValue) => {
console.log('monitorLiveInfoList 更新:', newValue);
});
// 直接访问数据
console.log('当前 monitorLiveInfoList:', monitorLiveInfoList.value);
接口函数
init
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| config | InitConfig |
是 | 初始化配置对象 |
| baseUrl | string |
是 | API服务器基础URL |
| account | Account |
是 | 账户信息,包含 userId 和 userSig |
示例
import { useLiveMonitorState } from 'tuikit-atomicx-vue3';
const { init } = useLiveMonitorState();
// 初始化监控模块
init({
baseUrl: 'https://api.example.com',
account: {
userId: 'user123',
userSig: 'signature'
}
});
getLiveList
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| page | number |
是 | 页码,从1开始 |
| pageSize | number |
是 | 每页数量 |
示例
import { useLiveMonitorState } from 'tuikit-atomicx-vue3';
const { getLiveList } = useLiveMonitorState();
// 获取第一页直播列表
try {
const liveList = await getLiveList(1, 20);
console.log('直播列表:', liveList);
} catch (error) {
console.error('获取直播列表失败:', error);
}
// 获取更多页
const moreLives = await getLiveList(2, 20);
closeRoom
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 要关闭的直播间ID |
示例
import { useLiveMonitorState } from 'tuikit-atomicx-vue3';
const { closeRoom } = useLiveMonitorState();
// 关闭违规直播间
try {
await closeRoom('live_123');
console.log('直播间已关闭');
} catch (error) {
console.error('关闭直播间失败:', error);
}
sendMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 直播间ID |
| message | MonitorMessage |
是 | 要发送的消息 |
示例
import { useLiveMonitorState } from 'tuikit-atomicx-vue3';
const { sendMessage } = useLiveMonitorState();
// 发送警告消息(暂不支持)
sendMessage('live_123', {
type: 'warning',
content: '请遵守直播规范'
});
startPlay
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 直播间ID |
| viewId | string |
是 | 视频容器元素ID |
示例
import { useLiveMonitorState } from 'tuikit-atomicx-vue3';
const { startPlay } = useLiveMonitorState();
// 开始播放直播流
try {
await startPlay('live_123', 'video-container');
console.log('已开始播放直播');
} catch (error) {
console.error('播放失败:', error);
}
stopPlay
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 直播间ID |
示例
import { useLiveMonitorState } from 'tuikit-atomicx-vue3';
const { stopPlay } = useLiveMonitorState();
// 停止播放直播流
try {
await stopPlay('live_123');
console.log('已停止播放');
} catch (error) {
console.error('停止播放失败:', error);
}
muteLiveAudio
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 直播间ID |
| mute | boolean |
是 | 是否静音,true为静音,false为取消静音 |
示例
import { useLiveMonitorState } from 'tuikit-atomicx-vue3';
const { muteLiveAudio } = useLiveMonitorState();
// 静音直播音频
await muteLiveAudio('live_123', true);
// 取消静音直播音频
await muteLiveAudio('live_123', false);
MessageInputState
响应式数据
inputRawValue
Ref<any>
示例
import { useMessageInputState } from 'tuikit-atomicx-vue3';
const { inputRawValue } = useMessageInputState();
// 监听数据变化
watch(inputRawValue, (newValue) => {
console.log('inputRawValue 更新:', newValue);
});
// 直接访问数据
console.log('当前 inputRawValue:', inputRawValue.value);
isPeerTyping
Ref<any>
示例
import { useMessageInputState } from 'tuikit-atomicx-vue3';
const { isPeerTyping } = useMessageInputState();
// 监听数据变化
watch(isPeerTyping, (newValue) => {
console.log('isPeerTyping 更新:', newValue);
});
// 直接访问数据
console.log('当前 isPeerTyping:', isPeerTyping.value);
接口函数
updateRawValue
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| value | string | InputContent[] | 是 | 要设置的值,可以是字符串或结构化内容数组 |
示例
import { useMessageInputState, MessageContentType } from 'tuikit-atomicx-vue3';
const { updateRawValue } = useMessageInputState();
// 更新文本内容
updateRawValue('Hello World');
// 更新结构化内容
updateRawValue([
{ type: MessageContentType.TEXT, content: 'Hello ' },
{ type: MessageContentType.EMOJI, content: { key: '[smile]', text: '😊' } }
]);
setEditorInstance
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| instance | Editor | null | 是 | 编辑器实例,传入 null 表示清除当前实例 |
示例
import { useMessageInputState } from 'tuikit-atomicx-vue3';
const { setEditorInstance } = useMessageInputState();
// 设置编辑器实例
setEditorInstance(editorInstance);
// 清除编辑器实例
setEditorInstance(null);
setContent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| content | string | InputContent[] | 是 | 要设置的内容 |
示例
import { useMessageInputState, MessageContentType } from 'tuikit-atomicx-vue3';
const { setContent } = useMessageInputState();
// 设置文本内容
setContent('Hello World');
// 设置结构化内容
setContent([
{ type: MessageContentType.TEXT, content: 'Hello ' },
{ type: MessageContentType.EMOJI, content: { key: '[smile]', text: '😊' } }
]);
insertContent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| content | string | InputContent[] | 是 | 要插入的内容 |
| focus | boolean | 否 | 插入后是否聚焦编辑器,默认为 true |
示例
import { useMessageInputState, MessageContentType } from 'tuikit-atomicx-vue3';
const { insertContent } = useMessageInputState();
// 插入文本内容
insertContent('Hello World');
// 插入表情
insertContent([
{ type: MessageContentType.EMOJI, content: { key: '[smile]', text: '😊' } }
]);
// 插入内容但不聚焦
insertContent('Hello', false);
focusEditor
示例
import { useMessageInputState } from 'tuikit-atomicx-vue3';
const { focusEditor } = useMessageInputState();
// 聚焦编辑器
focusEditor();
blurEditor
示例
import { useMessageInputState } from 'tuikit-atomicx-vue3';
const { blurEditor } = useMessageInputState();
// 失焦编辑器
blurEditor();
sendMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| msg | string | InputContent[] | 否 | 要发送的消息内容,如果不提供则使用当前输入框的值 |
示例
import { useMessageInputState, MessageContentType } from 'tuikit-atomicx-vue3';
const { sendMessage } = useMessageInputState();
// 发送文本消息
await sendMessage('Hello World');
// 发送结构化消息
await sendMessage([
{ type: MessageContentType.TEXT, content: 'Check this image: ' },
{ type: MessageContentType.IMAGE, content: imageFile }
]);
// 发送当前输入框内容
await sendMessage();
MessageActionState
响应式数据
forwardMessageIDList
Ref<any>
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { forwardMessageIDList } = useMessageActionState();
// 监听数据变化
watch(forwardMessageIDList, (newValue) => {
console.log('forwardMessageIDList 更新:', newValue);
});
// 直接访问数据
console.log('当前 forwardMessageIDList:', forwardMessageIDList.value);
isForwardMessageSelectionDone
Ref<any>
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { isForwardMessageSelectionDone } = useMessageActionState();
// 监听数据变化
watch(isForwardMessageSelectionDone, (newValue) => {
console.log('isForwardMessageSelectionDone 更新:', newValue);
});
// 直接访问数据
console.log('当前 isForwardMessageSelectionDone:', isForwardMessageSelectionDone.value);
forwardConversationIDList
Ref<any>
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { forwardConversationIDList } = useMessageActionState();
// 监听数据变化
watch(forwardConversationIDList, (newValue) => {
console.log('forwardConversationIDList 更新:', newValue);
});
// 直接访问数据
console.log('当前 forwardConversationIDList:', forwardConversationIDList.value);
quotedMessage
Ref<any>
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { quotedMessage } = useMessageActionState();
// 监听数据变化
watch(quotedMessage, (newValue) => {
console.log('quotedMessage 更新:', newValue);
});
// 直接访问数据
console.log('当前 quotedMessage:', quotedMessage.value);
接口函数
forwardMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| isMergeForward | boolean | 是 | 是否合并转发 |
| messageIDList | string[] | 是 | 要转发的消息ID列表 |
| conversationIDList | string[] | 是 | 目标会话ID列表 |
| useOfflinePush | boolean | 否 | 是否使用离线推送 |
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { forwardMessage } = useMessageActionState();
// 合并转发消息
const results = await forwardMessage({
isMergeForward: true,
messageIDList: ['msg_001', 'msg_002'],
conversationIDList: ['C2C_user123', 'GROUP_group456']
});
// 逐条转发消息
await forwardMessage({
isMergeForward: false,
messageIDList: ['msg_001'],
conversationIDList: ['C2C_user123']
});
setForwardMessageIDList
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| messageIDList | string[] | 是 | 要转发的消息ID列表 |
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { setForwardMessageIDList } = useMessageActionState();
// 设置转发消息ID列表
setForwardMessageIDList(['msg_001', 'msg_002', 'msg_003']);
setIsForwardMessageSelectionDone
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| isSelectionDone | boolean | 是 | 是否完成消息选择 |
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { setIsForwardMessageSelectionDone } = useMessageActionState();
// 标记消息选择完成
setIsForwardMessageSelectionDone(true);
// 重置消息选择状态
setIsForwardMessageSelectionDone(false);
setForwardConversationIDList
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| conversationIDList | string[] | 是 | 目标会话ID列表 |
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { setForwardConversationIDList } = useMessageActionState();
// 设置转发目标会话
setForwardConversationIDList(['C2C_user123', 'GROUP_group456']);
quoteMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| message | MessageModel | undefined | 是 | 要引用的消息对象,传入 undefined 取消引用 |
示例
import { useMessageActionState, useMessageListState } from 'tuikit-atomicx-vue3';
const { quoteMessage } = useMessageActionState();
const { messageList } = useMessageListState();
// 引用消息
const messageToQuote = messageList.value[0];
quoteMessage(messageToQuote);
// 取消引用
quoteMessage(undefined);
clearQuotedMessage
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { clearQuotedMessage } = useMessageActionState();
// 清除引用消息
clearQuotedMessage();
copyTextMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| message | MessageModel | 是 | 要复制的消息对象 |
示例
import { useMessageActionState, useMessageListState } from 'tuikit-atomicx-vue3';
const { copyTextMessage } = useMessageActionState();
const { messageList } = useMessageListState();
// 复制消息文本
const message = messageList.value[0];
const success = await copyTextMessage(message);
if (success) {
console.log('复制成功');
}
deleteMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| message | MessageModel | 是 | 要删除的消息对象 |
示例
import { useMessageActionState, useMessageListState } from 'tuikit-atomicx-vue3';
const { deleteMessage } = useMessageActionState();
const { messageList } = useMessageListState();
// 删除消息
const message = messageList.value[0];
try {
await deleteMessage(message);
console.log('消息删除成功');
} catch (error) {
console.error('删除失败:', error);
}
recallMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| message | MessageModel | 是 | 要撤回的消息对象 |
示例
import { useMessageActionState, useMessageListState } from 'tuikit-atomicx-vue3';
const { recallMessage } = useMessageActionState();
const { messageList } = useMessageListState();
// 撤回消息
const message = messageList.value[0];
try {
await recallMessage(message);
console.log('消息撤回成功');
} catch (error) {
console.error('撤回失败(可能超过时间限制):', error);
}
resetMessageActionState
示例
import { useMessageActionState } from 'tuikit-atomicx-vue3';
const { resetMessageActionState } = useMessageActionState();
// 重置所有消息操作状态
resetMessageActionState();
ConversationListState
响应式数据
conversationList
Ref<any>
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { conversationList } = useConversationListState();
// 监听数据变化
watch(conversationList, (newValue) => {
console.log('conversationList 更新:', newValue);
});
// 直接访问数据
console.log('当前 conversationList:', conversationList.value);
activeConversation
Ref<any>
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { activeConversation } = useConversationListState();
// 监听数据变化
watch(activeConversation, (newValue) => {
console.log('activeConversation 更新:', newValue);
});
// 直接访问数据
console.log('当前 activeConversation:', activeConversation.value);
totalUnRead
Ref<any>
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { totalUnRead } = useConversationListState();
// 监听数据变化
watch(totalUnRead, (newValue) => {
console.log('totalUnRead 更新:', newValue);
});
// 直接访问数据
console.log('当前 totalUnRead:', totalUnRead.value);
netStatus
Ref<any>
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { netStatus } = useConversationListState();
// 监听数据变化
watch(netStatus, (newValue) => {
console.log('netStatus 更新:', newValue);
});
// 直接访问数据
console.log('当前 netStatus:', netStatus.value);
接口函数
markConversationUnread
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| conversationID | string | 是 | 会话ID |
| isUnread | boolean | 是 | 是否标记为未读 |
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { markConversationUnread } = useConversationListState();
// 标记会话为未读
await markConversationUnread('C2Cuser123', true);
// 标记会话为已读
await markConversationUnread('C2Cuser123', false);
setActiveConversation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| conversationID | string | 是 | 要设置为活跃的会话ID |
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { setActiveConversation } = useConversationListState();
// 切换到指定会话
await setActiveConversation('C2Cuser123');
pinConversation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| conversationID | string | 是 | 会话ID |
| isPin | boolean | 是 | 是否置顶 |
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { pinConversation } = useConversationListState();
// 置顶会话
await pinConversation('C2Cuser123', true);
// 取消置顶
await pinConversation('C2Cuser123', false);
deleteConversation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| conversationID | string | 是 | 要删除的会话ID |
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { deleteConversation } = useConversationListState();
// 删除会话
try {
await deleteConversation('C2Cuser123');
console.log('会话删除成功');
} catch (error) {
console.error('删除会话失败:', error);
}
muteConversation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| conversationID | string | 是 | 会话ID |
| isMuted | boolean | 是 | 是否开启免打扰 |
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { muteConversation } = useConversationListState();
// 开启免打扰
await muteConversation('C2Cuser123', true);
// 关闭免打扰
await muteConversation('C2Cuser123', false);
setConversationDraft
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| conversationID | string | 是 | 会话ID |
| draftText | string | 是 | 草稿内容 |
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { setConversationDraft } = useConversationListState();
// 设置会话草稿
await setConversationDraft({
conversationID: 'C2Cuser123',
draftText: '这是一条草稿消息'
});
createC2CConversation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userID | string | 是 | 目标用户ID |
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
const { createC2CConversation } = useConversationListState();
// 创建与用户的单聊会话
try {
const conversation = await createC2CConversation('user123');
console.log('单聊会话创建成功:', conversation);
} catch (error) {
console.error('创建单聊会话失败:', error);
}
createGroupConversation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID(可选) |
| name | string | 是 | 群组名称 |
| type | string | 是 | 群组类型 |
| memberList | string[] | 否 | 初始成员列表 |
示例
import { useConversationListState } from 'tuikit-atomicx-vue3';
import TUIChatEngine from '@tencentcloud/chat-uikit-engine-lite';
const { createGroupConversation } = useConversationListState();
// 创建群聊会话
try {
const conversation = await createGroupConversation({
name: '我的群聊',
type: TUIChatEngine.TYPES.GRP_WORK,
memberList: ['user1', 'user2']
});
console.log('群聊会话创建成功:', conversation);
} catch (error) {
console.error('创建群聊会话失败:', error);
}
ContactListState
响应式数据
friendList
Ref<any>
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { friendList } = useContactListState();
// 监听数据变化
watch(friendList, (newValue) => {
console.log('friendList 更新:', newValue);
});
// 直接访问数据
console.log('当前 friendList:', friendList.value);
groupList
Ref<any>
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { groupList } = useContactListState();
// 监听数据变化
watch(groupList, (newValue) => {
console.log('groupList 更新:', newValue);
});
// 直接访问数据
console.log('当前 groupList:', groupList.value);
blackList
Ref<any>
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { blackList } = useContactListState();
// 监听数据变化
watch(blackList, (newValue) => {
console.log('blackList 更新:', newValue);
});
// 直接访问数据
console.log('当前 blackList:', blackList.value);
friendApplicationUnreadCount
Ref<any>
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { friendApplicationUnreadCount } = useContactListState();
// 监听数据变化
watch(friendApplicationUnreadCount, (newValue) => {
console.log('friendApplicationUnreadCount 更新:', newValue);
});
// 直接访问数据
console.log('当前 friendApplicationUnreadCount:', friendApplicationUnreadCount.value);
friendGroupList
Ref<any>
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { friendGroupList } = useContactListState();
// 监听数据变化
watch(friendGroupList, (newValue) => {
console.log('friendGroupList 更新:', newValue);
});
// 直接访问数据
console.log('当前 friendGroupList:', friendGroupList.value);
friendApplicationList
Ref<any>
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { friendApplicationList } = useContactListState();
// 监听数据变化
watch(friendApplicationList, (newValue) => {
console.log('friendApplicationList 更新:', newValue);
});
// 直接访问数据
console.log('当前 friendApplicationList:', friendApplicationList.value);
groupApplicationList
Ref<any>
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { groupApplicationList } = useContactListState();
// 监听数据变化
watch(groupApplicationList, (newValue) => {
console.log('groupApplicationList 更新:', newValue);
});
// 直接访问数据
console.log('当前 groupApplicationList:', groupApplicationList.value);
接口函数
setGroupApplicationList
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { setGroupApplicationList } = useContactListState();
// 设置群申请列表
await setGroupApplicationList({
applicationList: []
});
setFriendList
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { setFriendList } = useContactListState();
// 设置好友列表
await setFriendList({
friendList: []
});
setGroupList
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { setGroupList } = useContactListState();
// 设置群组列表
await setGroupList({
groupList: []
});
setBlackList
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { setBlackList } = useContactListState();
// 设置黑名单
await setBlackList({
blackList: []
});
setFriendApplicationUnreadCount
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { setFriendApplicationUnreadCount } = useContactListState();
// 设置好友申请未读数
await setFriendApplicationUnreadCount({
count: 5
});
setFriendGroupList
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { setFriendGroupList } = useContactListState();
// 设置好友分组列表
await setFriendGroupList({
groupList: []
});
setFriendApplicationList
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { setFriendApplicationList } = useContactListState();
// 设置好友申请列表
await setFriendApplicationList({
applicationList: []
});
initContactListWatcher
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { initContactListWatcher } = useContactListState();
// 初始化通讯录监听器
await initContactListWatcher({
autoUpdate: true
});
addFriend
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userID | string | 是 | 要添加的用户ID |
| addSource | string | 是 | 添加来源 |
| remark | string | 否 | 好友备注 |
| groupName | string | 否 | 好友分组名称 |
| wording | string | 否 | 申请理由 |
| type | number | 否 | 申请类型 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { addFriend } = useContactListState();
// 添加好友
try {
await addFriend({
userID: 'user123',
addSource: 'search',
remark: '同事小王',
groupName: '工作',
wording: '我是小李,想加您为好友'
});
console.log('好友申请发送成功');
} catch (error) {
console.error('添加好友失败:', error);
}
markFriendApplicationAsRead
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { markFriendApplicationAsRead } = useContactListState();
// 标记好友申请为已读
try {
await markFriendApplicationAsRead();
console.log('好友申请已标记为已读');
} catch (error) {
console.error('标记已读失败:', error);
}
acceptFriendApplication
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userID | string | 是 | 申请用户的ID |
| remark | string | 否 | 好友备注 |
| type | number | 是 | 申请类型 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { acceptFriendApplication } = useContactListState();
// 接受好友申请
try {
await acceptFriendApplication({
userID: 'user123',
remark: '新朋友',
type: 1
});
console.log('好友申请已接受');
} catch (error) {
console.error('接受申请失败:', error);
}
refuseFriendApplication
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userID | string | 是 | 申请用户的ID |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { refuseFriendApplication } = useContactListState();
// 拒绝好友申请
try {
await refuseFriendApplication('user123');
console.log('好友申请已拒绝');
} catch (error) {
console.error('拒绝申请失败:', error);
}
addToBlacklist
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userIDList | string[] | 是 | 要添加到黑名单的用户ID列表 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { addToBlacklist } = useContactListState();
// 添加用户到黑名单
try {
await addToBlacklist(['user123', 'user456']);
console.log('用户已添加到黑名单');
} catch (error) {
console.error('添加到黑名单失败:', error);
}
removeFromBlacklist
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userIDList | string[] | 是 | 要从黑名单移除的用户ID列表 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { removeFromBlacklist } = useContactListState();
// 从黑名单移除用户
try {
await removeFromBlacklist(['user123', 'user456']);
console.log('用户已从黑名单移除');
} catch (error) {
console.error('从黑名单移除失败:', error);
}
deleteFriend
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userID | string | 是 | 要删除的好友用户ID |
| type | string | 否 | 删除类型 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { deleteFriend } = useContactListState();
// 删除好友
try {
await deleteFriend({
userID: 'user123',
type: 'both'
});
console.log('好友删除成功');
} catch (error) {
console.error('删除好友失败:', error);
}
setFriendRemark
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userID | string | 是 | 好友用户ID |
| remark | string | 是 | 新的备注名称 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { setFriendRemark } = useContactListState();
// 设置好友备注
try {
await setFriendRemark({
userID: 'user123',
remark: '小王同事'
});
console.log('好友备注设置成功');
} catch (error) {
console.error('设置备注失败:', error);
}
createFriendGroup
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| name | string | 是 | 分组名称 |
| userIDList | string[] | 否 | 要添加到分组的用户ID列表 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { createFriendGroup } = useContactListState();
// 创建好友分组
try {
await createFriendGroup({
name: '工作同事',
userIDList: ['user123', 'user456']
});
console.log('好友分组创建成功');
} catch (error) {
console.error('创建分组失败:', error);
}
deleteFriendGroup
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| name | string | 是 | 要删除的分组名称 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { deleteFriendGroup } = useContactListState();
// 删除好友分组
try {
await deleteFriendGroup('工作同事');
console.log('好友分组删除成功');
} catch (error) {
console.error('删除分组失败:', error);
}
addToFriendGroup
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| name | string | 是 | 分组名称 |
| userIDList | string[] | 是 | 要添加的好友用户ID列表 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { addToFriendGroup } = useContactListState();
// 添加好友到分组
try {
await addToFriendGroup({
name: '工作同事',
userIDList: ['user789']
});
console.log('好友已添加到分组');
} catch (error) {
console.error('添加到分组失败:', error);
}
removeFromFriendGroup
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| name | string | 是 | 分组名称 |
| userIDList | string[] | 是 | 要移除的好友用户ID列表 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { removeFromFriendGroup } = useContactListState();
// 从分组移除好友
try {
await removeFromFriendGroup({
name: '工作同事',
userIDList: ['user789']
});
console.log('好友已从分组移除');
} catch (error) {
console.error('从分组移除失败:', error);
}
renameFriendGroup
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| oldName | string | 是 | 原分组名称 |
| newName | string | 是 | 新分组名称 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { renameFriendGroup } = useContactListState();
// 重命名好友分组
try {
await renameFriendGroup({
oldName: '工作同事',
newName: '公司同事'
});
console.log('分组重命名成功');
} catch (error) {
console.error('重命名分组失败:', error);
}
joinGroup
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 是 | 要加入的群组ID |
| applyMessage | string | 否 | 申请加群的理由 |
| type | string | 否 | 加群类型 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { joinGroup } = useContactListState();
// 申请加入群组
try {
await joinGroup({
groupID: 'group123',
applyMessage: '我想加入这个群组学习交流'
});
console.log('加群申请已发送');
} catch (error) {
console.error('加入群组失败:', error);
}
acceptGroupApplication
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| application | GroupApplication | 是 | 群组申请对象 |
| handleMessage | string | 否 | 处理消息 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { acceptGroupApplication, groupApplicationList } = useContactListState();
// 接受群组申请
try {
const application = groupApplicationList.value[0];
await acceptGroupApplication({
application: application,
handleMessage: '欢迎加入群组'
});
console.log('群组申请已接受');
} catch (error) {
console.error('接受群组申请失败:', error);
}
refuseGroupApplication
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| application | GroupApplication | 是 | 群组申请对象 |
| handleMessage | string | 否 | 拒绝理由 |
示例
import { useContactListState } from 'tuikit-atomicx-vue3';
const { refuseGroupApplication, groupApplicationList } = useContactListState();
// 拒绝群组申请
try {
const application = groupApplicationList.value[0];
await refuseGroupApplication({
application: application,
handleMessage: '暂不接受新成员'
});
console.log('群组申请已拒绝');
} catch (error) {
console.error('拒绝群组申请失败:', error);
}
GroupSettingState
响应式数据
groupID
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { groupID } = useGroupSettingState();
// 监听数据变化
watch(groupID, (newValue) => {
console.log('groupID 更新:', newValue);
});
// 直接访问数据
console.log('当前 groupID:', groupID.value);
groupType
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { groupType } = useGroupSettingState();
// 监听数据变化
watch(groupType, (newValue) => {
console.log('groupType 更新:', newValue);
});
// 直接访问数据
console.log('当前 groupType:', groupType.value);
groupName
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { groupName } = useGroupSettingState();
// 监听数据变化
watch(groupName, (newValue) => {
console.log('groupName 更新:', newValue);
});
// 直接访问数据
console.log('当前 groupName:', groupName.value);
avatar
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { avatar } = useGroupSettingState();
// 监听数据变化
watch(avatar, (newValue) => {
console.log('avatar 更新:', newValue);
});
// 直接访问数据
console.log('当前 avatar:', avatar.value);
introduction
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { introduction } = useGroupSettingState();
// 监听数据变化
watch(introduction, (newValue) => {
console.log('introduction 更新:', newValue);
});
// 直接访问数据
console.log('当前 introduction:', introduction.value);
notification
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { notification } = useGroupSettingState();
// 监听数据变化
watch(notification, (newValue) => {
console.log('notification 更新:', newValue);
});
// 直接访问数据
console.log('当前 notification:', notification.value);
isMuted
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { isMuted } = useGroupSettingState();
// 监听数据变化
watch(isMuted, (newValue) => {
console.log('isMuted 更新:', newValue);
});
// 直接访问数据
console.log('当前 isMuted:', isMuted.value);
isPinned
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { isPinned } = useGroupSettingState();
// 监听数据变化
watch(isPinned, (newValue) => {
console.log('isPinned 更新:', newValue);
});
// 直接访问数据
console.log('当前 isPinned:', isPinned.value);
groupOwner
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { groupOwner } = useGroupSettingState();
// 监听数据变化
watch(groupOwner, (newValue) => {
console.log('groupOwner 更新:', newValue);
});
// 直接访问数据
console.log('当前 groupOwner:', groupOwner.value);
adminMembers
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { adminMembers } = useGroupSettingState();
// 监听数据变化
watch(adminMembers, (newValue) => {
console.log('adminMembers 更新:', newValue);
});
// 直接访问数据
console.log('当前 adminMembers:', adminMembers.value);
allMembers
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { allMembers } = useGroupSettingState();
// 监听数据变化
watch(allMembers, (newValue) => {
console.log('allMembers 更新:', newValue);
});
// 直接访问数据
console.log('当前 allMembers:', allMembers.value);
memberCount
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { memberCount } = useGroupSettingState();
// 监听数据变化
watch(memberCount, (newValue) => {
console.log('memberCount 更新:', newValue);
});
// 直接访问数据
console.log('当前 memberCount:', memberCount.value);
maxMemberCount
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { maxMemberCount } = useGroupSettingState();
// 监听数据变化
watch(maxMemberCount, (newValue) => {
console.log('maxMemberCount 更新:', newValue);
});
// 直接访问数据
console.log('当前 maxMemberCount:', maxMemberCount.value);
currentUserID
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { currentUserID } = useGroupSettingState();
// 监听数据变化
watch(currentUserID, (newValue) => {
console.log('currentUserID 更新:', newValue);
});
// 直接访问数据
console.log('当前 currentUserID:', currentUserID.value);
currentUserRole
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { currentUserRole } = useGroupSettingState();
// 监听数据变化
watch(currentUserRole, (newValue) => {
console.log('currentUserRole 更新:', newValue);
});
// 直接访问数据
console.log('当前 currentUserRole:', currentUserRole.value);
nameCard
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { nameCard } = useGroupSettingState();
// 监听数据变化
watch(nameCard, (newValue) => {
console.log('nameCard 更新:', newValue);
});
// 直接访问数据
console.log('当前 nameCard:', nameCard.value);
isMuteAllMembers
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { isMuteAllMembers } = useGroupSettingState();
// 监听数据变化
watch(isMuteAllMembers, (newValue) => {
console.log('isMuteAllMembers 更新:', newValue);
});
// 直接访问数据
console.log('当前 isMuteAllMembers:', isMuteAllMembers.value);
isInGroup
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { isInGroup } = useGroupSettingState();
// 监听数据变化
watch(isInGroup, (newValue) => {
console.log('isInGroup 更新:', newValue);
});
// 直接访问数据
console.log('当前 isInGroup:', isInGroup.value);
inviteOption
Ref<any>
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { inviteOption } = useGroupSettingState();
// 监听数据变化
watch(inviteOption, (newValue) => {
console.log('inviteOption 更新:', newValue);
});
// 直接访问数据
console.log('当前 inviteOption:', inviteOption.value);
接口函数
getGroupMemberList
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
| count | number | 否 | 获取成员数量,默认100 |
| offset | number | 否 | 偏移量,用于分页,默认0 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { getGroupMemberList } = useGroupSettingState();
// 获取群组成员列表
try {
const members = await getGroupMemberList({
groupID: 'group123',
count: 50,
offset: 0
});
console.log('群组成员:', members);
} catch (error) {
console.error('获取成员列表失败:', error);
}
// 分页加载更多成员
const moreMembers = await getGroupMemberList({
count: 50,
offset: 50
});
updateGroupProfile
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
| name | string | 否 | 群组名称,长度限制1-30字符 |
| avatar | string | 否 | 群组头像URL,长度限制500字符以内 |
| introduction | string | 否 | 群组简介,长度限制130字符以内 |
| notification | string | 否 | 群组公告,长度限制130字符以内 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { updateGroupProfile } = useGroupSettingState();
// 更新群组资料
try {
await updateGroupProfile({
groupID: 'group123',
name: '新的群组名称',
introduction: '这是一个学习交流群',
notification: '欢迎大家积极讨论',
avatar: 'https://example.com/avatar.jpg'
});
console.log('群组资料更新成功');
} catch (error) {
console.error('更新群组资料失败:', error);
}
// 只更新群名称
await updateGroupProfile({
name: '技术交流群'
});
addGroupMember
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
| userIDList | string[] | 是 | 要添加的用户ID列表 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { addGroupMember } = useGroupSettingState();
// 添加群组成员
try {
const result = await addGroupMember({
groupID: 'group123',
userIDList: ['user1', 'user2', 'user3']
});
console.log('添加成功的用户:', result.successUserIDList);
console.log('添加失败的用户:', result.failureUserIDList);
} catch (error) {
console.error('添加群组成员失败:', error);
}
deleteGroupMember
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
| userIDList | string[] | 是 | 要删除的用户ID列表 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { deleteGroupMember } = useGroupSettingState();
// 删除群组成员
try {
await deleteGroupMember({
groupID: 'group123',
userIDList: ['user1', 'user2']
});
console.log('群组成员删除成功');
} catch (error) {
console.error('删除群组成员失败:', error);
}
changeGroupOwner
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
| newOwnerID | string | 是 | 新群主的用户ID |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { changeGroupOwner } = useGroupSettingState();
// 转让群主
try {
await changeGroupOwner({
groupID: 'group123',
newOwnerID: 'user123'
});
console.log('群主转让成功');
} catch (error) {
console.error('转让群主失败:', error);
}
setGroupMemberRole
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
| userID | string | 是 | 要设置角色的用户ID |
| role | GroupMemberRole | 是 | 新的角色类型 |
示例
import { useGroupSettingState, GroupMemberRole } from 'tuikit-atomicx-vue3';
const { setGroupMemberRole } = useGroupSettingState();
// 设置用户为管理员
try {
await setGroupMemberRole({
groupID: 'group123',
userID: 'user123',
role: GroupMemberRole.ADMIN
});
console.log('成员角色设置成功');
} catch (error) {
console.error('设置成员角色失败:', error);
}
// 取消管理员权限
await setGroupMemberRole({
userID: 'user123',
role: GroupMemberRole.COMMON
});
setGroupMemberNameCard
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
| userID | string | 否 | 用户ID,不传则使用当前用户ID |
| nameCard | string | 是 | 群名片内容 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { setGroupMemberNameCard } = useGroupSettingState();
// 设置自己的群名片
try {
await setGroupMemberNameCard({
groupID: 'group123',
nameCard: '技术负责人-小王'
});
console.log('群名片设置成功');
} catch (error) {
console.error('设置群名片失败:', error);
}
// 设置其他成员的群名片(需要管理员权限)
await setGroupMemberNameCard({
userID: 'user123',
nameCard: '产品经理-小李'
});
setChatPinned
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| value | boolean | 是 | 是否置顶,true为置顶,false为取消置顶 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { setChatPinned } = useGroupSettingState();
// 置顶聊天
try {
await setChatPinned(true);
console.log('聊天置顶成功');
} catch (error) {
console.error('设置置顶失败:', error);
}
// 取消置顶
await setChatPinned(false);
setChatMuted
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| value | boolean | 是 | 是否免打扰,true为开启免打扰,false为关闭免打扰 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { setChatMuted } = useGroupSettingState();
// 开启免打扰
try {
await setChatMuted(true);
console.log('免打扰设置成功');
} catch (error) {
console.error('设置免打扰失败:', error);
}
// 关闭免打扰
await setChatMuted(false);
setGroupMemberMuteTime
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
| userID | string | 是 | 要禁言的用户ID |
| time | number | 是 | 禁言时间(秒),0表示取消禁言 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { setGroupMemberMuteTime } = useGroupSettingState();
// 禁言用户10分钟
try {
await setGroupMemberMuteTime({
groupID: 'group123',
userID: 'user123',
time: 600 // 10分钟 = 600秒
});
console.log('用户禁言成功');
} catch (error) {
console.error('设置禁言失败:', error);
}
// 取消禁言
await setGroupMemberMuteTime({
userID: 'user123',
time: 0
});
setMuteAllMember
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| value | boolean | 是 | 是否全员禁言,true为开启,false为关闭 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { setMuteAllMember } = useGroupSettingState();
// 开启全员禁言
try {
await setMuteAllMember(true);
console.log('全员禁言开启成功');
} catch (error) {
console.error('设置全员禁言失败:', error);
}
// 关闭全员禁言
await setMuteAllMember(false);
dismissGroup
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { dismissGroup } = useGroupSettingState();
// 解散群组
try {
await dismissGroup('group123');
console.log('群组解散成功');
} catch (error) {
console.error('解散群组失败:', error);
}
// 解散当前群组
await dismissGroup();
quitGroup
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| groupID | string | 否 | 群组ID,不传则使用当前群组ID |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { quitGroup } = useGroupSettingState();
// 退出群组
try {
await quitGroup('group123');
console.log('退出群组成功');
} catch (error) {
console.error('退出群组失败:', error);
}
// 退出当前群组
await quitGroup();
hasPermission
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| permission | GroupPermission | 是 | 要检查的权限类型 |
| role | GroupMemberRole | 否 | 用户角色,不传则使用当前用户角色 |
| groupType | GroupType | 否 | 群组类型,不传则使用当前群组类型 |
示例
import { useGroupSettingState, GroupPermission, GroupMemberRole, GroupType } from 'tuikit-atomicx-vue3';
const { hasPermission } = useGroupSettingState();
// 检查当前用户是否有删除成员的权限
const canDeleteMember = hasPermission(GroupPermission.DELETE_MEMBER);
// 检查管理员在工作群中是否有修改群资料的权限
const canModifyProfile = hasPermission(
GroupPermission.MODIFY_GROUP_INFO,
GroupMemberRole.ADMIN,
GroupType.WORK
);
if (canDeleteMember) {
console.log('可以删除群成员');
}
canOperateOnMember
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| targetMember | GroupMember | 是 | 目标成员信息 |
示例
import { useGroupSettingState } from 'tuikit-atomicx-vue3';
const { canOperateOnMember, allMembers } = useGroupSettingState();
// 检查是否可以对某个成员进行操作
const member = allMembers.value?.find(m => m.userID === 'user123');
if (member && canOperateOnMember(member)) {
console.log('可以对该成员进行管理操作');
// 显示删除、禁言等操作按钮
} else {
console.log('无权限操作该成员');
}
// 权限规则:
// - 群主可以操作所有人(除自己)
// - 管理员只能操作普通成员
// - 普通成员不能操作任何人
// - 任何人都不能操作自己
getAvailablePermissions
示例
import { useGroupSettingState, GroupPermission } from 'tuikit-atomicx-vue3';
const { getAvailablePermissions } = useGroupSettingState();
// 获取当前用户的所有权限
const permissions = getAvailablePermissions();
// 根据权限显示不同的功能按钮
if (permissions.includes(GroupPermission.DELETE_MEMBER)) {
console.log('显示删除成员按钮');
}
if (permissions.includes(GroupPermission.MODIFY_GROUP_INFO)) {
console.log('显示编辑群资料按钮');
}
if (permissions.includes(GroupPermission.MUTE_MEMBER)) {
console.log('显示禁言成员按钮');
}
initWatcher
示例
// 该函数在模块加载时自动调用,监听以下数据变化:
// - 当前会话变化:自动更新群组信息和用户状态
// - 群组资料变化:同步更新群组ID等信息
// - 会话切换:自动重置或更新相关状态
// 通常不需要手动调用此函数
VideoMixerState
响应式数据
publishVideoQuality
Ref<TUIVideoQuality>
示例
import { useVideoMixerState, TUIVideoQuality } from 'tuikit-atomicx-vue3';
const { publishVideoQuality } = useVideoMixerState();
// 监听视频质量变化
watch(publishVideoQuality, (newValue) => {
console.log('视频质量更新:', newValue);
});
// 设置视频质量
publishVideoQuality.value = TUIVideoQuality.kVideoQuality_720p;
isVideoMixerEnabled
Ref<boolean>
示例
import { useVideoMixerState } from 'tuikit-atomicx-vue3';
const { isVideoMixerEnabled, enableLocalVideoMixer } = useVideoMixerState();
// 监听混流状态变化
watch(isVideoMixerEnabled, (newValue) => {
console.log('视频混流状态:', newValue ? '已启用' : '未启用');
});
// 检查混流状态
if (!isVideoMixerEnabled.value) {
enableLocalVideoMixer();
}
mediaSourceList
Ref<MediaSource[]>
示例
import { useVideoMixerState } from 'tuikit-atomicx-vue3';
const { mediaSourceList } = useVideoMixerState();
// 监听媒体源列表变化
watch(mediaSourceList, (newValue) => {
console.log('媒体源数量:', newValue.length);
});
// 遍历所有媒体源
mediaSourceList.value.forEach(source => {
console.log('媒体源:', source.id, source.type);
});
activeMediaSource
ComputedRef<MediaSource | null>
示例
import { useVideoMixerState } from 'tuikit-atomicx-vue3';
const { activeMediaSource, updateMediaSource } = useVideoMixerState();
// 监听活跃媒体源变化
watch(activeMediaSource, (newValue) => {
if (newValue) {
console.log('当前选中的媒体源:', newValue.id);
}
});
// 更新当前活跃媒体源的布局
if (activeMediaSource.value) {
updateMediaSource(activeMediaSource.value, {
layout: { rect: { left: 0, top: 0, right: 640, bottom: 480 } }
});
}
接口函数
enableLocalVideoMixer
示例
import { useVideoMixerState } from 'tuikit-atomicx-vue3';
const { enableLocalVideoMixer, isVideoMixerEnabled } = useVideoMixerState();
// 启用视频混流
enableLocalVideoMixer();
console.log('视频混流已启用:', isVideoMixerEnabled.value);
addMediaSource
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| source | MediaSource | 是 | 媒体源对象,包含类型、配置和布局信息 |
示例
import { useVideoMixerState } from 'tuikit-atomicx-vue3';
import { TRTCMediaSourceType } from '@tencentcloud/tuiroom-engine-js';
const { addMediaSource } = useVideoMixerState();
// 添加摄像头媒体源
await addMediaSource({
type: TRTCMediaSourceType.kCamera,
camera: { cameraId: 'default' },
});
// 添加屏幕分享媒体源
await addMediaSource({
type: TRTCMediaSourceType.kScreen,
screen: { sourceId: 'screen' },
});
// 添加图片媒体源
await addMediaSource({
type: TRTCMediaSourceType.kImage,
image: { imagePath: '/path/to/image.png' },
});
updateMediaSource
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| source | MediaSource | 是 | 要更新的媒体源对象 |
| config | Partial<MediaSource> | 是 | 更新的配置内容 |
示例
import { useVideoMixerState } from 'tuikit-atomicx-vue3';
const { updateMediaSource, mediaSourceList } = useVideoMixerState();
// 更新媒体源布局
const source = mediaSourceList.value[0];
if (source) {
await updateMediaSource(source, {
layout: {
rect: { left: 100, top: 100, right: 500, bottom: 400 }
}
});
console.log('媒体源布局已更新');
}
removeMediaSource
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| source | MediaSource | 是 | 要移除的媒体源对象 |
示例
import { useVideoMixerState } from 'tuikit-atomicx-vue3';
const { removeMediaSource, mediaSourceList } = useVideoMixerState();
// 移除第一个媒体源
const source = mediaSourceList.value[0];
if (source) {
await removeMediaSource(source);
console.log('媒体源已移除');
}
clearMediaSource
示例
import { useVideoMixerState } from 'tuikit-atomicx-vue3';
const { clearMediaSource, mediaSourceList } = useVideoMixerState();
// 清空所有媒体源
clearMediaSource();
console.log('所有媒体源已清空,当前数量:', mediaSourceList.value.length);
ASRState
响应式数据
recentTranscripts
Ref<any>
示例
import { useASRState } from 'tuikit-atomicx-vue3';
const { recentTranscripts } = useASRState();
// 监听数据变化
watch(recentTranscripts, (newValue) => {
console.log('recentTranscripts 更新:', newValue);
});
// 直接访问数据
console.log('当前 recentTranscripts:', recentTranscripts.value);
transcriptHistory
Ref<any>
示例
import { useASRState } from 'tuikit-atomicx-vue3';
const { transcriptHistory } = useASRState();
// 监听数据变化
watch(transcriptHistory, (newValue) => {
console.log('transcriptHistory 更新:', newValue);
});
// 直接访问数据
console.log('当前 transcriptHistory:', transcriptHistory.value);
接口函数
setRecentTranscriptsDuration
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| duration | number | 是 | 时间窗口大小,单位为毫秒 |
示例
import { useASRState } from 'tuikit-atomicx-vue3';
const { setRecentTranscriptsDuration } = useASRState();
// 设置最近消息窗口为5秒
setRecentTranscriptsDuration(5000);
// 设置最近消息窗口为10秒
setRecentTranscriptsDuration(10000);
clearHistory
示例
import { useASRState } from 'tuikit-atomicx-vue3';
const { clearHistory, transcriptHistory } = useASRState();
// 清除所有转写记录
clearHistory();
console.log('转录记录已清空:', transcriptHistory.value.length === 0);
exportTranscripts
示例
import { useASRState } from 'tuikit-atomicx-vue3';
const { exportTranscripts } = useASRState();
// 导出转写记录
const transcriptText = exportTranscripts();
if (transcriptText) {
// 保存到文件
const blob = new Blob([transcriptText], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = '会议转录记录.txt';
a.click();
URL.revokeObjectURL(url);
} else {
console.log('没有转录记录可导出');
}
SearchState
响应式数据
keyword
Ref<any>
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
const { keyword } = useSearchState();
// 监听数据变化
watch(keyword, (newValue) => {
console.log('keyword 更新:', newValue);
});
// 直接访问数据
console.log('当前 keyword:', keyword.value);
results
Ref<any>
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
const { results } = useSearchState();
// 监听数据变化
watch(results, (newValue) => {
console.log('results 更新:', newValue);
});
// 直接访问数据
console.log('当前 results:', results.value);
isLoading
Ref<any>
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
const { isLoading } = useSearchState();
// 监听数据变化
watch(isLoading, (newValue) => {
console.log('isLoading 更新:', newValue);
});
// 直接访问数据
console.log('当前 isLoading:', isLoading.value);
error
Ref<any>
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
const { error } = useSearchState();
// 监听数据变化
watch(error, (newValue) => {
console.log('error 更新:', newValue);
});
// 直接访问数据
console.log('当前 error:', error.value);
searchAdvancedParams
Ref<any>
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
const { searchAdvancedParams } = useSearchState();
// 监听数据变化
watch(searchAdvancedParams, (newValue) => {
console.log('searchAdvancedParams 更新:', newValue);
});
// 直接访问数据
console.log('当前 searchAdvancedParams:', searchAdvancedParams.value);
selectedSearchType
Ref<any>
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
const { selectedSearchType } = useSearchState();
// 监听数据变化
watch(selectedSearchType, (newValue) => {
console.log('selectedSearchType 更新:', newValue);
});
// 直接访问数据
console.log('当前 selectedSearchType:', selectedSearchType.value);
接口函数
setKeyword
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| keyword | string | 是 | 搜索关键词 |
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
const { setKeyword } = useSearchState();
// 设置搜索关键词
setKeyword('hello world');
// 清除搜索关键词
setKeyword('');
loadMore
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| type | SearchType | 否 | 搜索类型,如 SearchType.MESSAGE、SearchType.USER、SearchType.GROUP |
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
import { SearchType } from '@tencentcloud/chat-uikit-engine-lite';
const { loadMore } = useSearchState();
// 加载更多消息搜索结果
await loadMore(SearchType.MESSAGE);
// 加载更多用户搜索结果
await loadMore(SearchType.USER);
setSelectedType
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| type | SearchType | 'all' | 是 | 搜索类型,'all' 表示搜索所有类型 |
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
import { SearchType } from '@tencentcloud/chat-uikit-engine-lite';
const { setSelectedType } = useSearchState();
// 设置搜索类型为消息
setSelectedType(SearchType.MESSAGE);
// 设置搜索类型为全部
setSelectedType('all');
setSearchMessageAdvancedParams
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| params | SearchCloudMessagesParams | 是 | 消息搜索高级参数对象 |
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
import TUIChatEngine from '@tencentcloud/chat-uikit-engine-lite';
const { setSearchMessageAdvancedParams } = useSearchState();
// 设置消息搜索高级参数
setSearchMessageAdvancedParams({
conversationID: 'C2C_user123',
senderUserIDList: ['user1', 'user2'],
messageTypeList: [TUIChatEngine.TYPES.MSG_TYPE_TEXT]
});
setSearchUserAdvancedParams
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| params | SearchCloudUsersParams | 是 | 用户搜索高级参数对象 |
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
const { setSearchUserAdvancedParams } = useSearchState();
// 设置用户搜索高级参数
setSearchUserAdvancedParams({
// 用户搜索参数
});
setSearchGroupAdvancedParams
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| params | SearchCloudGroupsParams | 是 | 群组搜索高级参数对象 |
示例
import { useSearchState } from 'tuikit-atomicx-vue3';
const { setSearchGroupAdvancedParams } = useSearchState();
// 设置群组搜索高级参数
setSearchGroupAdvancedParams({
// 群组搜索参数
});
SeatStore
响应式数据
liveOwnerUserId
Ref<any>
示例
import { useSeatStore } from 'tuikit-atomicx-vue3';
const { liveOwnerUserId } = useSeatStore();
// 监听数据变化
watch(liveOwnerUserId, (newValue) => {
console.log('liveOwnerUserId 更新:', newValue);
});
// 直接访问数据
console.log('当前 liveOwnerUserId:', liveOwnerUserId.value);
localUserId
Ref<any>
示例
import { useSeatStore } from 'tuikit-atomicx-vue3';
const { localUserId } = useSeatStore();
// 监听数据变化
watch(localUserId, (newValue) => {
console.log('localUserId 更新:', newValue);
});
// 直接访问数据
console.log('当前 localUserId:', localUserId.value);
seatList
Ref<any>
示例
import { useSeatStore } from 'tuikit-atomicx-vue3';
const { seatList } = useSeatStore();
// 监听数据变化
watch(seatList, (newValue) => {
console.log('seatList 更新:', newValue);
});
// 直接访问数据
console.log('当前 seatList:', seatList.value);
coHostUserList
Ref<any>
示例
import { useSeatStore } from 'tuikit-atomicx-vue3';
const { coHostUserList } = useSeatStore();
// 监听数据变化
watch(coHostUserList, (newValue) => {
console.log('coHostUserList 更新:', newValue);
});
// 直接访问数据
console.log('当前 coHostUserList:', coHostUserList.value);
sentDeviceRequestMap
Ref<any>
示例
import { useSeatStore } from 'tuikit-atomicx-vue3';
const { sentDeviceRequestMap } = useSeatStore();
// 监听数据变化
watch(sentDeviceRequestMap, (newValue) => {
console.log('sentDeviceRequestMap 更新:', newValue);
});
// 直接访问数据
console.log('当前 sentDeviceRequestMap:', sentDeviceRequestMap.value);
receivedDeviceRequestMap
Ref<any>
示例
import { useSeatStore } from 'tuikit-atomicx-vue3';
const { receivedDeviceRequestMap } = useSeatStore();
// 监听数据变化
watch(receivedDeviceRequestMap, (newValue) => {
console.log('receivedDeviceRequestMap 更新:', newValue);
});
// 直接访问数据
console.log('当前 receivedDeviceRequestMap:', receivedDeviceRequestMap.value);
userInfoMap
Ref<any>
示例
import { useSeatStore } from 'tuikit-atomicx-vue3';
const { userInfoMap } = useSeatStore();
// 监听数据变化
watch(userInfoMap, (newValue) => {
console.log('userInfoMap 更新:', newValue);
});
// 直接访问数据
console.log('当前 userInfoMap:', userInfoMap.value);
接口函数
getUserInfo
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string | 是 | 用户ID |
示例
import { useSeatStore } from 'tuikit-atomicx-vue3';
const { getUserInfo } = useSeatStore();
// 通过userId获取用户信息
const userInfo = await getUserInfo('user_123');
console.log('用户信息:', userInfo);
// 输出: { userId, userName, avatarUrl, customInfo, userRole, isMessageDisabled }
convertUserInfoToAudienceInfo
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userInfo | TUIUserInfo | 是 | TUIUserInfo 格式的用户信息对象 |
示例
import { useSeatStore } from 'tuikit-atomicx-vue3';
const { convertUserInfoToAudienceInfo } = useSeatStore();
// 将TUIUserInfo转换为AudienceInfo格式
const tuiUserInfo = {
userId: 'user_123',
userName: 'John',
avatarUrl: 'https://example.com/avatar.png',
roomCustomInfo: {},
userRole: 0,
isMessageDisabled: false
};
const audienceInfo = convertUserInfoToAudienceInfo(tuiUserInfo);
console.log('观众信息:', audienceInfo);
// 输出: { userId, userName, avatarUrl, customInfo, userRole, isMessageDisabled }
AITranscriberState
管理实时语音转写的状态和操作,包括消息接收和历史记录等功能
响应式数据
realtimeMessageList
Ref<TranscriberMessage[]>
示例
import { watch } from 'vue';
import { useAITranscriberState } from 'tuikit-atomicx-vue3';
const { realtimeMessageList } = useAITranscriberState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => realtimeMessageList.value, (newValue) => {
console.log('realtimeMessageList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => realtimeMessageList.value?.length, (newLength, oldLength) => {
console.log('realtimeMessageList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 realtimeMessageList:', realtimeMessageList.value);
接口函数
startRealtimeTranscriber
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| sourceLanguage | TranscriberLanguage |
是 | 源语言 |
| translationLanguages | TranscriberLanguage[] |
否 | 目标翻译语言 |
示例
import { useAITranscriberState } from 'tuikit-atomicx-vue3';
const { startRealtimeTranscriber } = useAITranscriberState();
const transcriberRobotId = await startRealtimeTranscriber({
sourceLanguage: 'zh',
translationLanguages: ['en'],
});
stopRealtimeTranscriber
示例
import { useAITranscriberState } from 'tuikit-atomicx-vue3';
const { stopRealtimeTranscriber } = useAITranscriberState();
await stopRealtimeTranscriber();
updateRealTimeTranscriber
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| sourceLanguage | TranscriberLanguage |
是 | 源语言 |
| translationLanguages | TranscriberLanguage[] |
否 | 目标翻译语言 |
示例
import { useAITranscriberState } from 'tuikit-atomicx-vue3';
const { updateRealTimeTranscriber } = useAITranscriberState();
await updateRealTimeTranscriber({
sourceLanguage: 'zh',
translationLanguages: ['en'],
});
subscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | RealtimeTranscriberEvent |
是 | 事件名称 |
| callback | RealtimeTranscriberEventCallback |
是 | 事件回调函数 |
示例
import { useAITranscriberState, RealtimeTranscriberEvent } from 'tuikit-atomicx-vue3';
const { subscribeEvent } = useAITranscriberState();
subscribeEvent(RealtimeTranscriberEvent.onReceiveTranscriberMessage, (eventInfo) => {
console.log('onReceiveTranscriberMessage', eventInfo);
});
unsubscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | RealtimeTranscriberEvent |
是 | 事件名称 |
| callback | RealtimeTranscriberEventCallback |
是 | 事件回调函数 |
示例
import { useAITranscriberState, RealtimeTranscriberEvent } from 'tuikit-atomicx-vue3';
const { unsubscribeEvent } = useAITranscriberState();
unsubscribeEvent(RealtimeTranscriberEvent.onReceiveTranscriberMessage, (eventInfo) => {
console.log('onReceiveTranscriberMessage', eventInfo);
});
BarrageState
管理直播间弹幕功能,包括文本消息和自定义消息的发送、接收和存储
响应式数据
messageList
Ref<Barrage[]>
示例
import { watch } from 'vue';
import { useBarrageState } from 'tuikit-atomicx-vue3';
const { messageList } = useBarrageState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => messageList.value, (newValue) => {
console.log('messageList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => messageList.value?.length, (newLength, oldLength) => {
console.log('messageList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 messageList:', messageList.value);
接口函数
sendTextMessage
示例
import { useBarrageState } from 'tuikit-atomicx-vue3';
const { sendTextMessage } = useBarrageState();
// 调用函数
await sendTextMessage();
sendCustomMessage
示例
import { useBarrageState } from 'tuikit-atomicx-vue3';
const { sendCustomMessage } = useBarrageState();
// 调用函数
await sendCustomMessage();
appendLocalTip
示例
import { useBarrageState } from 'tuikit-atomicx-vue3';
const { appendLocalTip } = useBarrageState();
// 调用函数
await appendLocalTip();
BattleState
管理直播间PK功能,包括PK邀请、接受、拒绝、退出以及PK过程中的事件处理和状态管理
响应式数据
currentBattleInfo
Ref<BattleInfo | undefined>
示例
import { watch } from 'vue';
import { useBattleState } from 'tuikit-atomicx-vue3';
const { currentBattleInfo } = useBattleState();
// 监听数据变化
watch(currentBattleInfo, (newValue) => {
console.log('currentBattleInfo 已更新:', newValue);
});
// 直接访问数据
console.log('当前 currentBattleInfo:', currentBattleInfo.value);
battleUsers
Ref<SeatUserInfo[]>
示例
import { watch } from 'vue';
import { useBattleState } from 'tuikit-atomicx-vue3';
const { battleUsers } = useBattleState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => battleUsers.value, (newValue) => {
console.log('battleUsers 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => battleUsers.value?.length, (newLength, oldLength) => {
console.log('battleUsers 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 battleUsers:', battleUsers.value);
battleScore
Ref<Map<string, number>>
示例
import { watch } from 'vue';
import { useBattleState } from 'tuikit-atomicx-vue3';
const { battleScore } = useBattleState();
// 监听数据变化
watch(battleScore, (newValue) => {
console.log('battleScore 已更新:', newValue);
});
// 直接访问数据
console.log('当前 battleScore:', battleScore.value);
接口函数
subscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | BattleEvent |
是 | 要订阅的PK事件类型 |
| eventInfo | any |
是 | 事件信息对象 |
示例
const { subscribeEvent } = useBattleState();
// 订阅PK开始事件
subscribeEvent(BattleEvent.onBattleStarted, (eventInfo) => {
console.log('PK开始了:', eventInfo.battleInfo);
console.log('发起者:', eventInfo.inviter.userName);
console.log('被邀请者:', eventInfo.invitees.map(u => u.userName));
});
// 订阅PK结束事件
subscribeEvent(BattleEvent.onBattleEnded, (eventInfo) => {
console.log('PK结束:', eventInfo.reason);
});
unsubscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | BattleEvent |
是 | 要取消订阅的PK事件类型 |
| callback | Function |
是 | 要移除的回调函数 |
示例
const { subscribeEvent, unsubscribeEvent } = useBattleState();
const handleBattleStart = (eventInfo) => {
console.log('PK开始:', eventInfo);
};
// 订阅事件
subscribeEvent(BattleEvent.onBattleStarted, handleBattleStart);
// 取消订阅
unsubscribeEvent(BattleEvent.onBattleStarted, handleBattleStart);
requestBattle
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| duration | number |
是 | PK持续时间(秒) |
| needResponse | boolean |
是 | 是否需要响应 |
| extensionInfo | Record<string, any> |
否 | 扩展信息 |
| userIdList | string[] |
否 | 被邀请用户ID列表 |
| timeout | number |
是 | 邀请超时时间(秒) |
示例
const { requestBattle } = useBattleState();
// 发起PK邀请
try {
await requestBattle({
config: {
duration: 300, // 5分钟PK
needResponse: true,
extensionInfo: { theme: 'singing' }
},
userIdList: ['user123', 'user456'],
timeout: 30 // 30秒超时
});
console.log('PK邀请发送成功');
} catch (error) {
console.error('PK邀请发送失败:', error);
}
cancelBattleRequest
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| battleId | string |
是 | PK ID |
| userIdList | string[] |
否 | 要取消邀请的用户ID列表 |
示例
const { cancelBattleRequest } = useBattleState();
// 取消PK邀请
try {
await cancelBattleRequest({
battleId: 'battle_123',
userIdList: ['user123', 'user456']
});
console.log('PK邀请已取消');
} catch (error) {
console.error('取消PK邀请失败:', error);
}
acceptBattle
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| battleId | string |
是 | PK ID |
示例
const { acceptBattle, subscribeEvent } = useBattleState();
// 监听PK邀请
subscribeEvent(BattleEvent.onBattleRequestReceived, async (eventInfo) => {
const { battleId, inviter } = eventInfo;
console.log(`收到来自 ${inviter.userName} 的PK邀请`);
// 接受PK邀请
try {
await acceptBattle({ battleId });
console.log('已接受PK邀请');
} catch (error) {
console.error('接受PK邀请失败:', error);
}
});
rejectBattle
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| battleId | string |
是 | PK ID |
示例
const { rejectBattle, subscribeEvent } = useBattleState();
// 监听PK邀请并拒绝
subscribeEvent(BattleEvent.onBattleRequestReceived, async (eventInfo) => {
const { battleId, inviter } = eventInfo;
console.log(`收到来自 ${inviter.userName} 的PK邀请`);
// 拒绝PK邀请
try {
await rejectBattle({ battleId });
console.log('已拒绝PK邀请');
} catch (error) {
console.error('拒绝PK邀请失败:', error);
}
});
exitBattle
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| battleId | string |
是 | PK ID |
示例
const { exitBattle, currentBattleInfo } = useBattleState();
// 退出当前PK
const handleExitBattle = async () => {
if (currentBattleInfo.value) {
try {
await exitBattle({
battleId: currentBattleInfo.value.battleId
});
console.log('已退出PK');
} catch (error) {
console.error('退出PK失败:', error);
}
}
};
C2CSettingState
管理单聊(C2C)会话的设置功能,包括用户信息、会话置顶、静音、好友关系管理等功能
响应式数据
userID
Ref<unknown>
示例
import { watch } from 'vue';
import { useC2CSettingState } from 'tuikit-atomicx-vue3';
const { userID } = useC2CSettingState();
// 监听数据变化
watch(userID, (newValue) => {
console.log('userID 已更新:', newValue);
});
// 直接访问数据
console.log('当前 userID:', userID.value);
nick
Ref<unknown>
示例
import { watch } from 'vue';
import { useC2CSettingState } from 'tuikit-atomicx-vue3';
const { nick } = useC2CSettingState();
// 监听数据变化
watch(nick, (newValue) => {
console.log('nick 已更新:', newValue);
});
// 直接访问数据
console.log('当前 nick:', nick.value);
avatar
Ref<unknown>
示例
import { watch } from 'vue';
import { useC2CSettingState } from 'tuikit-atomicx-vue3';
const { avatar } = useC2CSettingState();
// 监听数据变化
watch(avatar, (newValue) => {
console.log('avatar 已更新:', newValue);
});
// 直接访问数据
console.log('当前 avatar:', avatar.value);
signature
Ref<unknown>
示例
import { watch } from 'vue';
import { useC2CSettingState } from 'tuikit-atomicx-vue3';
const { signature } = useC2CSettingState();
// 监听数据变化
watch(signature, (newValue) => {
console.log('signature 已更新:', newValue);
});
// 直接访问数据
console.log('当前 signature:', signature.value);
remark
Ref<unknown>
示例
import { watch } from 'vue';
import { useC2CSettingState } from 'tuikit-atomicx-vue3';
const { remark } = useC2CSettingState();
// 监听数据变化
watch(remark, (newValue) => {
console.log('remark 已更新:', newValue);
});
// 直接访问数据
console.log('当前 remark:', remark.value);
isMuted
Ref<unknown>
示例
import { watch } from 'vue';
import { useC2CSettingState } from 'tuikit-atomicx-vue3';
const { isMuted } = useC2CSettingState();
// 监听数据变化
watch(isMuted, (newValue) => {
console.log('isMuted 已更新:', newValue);
});
// 直接访问数据
console.log('当前 isMuted:', isMuted.value);
isPinned
Ref<unknown>
示例
import { watch } from 'vue';
import { useC2CSettingState } from 'tuikit-atomicx-vue3';
const { isPinned } = useC2CSettingState();
// 监听数据变化
watch(isPinned, (newValue) => {
console.log('isPinned 已更新:', newValue);
});
// 直接访问数据
console.log('当前 isPinned:', isPinned.value);
isContact
Ref<unknown>
示例
import { watch } from 'vue';
import { useC2CSettingState } from 'tuikit-atomicx-vue3';
const { isContact } = useC2CSettingState();
// 监听数据变化
watch(isContact, (newValue) => {
console.log('isContact 已更新:', newValue);
});
// 直接访问数据
console.log('当前 isContact:', isContact.value);
接口函数
setChatPinned
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| value | boolean |
是 | 置顶状态,true为置顶,false为取消置顶 |
示例
const { setChatPinned, isPinned } = useC2CSettingState();
// 置顶会话
setChatPinned(true);
// 取消置顶
setChatPinned(false);
// 切换置顶状态
const togglePin = () => {
setChatPinned(!isPinned.value);
};
setChatMuted
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| value | boolean |
是 | 静音状态,true为静音,false为取消静音 |
示例
const { setChatMuted, isMuted } = useC2CSettingState();
// 静音会话
setChatMuted(true);
// 取消静音
setChatMuted(false);
// 切换静音状态
const toggleMute = () => {
setChatMuted(!isMuted.value);
};
setUserRemark
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| remark | string |
是 | 要设置的备注名 |
示例
const { setUserRemark, userID, isContact } = useC2CSettingState();
// 设置好友备注
const updateRemark = async (newRemark: string) => {
if (isContact.value && userID.value) {
try {
await setUserRemark(newRemark);
console.log('备注设置成功');
} catch (error) {
console.error('备注设置失败:', error);
}
} else {
console.log('只能为好友设置备注');
}
};
// 使用示例
updateRemark('我的好朋友');
CoGuestState
管理连麦嘉宾的状态和操作,包括申请连麦、邀请连麦、处理连麦请求等功能
响应式数据
connected
Ref<SeatUserInfo[]>
示例
import { watch } from 'vue';
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { connected } = useCoGuestState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => connected.value, (newValue) => {
console.log('connected 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => connected.value?.length, (newLength, oldLength) => {
console.log('connected 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 connected:', connected.value);
invitees
Ref<LiveUserInfo[]>
示例
import { watch } from 'vue';
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { invitees } = useCoGuestState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => invitees.value, (newValue) => {
console.log('invitees 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => invitees.value?.length, (newLength, oldLength) => {
console.log('invitees 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 invitees:', invitees.value);
applicants
Ref<LiveUserInfo[]>
示例
import { watch } from 'vue';
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { applicants } = useCoGuestState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => applicants.value, (newValue) => {
console.log('applicants 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => applicants.value?.length, (newLength, oldLength) => {
console.log('applicants 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 applicants:', applicants.value);
candidates
Ref<Array>
示例
import { watch } from 'vue';
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { candidates } = useCoGuestState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => candidates.value, (newValue) => {
console.log('candidates 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => candidates.value?.length, (newLength, oldLength) => {
console.log('candidates 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 candidates:', candidates.value);
接口函数
applyForSeat
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| seatIndex | number |
是 | 麦位索引,指定要申请的麦位位置 |
| timeout | number |
是 | 超时时间(秒),超过此时间未响应将自动取消申请 |
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { applyForSeat } = useCoGuestState();
// 调用函数
await applyForSeat({
seatIndex: 0,
timeout: 30,
});
cancelApplication
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { cancelApplication } = useCoGuestState();
// 调用函数
await cancelApplication();
acceptApplication
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 要接受的申请者用户 ID |
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { acceptApplication } = useCoGuestState();
// 调用函数
await acceptApplication({
userId: 'user_001',
});
rejectApplication
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 要拒绝的申请者用户 ID |
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { rejectApplication } = useCoGuestState();
// 调用函数
await rejectApplication({
userId: 'user_001',
});
inviteToSeat
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 要邀请的用户 ID |
| seatIndex | number |
是 | 麦位索引,指定邀请用户上的麦位位置 |
| timeout | number |
是 | 超时时间(毫秒),超过此时间未响应将自动取消邀请 |
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { inviteToSeat } = useCoGuestState();
// 调用函数
await inviteToSeat({
userId: 'user_001',
seatIndex: 0,
timeout: 30,
});
cancelInvitation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| inviteeId | string |
是 | 要取消邀请的被邀请者用户 ID |
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { cancelInvitation } = useCoGuestState();
// 调用函数
await cancelInvitation({
inviteeId: 'example_inviteeId',
});
acceptInvitation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| inviterId | string |
是 | 发送邀请的主播用户 ID |
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { acceptInvitation } = useCoGuestState();
// 调用函数
await acceptInvitation({
inviterId: 'example_inviterId',
});
rejectInvitation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| inviterId | string |
是 | 发送邀请的主播用户 ID |
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { rejectInvitation } = useCoGuestState();
// 调用函数
await rejectInvitation({
inviterId: 'example_inviterId',
});
disConnect
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { disConnect } = useCoGuestState();
// 调用函数
await disConnect();
subscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | HostEvent | GuestEvent |
是 | 要订阅的事件类型 |
| callback | Function |
是 | 回调函数,接收事件信息作为参数 |
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { subscribeEvent } = useCoGuestState();
// 调用函数
await subscribeEvent({ event: /* HostEvent | GuestEvent */, callback: /* Function */ });
unsubscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | HostEvent | GuestEvent |
是 | 要取消订阅的事件类型 |
| callback | Function |
是 | 要移除的回调函数 |
示例
import { useCoGuestState } from 'tuikit-atomicx-vue3';
const { unsubscribeEvent } = useCoGuestState();
// 调用函数
await unsubscribeEvent({ event: /* HostEvent | GuestEvent */, callback: /* Function */ });
CoHostState
管理直播连麦功能,包括连麦邀请、接受、拒绝、退出以及连麦过程中的用户管理和事件处理
响应式数据
coHostStatus
ComputedRef<CoHostStatus>
示例
import { watch } from 'vue';
import { useCoHostState } from 'tuikit-atomicx-vue3';
const { coHostStatus } = useCoHostState();
// 监听数据变化
watch(coHostStatus, (newValue) => {
console.log('coHostStatus 已更新:', newValue);
});
// 直接访问数据
console.log('当前 coHostStatus:', coHostStatus.value);
connected
Ref<SeatUserInfo[]>
示例
import { watch } from 'vue';
import { useCoHostState } from 'tuikit-atomicx-vue3';
const { connected } = useCoHostState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => connected.value, (newValue) => {
console.log('connected 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => connected.value?.length, (newLength, oldLength) => {
console.log('connected 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 connected:', connected.value);
applicant
Ref<SeatUserInfo | null>
示例
import { watch } from 'vue';
import { useCoHostState } from 'tuikit-atomicx-vue3';
const { applicant } = useCoHostState();
// 监听数据变化
watch(applicant, (newValue) => {
console.log('applicant 已更新:', newValue);
});
// 直接访问数据
console.log('当前 applicant:', applicant.value);
invitees
Ref<SeatUserInfo[]>
示例
import { watch } from 'vue';
import { useCoHostState } from 'tuikit-atomicx-vue3';
const { invitees } = useCoHostState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => invitees.value, (newValue) => {
console.log('invitees 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => invitees.value?.length, (newLength, oldLength) => {
console.log('invitees 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 invitees:', invitees.value);
candidates
ComputedRef<SeatUserInfo[]>
示例
import { watch } from 'vue';
import { useCoHostState } from 'tuikit-atomicx-vue3';
const { candidates } = useCoHostState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => candidates.value, (newValue) => {
console.log('candidates 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => candidates.value?.length, (newLength, oldLength) => {
console.log('candidates 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 candidates:', candidates.value);
接口函数
requestHostConnection
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 目标直播间ID |
| layoutTemplate | CoHostLayoutTemplate |
是 | 连麦布局模板 |
| timeout | number |
是 | 请求超时时间(秒) |
| extensionInfo | string |
是 | 扩展信息 |
示例
const { requestHostConnection } = useCoHostState();
// 发起连麦请求
try {
const result = await requestHostConnection({
liveId: 'live_123',
layoutTemplate: CoHostLayoutTemplate.Grid,
timeout: 30,
extensionInfo: JSON.stringify({ type: 'music' })
});
const code = result.get('live_123');
if (code === TUIConnectionCode.TUIConnectionCodeSuccess) {
console.log('连麦请求发送成功');
} else {
console.log('连麦请求失败:', code);
}
} catch (error) {
console.error('连麦请求异常:', error);
}
cancelHostConnection
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 目标直播间ID |
示例
const { cancelHostConnection } = useCoHostState();
// 取消连麦请求
try {
await cancelHostConnection({
liveId: 'live_123'
});
console.log('连麦请求已取消');
} catch (error) {
console.error('取消连麦请求失败:', error);
}
acceptHostConnection
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 发起连麦的直播间ID |
示例
const { acceptHostConnection, subscribeEvent } = useCoHostState();
// 监听连麦请求并接受
subscribeEvent(CoHostEvent.onCoHostRequestReceived, async (eventInfo) => {
const { inviter } = eventInfo;
console.log(`收到来自 ${inviter.userName} 的连麦请求`);
// 接受连麦请求
try {
await acceptHostConnection({ liveId: inviter.liveId });
console.log('已接受连麦请求');
} catch (error) {
console.error('接受连麦请求失败:', error);
}
});
rejectHostConnection
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| liveId | string |
是 | 发起连麦的直播间ID |
示例
const { rejectHostConnection, subscribeEvent } = useCoHostState();
// 监听连麦请求并拒绝
subscribeEvent(CoHostEvent.onCoHostRequestReceived, async (eventInfo) => {
const { inviter } = eventInfo;
console.log(`收到来自 ${inviter.userName} 的连麦请求`);
// 拒绝连麦请求
try {
await rejectHostConnection({ liveId: inviter.liveId });
console.log('已拒绝连麦请求');
} catch (error) {
console.error('拒绝连麦请求失败:', error);
}
});
exitHostConnection
示例
const { exitHostConnection, coHostStatus } = useCoHostState();
// 退出连麦
const handleExitCoHost = async () => {
if (coHostStatus.value === CoHostStatus.Connected) {
try {
await exitHostConnection();
console.log('已退出连麦');
} catch (error) {
console.error('退出连麦失败:', error);
}
}
};
subscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | CoHostEvent |
是 | 要订阅的连麦事件类型 |
| callback | CoHostEventCallback |
是 | 事件触发时的回调函数 |
示例
const { subscribeEvent } = useCoHostState();
// 订阅连麦请求事件
subscribeEvent(CoHostEvent.onCoHostRequestReceived, (eventInfo) => {
console.log('收到连麦请求:', eventInfo.inviter);
});
// 订阅用户加入连麦事件
subscribeEvent(CoHostEvent.onCoHostUserJoined, (eventInfo) => {
console.log('用户加入连麦:', eventInfo.userInfo.userName);
});
// 订阅用户离开连麦事件
subscribeEvent(CoHostEvent.onCoHostUserLeft, (eventInfo) => {
console.log('用户离开连麦:', eventInfo.userInfo.userName);
});
unsubscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | CoHostEvent |
是 | 要取消订阅的连麦事件类型 |
| callback | CoHostEventCallback |
是 | 要移除的回调函数 |
示例
const { subscribeEvent, unsubscribeEvent } = useCoHostState();
const handleCoHostRequest = (eventInfo) => {
console.log('连麦请求:', eventInfo);
};
// 订阅事件
subscribeEvent(CoHostEvent.onCoHostRequestReceived, handleCoHostRequest);
// 取消订阅
unsubscribeEvent(CoHostEvent.onCoHostRequestReceived, handleCoHostRequest);
DeviceState
管理音视频设备的状态和操作,包括麦克风、摄像头、扬声器和屏幕分享等功能
响应式数据
microphoneStatus
Ref<DeviceStatus>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { microphoneStatus } = useDeviceState();
// 监听数据变化
watch(microphoneStatus, (newValue) => {
console.log('microphoneStatus 已更新:', newValue);
});
// 直接访问数据
console.log('当前 microphoneStatus:', microphoneStatus.value);
microphoneList
Ref<TUIDeviceInfo[]>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { microphoneList } = useDeviceState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => microphoneList.value, (newValue) => {
console.log('microphoneList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => microphoneList.value?.length, (newLength, oldLength) => {
console.log('microphoneList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 microphoneList:', microphoneList.value);
currentMicrophone
Ref<TUIDeviceInfo | null>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { currentMicrophone } = useDeviceState();
// 监听数据变化
watch(currentMicrophone, (newValue) => {
console.log('currentMicrophone 已更新:', newValue);
});
// 直接访问数据
console.log('当前 currentMicrophone:', currentMicrophone.value);
microphoneLastError
Ref<DeviceError>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { microphoneLastError } = useDeviceState();
// 监听数据变化
watch(microphoneLastError, (newValue) => {
console.log('microphoneLastError 已更新:', newValue);
});
// 直接访问数据
console.log('当前 microphoneLastError:', microphoneLastError.value);
isMicrophoneTesting
Ref<boolean>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { isMicrophoneTesting } = useDeviceState();
// 监听数据变化
watch(isMicrophoneTesting, (newValue) => {
console.log('isMicrophoneTesting 已更新:', newValue);
});
// 直接访问数据
console.log('当前 isMicrophoneTesting:', isMicrophoneTesting.value);
currentMicVolume
Ref<number>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { currentMicVolume } = useDeviceState();
// 监听数据变化
watch(currentMicVolume, (newValue) => {
console.log('currentMicVolume 已更新:', newValue);
});
// 直接访问数据
console.log('当前 currentMicVolume:', currentMicVolume.value);
captureVolume
Ref<number>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { captureVolume } = useDeviceState();
// 监听数据变化
watch(captureVolume, (newValue) => {
console.log('captureVolume 已更新:', newValue);
});
// 直接访问数据
console.log('当前 captureVolume:', captureVolume.value);
testingMicVolume
Ref<number>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { testingMicVolume } = useDeviceState();
// 监听数据变化
watch(testingMicVolume, (newValue) => {
console.log('testingMicVolume 已更新:', newValue);
});
// 直接访问数据
console.log('当前 testingMicVolume:', testingMicVolume.value);
cameraStatus
Ref<DeviceStatus>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { cameraStatus } = useDeviceState();
// 监听数据变化
watch(cameraStatus, (newValue) => {
console.log('cameraStatus 已更新:', newValue);
});
// 直接访问数据
console.log('当前 cameraStatus:', cameraStatus.value);
cameraList
Ref<TUIDeviceInfo[]>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { cameraList } = useDeviceState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => cameraList.value, (newValue) => {
console.log('cameraList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => cameraList.value?.length, (newLength, oldLength) => {
console.log('cameraList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 cameraList:', cameraList.value);
currentCamera
Ref<TUIDeviceInfo | null>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { currentCamera } = useDeviceState();
// 监听数据变化
watch(currentCamera, (newValue) => {
console.log('currentCamera 已更新:', newValue);
});
// 直接访问数据
console.log('当前 currentCamera:', currentCamera.value);
cameraLastError
Ref<DeviceError>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { cameraLastError } = useDeviceState();
// 监听数据变化
watch(cameraLastError, (newValue) => {
console.log('cameraLastError 已更新:', newValue);
});
// 直接访问数据
console.log('当前 cameraLastError:', cameraLastError.value);
isCameraTesting
Ref<boolean>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { isCameraTesting } = useDeviceState();
// 监听数据变化
watch(isCameraTesting, (newValue) => {
console.log('isCameraTesting 已更新:', newValue);
});
// 直接访问数据
console.log('当前 isCameraTesting:', isCameraTesting.value);
isCameraTestLoading
Ref<boolean>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { isCameraTestLoading } = useDeviceState();
// 监听数据变化
watch(isCameraTestLoading, (newValue) => {
console.log('isCameraTestLoading 已更新:', newValue);
});
// 直接访问数据
console.log('当前 isCameraTestLoading:', isCameraTestLoading.value);
isFrontCamera
Ref<boolean>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { isFrontCamera } = useDeviceState();
// 监听数据变化
watch(isFrontCamera, (newValue) => {
console.log('isFrontCamera 已更新:', newValue);
});
// 直接访问数据
console.log('当前 isFrontCamera:', isFrontCamera.value);
localMirrorType
Ref<MirrorType>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { localMirrorType } = useDeviceState();
// 监听数据变化
watch(localMirrorType, (newValue) => {
console.log('localMirrorType 已更新:', newValue);
});
// 直接访问数据
console.log('当前 localMirrorType:', localMirrorType.value);
localVideoQuality
Ref<VideoQuality>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { localVideoQuality } = useDeviceState();
// 监听数据变化
watch(localVideoQuality, (newValue) => {
console.log('localVideoQuality 已更新:', newValue);
});
// 直接访问数据
console.log('当前 localVideoQuality:', localVideoQuality.value);
speakerList
Ref<TUIDeviceInfo[]>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { speakerList } = useDeviceState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => speakerList.value, (newValue) => {
console.log('speakerList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => speakerList.value?.length, (newLength, oldLength) => {
console.log('speakerList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 speakerList:', speakerList.value);
currentSpeaker
Ref<TUIDeviceInfo | null>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { currentSpeaker } = useDeviceState();
// 监听数据变化
watch(currentSpeaker, (newValue) => {
console.log('currentSpeaker 已更新:', newValue);
});
// 直接访问数据
console.log('当前 currentSpeaker:', currentSpeaker.value);
outputVolume
Ref<number>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { outputVolume } = useDeviceState();
// 监听数据变化
watch(outputVolume, (newValue) => {
console.log('outputVolume 已更新:', newValue);
});
// 直接访问数据
console.log('当前 outputVolume:', outputVolume.value);
currentAudioRoute
Ref<AudioRoute>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { currentAudioRoute } = useDeviceState();
// 监听数据变化
watch(currentAudioRoute, (newValue) => {
console.log('currentAudioRoute 已更新:', newValue);
});
// 直接访问数据
console.log('当前 currentAudioRoute:', currentAudioRoute.value);
isSpeakerTesting
Ref<boolean>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { isSpeakerTesting } = useDeviceState();
// 监听数据变化
watch(isSpeakerTesting, (newValue) => {
console.log('isSpeakerTesting 已更新:', newValue);
});
// 直接访问数据
console.log('当前 isSpeakerTesting:', isSpeakerTesting.value);
screenStatus
Ref<DeviceStatus>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { screenStatus } = useDeviceState();
// 监听数据变化
watch(screenStatus, (newValue) => {
console.log('screenStatus 已更新:', newValue);
});
// 直接访问数据
console.log('当前 screenStatus:', screenStatus.value);
screenLastError
Ref<DeviceError>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { screenLastError } = useDeviceState();
// 监听数据变化
watch(screenLastError, (newValue) => {
console.log('screenLastError 已更新:', newValue);
});
// 直接访问数据
console.log('当前 screenLastError:', screenLastError.value);
networkInfo
Ref<NetworkInfo | null>
示例
import { watch } from 'vue';
import { useDeviceState } from 'tuikit-atomicx-vue3';
const { networkInfo } = useDeviceState();
// 监听数据变化
watch(networkInfo, (newValue) => {
console.log('networkInfo 已更新:', newValue);
});
// 直接访问数据
console.log('当前 networkInfo:', networkInfo.value);
接口函数
openLocalMicrophone
示例
const { openLocalMicrophone } = useDeviceState();
// 开启麦克风
try {
await openLocalMicrophone();
console.log('麦克风开启成功');
} catch (error) {
console.error('麦克风开启失败:', error);
}
closeLocalMicrophone
示例
const { closeLocalMicrophone } = useDeviceState();
// 关闭麦克风
await closeLocalMicrophone();
muteLocalAudio
示例
const { muteLocalAudio } = useDeviceState();
// 静音本地音频
await muteLocalAudio();
unmuteLocalAudio
示例
const { unmuteLocalAudio } = useDeviceState();
// 取消静音本地音频
await unmuteLocalAudio();
getMicrophoneList
示例
const { getMicrophoneList, microphoneList } = useDeviceState();
// 获取麦克风列表
try {
await getMicrophoneList();
console.log('麦克风列表:', microphoneList.value);
} catch (error) {
console.error('获取麦克风列表失败:', error);
}
setCurrentMicrophone
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| deviceId | string |
是 | 要切换到的麦克风设备ID |
示例
const { setCurrentMicrophone } = useDeviceState();
// 切换麦克风设备
await setCurrentMicrophone({ deviceId: 'microphone-device-id' });
startMicrophoneTest
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| interval | number |
否 | =200] - 音量检测间隔(毫秒) |
示例
const { startMicrophoneTest } = useDeviceState();
// 开始麦克风测试(默认200ms间隔)
await startMicrophoneTest({});
// 开始麦克风测试(自定义间隔)
await startMicrophoneTest({ interval: 100 });
stopMicrophoneTest
示例
const { stopMicrophoneTest } = useDeviceState();
// 停止麦克风测试
await stopMicrophoneTest();
setCaptureVolume
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| volume | number |
是 | 音量大小(0-100) |
示例
const { setCaptureVolume } = useDeviceState();
// 设置采集音量为80%
await setCaptureVolume(80);
getSpeakerList
示例
const { getSpeakerList, speakerList } = useDeviceState();
// 获取扬声器列表
try {
await getSpeakerList();
console.log('扬声器列表:', speakerList.value);
} catch (error) {
console.error('获取扬声器列表失败:', error);
}
setCurrentSpeaker
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| deviceId | string |
是 | 要切换到的扬声器设备ID |
示例
const { setCurrentSpeaker } = useDeviceState();
// 切换扬声器设备
await setCurrentSpeaker({ deviceId: 'speaker-device-id' });
setAudioRoute
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| output | AudioRoute |
是 | 音频路由类型 |
示例
const { setAudioRoute } = useDeviceState();
// 设置为扬声器模式
await setAudioRoute(AudioRoute.Speakerphone);
// 设置为听筒模式
await setAudioRoute(AudioRoute.Earpiece);
startSpeakerTest
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| filePath | string |
是 | 测试音频文件路径 |
示例
const { startSpeakerTest } = useDeviceState();
// 开始扬声器测试
await startSpeakerTest({ filePath: '/path/to/test-audio.mp3' });
stopSpeakerTest
示例
const { stopSpeakerTest } = useDeviceState();
// 停止扬声器测试
await stopSpeakerTest();
setOutputVolume
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| volume | number |
是 | 音量大小(0-100) |
示例
const { setOutputVolume } = useDeviceState();
// 设置播放音量为60%
await setOutputVolume(60);
openLocalCamera
示例
const { openLocalCamera } = useDeviceState();
// 开启摄像头
try {
await openLocalCamera();
console.log('摄像头开启成功');
} catch (error) {
console.error('摄像头开启失败:', error);
}
closeLocalCamera
示例
const { closeLocalCamera } = useDeviceState();
// 关闭摄像头
await closeLocalCamera();
getCameraList
示例
const { getCameraList, cameraList } = useDeviceState();
// 获取摄像头列表
try {
await getCameraList();
console.log('摄像头列表:', cameraList.value);
} catch (error) {
console.error('获取摄像头列表失败:', error);
}
setCurrentCamera
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| deviceId | string |
是 | 要切换到的摄像头设备ID |
示例
const { setCurrentCamera } = useDeviceState();
// 切换摄像头设备
await setCurrentCamera({ deviceId: 'camera-device-id' });
switchCamera
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| isFrontCamera | boolean |
是 | 是否切换到前置摄像头 |
示例
const { switchCamera } = useDeviceState();
// 切换到前置摄像头
await switchCamera({ isFrontCamera: true });
// 切换到后置摄像头
await switchCamera({ isFrontCamera: false });
switchMirror
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| mirror | MirrorType |
是 | 镜像类型(自动、启用、禁用) |
示例
const { switchMirror } = useDeviceState();
// 启用镜像
await switchMirror({ mirror: MirrorType.Enable });
// 禁用镜像
await switchMirror({ mirror: MirrorType.Disable });
// 自动镜像
await switchMirror({ mirror: MirrorType.Auto });
updateVideoQuality
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| quality | VideoQuality |
是 | 视频质量(360P、540P、720P、1080P) |
示例
const { updateVideoQuality } = useDeviceState();
// 设置为720P
await updateVideoQuality({ quality: VideoQuality.Quality720P });
// 设置为1080P
await updateVideoQuality({ quality: VideoQuality.Quality1080P });
startCameraTest
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| view | string |
是 | 显示摄像头画面的视图ID |
示例
const { startCameraTest } = useDeviceState();
// 开始摄像头测试
try {
await startCameraTest({ view: 'camera-preview' });
console.log('摄像头测试开始');
} catch (error) {
console.error('摄像头测试失败:', error);
}
stopCameraTest
示例
const { stopCameraTest } = useDeviceState();
// 停止摄像头测试
await stopCameraTest();
FreeBeautyState
响应式数据
beautyConfig
Ref<FreeBeautyConfig>
属性
| 属性名 | 类型 | 描述 |
|---|---|---|
| beautyLevel | number |
磨皮级别,取值范围 0-100 |
| whitenessLevel | number |
美白级别,取值范围 0-100 |
| ruddinessLevel | number |
红润级别,取值范围 0-100 |
示例
import { watch } from 'vue';
import { useFreeBeautyState } from 'tuikit-atomicx-vue3';
const { beautyConfig } = useFreeBeautyState();
// 监听数据变化
watch(beautyConfig, (newValue) => {
console.log('beautyConfig 已更新:', newValue);
});
// 直接访问数据
console.log('当前 beautyConfig:', beautyConfig.value);
接口函数
setFreeBeauty
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| beautyLevel | number |
是 | 磨皮级别,取值范围 0-100 |
| whitenessLevel | number |
是 | 美白级别,取值范围 0-100 |
| ruddinessLevel | number |
是 | 红润级别,取值范围 0-100 |
示例
import { useFreeBeautyState } from 'tuikit-atomicx-vue3';
const { setFreeBeauty } = useFreeBeautyState();
// 调用函数
await setFreeBeauty({
beautyLevel: 50,
whitenessLevel: 30,
ruddinessLevel: 20,
});
saveBeautySetting
示例
import { useFreeBeautyState } from 'tuikit-atomicx-vue3';
const { saveBeautySetting } = useFreeBeautyState();
// 调用函数
await saveBeautySetting();
LiveAudienceState
管理直播房间中的观众状态,包括观众列表、观众数量、管理员操作和事件订阅等功能
响应式数据
audienceList
AudienceInfo[]
示例
import { watch } from 'vue';
import { useLiveAudienceState } from 'tuikit-atomicx-vue3';
const { audienceList } = useLiveAudienceState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => audienceList.value, (newValue) => {
console.log('audienceList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => audienceList.value?.length, (newLength, oldLength) => {
console.log('audienceList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 audienceList:', audienceList.value);
audienceCount
number
示例
import { watch } from 'vue';
import { useLiveAudienceState } from 'tuikit-atomicx-vue3';
const { audienceCount } = useLiveAudienceState();
// 监听数据变化
watch(audienceCount, (newValue) => {
console.log('audienceCount 已更新:', newValue);
});
// 直接访问数据
console.log('当前 audienceCount:', audienceCount.value);
接口函数
fetchAudienceList
示例
const { fetchAudienceList, audienceList } = useLiveAudienceState();
// 获取观众列表
try {
const list = await fetchAudienceList();
console.log('观众列表:', list);
} catch (error) {
console.error('获取观众列表失败:', error);
}
setAdministrator
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 用户ID |
示例
const { setAdministrator } = useLiveAudienceState();
// 设置用户为管理员
await setAdministrator({ userId: 'user123' });
revokeAdministrator
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 用户ID |
示例
const { revokeAdministrator } = useLiveAudienceState();
// 撤销用户管理员权限
await revokeAdministrator({ userId: 'user123' });
kickUserOutOfRoom
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 用户ID |
示例
const { kickUserOutOfRoom } = useLiveAudienceState();
// 将用户踢出房间
await kickUserOutOfRoom({ userId: 'user123' });
disableSendMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 用户ID |
| isDisable | boolean |
是 | 是否禁用消息发送 |
示例
const { disableSendMessage } = useLiveAudienceState();
// 禁用用户发送消息
await disableSendMessage({ userId: 'user123', isDisable: true });
// 启用用户发送消息
await disableSendMessage({ userId: 'user123', isDisable: false });
subscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | LiveAudienceEvent |
是 | 要订阅的事件类型 |
| callback | Function |
是 | 事件回调函数 |
示例
const { subscribeEvent } = useLiveAudienceState();
// 订阅观众加入事件
subscribeEvent(LiveAudienceEvent.onAudienceJoined, (eventInfo) => {
console.log('观众加入:', eventInfo.audience);
});
unsubscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | LiveAudienceEvent |
是 | 要取消订阅的事件类型 |
| callback | Function |
是 | 要移除的事件回调函数 |
示例
const { unsubscribeEvent } = useLiveAudienceState();
// 定义回调函数
const handleAudienceJoined = (eventInfo) => {
console.log('观众加入:', eventInfo.audience);
};
// 取消订阅观众加入事件
unsubscribeEvent(LiveAudienceEvent.onAudienceJoined, handleAudienceJoined);
LoginState
响应式数据
loginUserInfo
Ref<LoginUserInfo | null>
示例
import { watch } from 'vue';
import { useLoginState } from 'tuikit-atomicx-vue3';
const { loginUserInfo } = useLoginState();
// 监听数据变化
watch(loginUserInfo, (newValue) => {
console.log('loginUserInfo 已更新:', newValue);
});
// 直接访问数据
console.log('当前 loginUserInfo:', loginUserInfo.value);
logout
Ref<unknown>
示例
import { watch } from 'vue';
import { useLoginState } from 'tuikit-atomicx-vue3';
const { logout } = useLoginState();
// 监听数据变化
watch(logout, (newValue) => {
console.log('logout 已更新:', newValue);
});
// 直接访问数据
console.log('当前 logout:', logout.value);
接口函数
login
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 用户ID |
| userSig | string |
是 | 用户签名 |
| sdkAppId | number |
是 | SDK应用ID |
示例
await login({
userId: 'user123',
userSig: 'signature',
sdkAppId: 123456
});
setSelfInfo
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userName | string |
否 | 用户昵称 |
| avatarUrl | string |
否 | 用户头像URL |
| customInfo | Record<string, any> |
否 | 自定义信息 |
示例
await setSelfInfo({
userName: '新昵称',
avatarUrl: 'https://example.com/avatar.jpg',
customInfo: { level: 5 }
});
MessageListState
管理聊天消息列表的状态和操作,包括消息加载、滚动控制、已读回执、消息高亮等功能
响应式数据
activeConversationID
Ref<string | undefined>
示例
import { watch } from 'vue';
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { activeConversationID } = useMessageListState();
// 监听数据变化
watch(activeConversationID, (newValue) => {
console.log('activeConversationID 已更新:', newValue);
});
// 直接访问数据
console.log('当前 activeConversationID:', activeConversationID.value);
messageList
Ref<readonly MessageModel[] | undefined>
示例
import { watch } from 'vue';
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { messageList } = useMessageListState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => messageList.value, (newValue) => {
console.log('messageList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => messageList.value?.length, (newLength, oldLength) => {
console.log('messageList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 messageList:', messageList.value);
hasMoreOlderMessage
Ref<boolean | undefined>
示例
import { watch } from 'vue';
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { hasMoreOlderMessage } = useMessageListState();
// 监听数据变化
watch(hasMoreOlderMessage, (newValue) => {
console.log('hasMoreOlderMessage 已更新:', newValue);
});
// 直接访问数据
console.log('当前 hasMoreOlderMessage:', hasMoreOlderMessage.value);
hasMoreNewerMessage
Ref<boolean | undefined>
示例
import { watch } from 'vue';
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { hasMoreNewerMessage } = useMessageListState();
// 监听数据变化
watch(hasMoreNewerMessage, (newValue) => {
console.log('hasMoreNewerMessage 已更新:', newValue);
});
// 直接访问数据
console.log('当前 hasMoreNewerMessage:', hasMoreNewerMessage.value);
enableReadReceipt
Ref<boolean | undefined>
示例
import { watch } from 'vue';
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { enableReadReceipt } = useMessageListState();
// 监听数据变化
watch(enableReadReceipt, (newValue) => {
console.log('enableReadReceipt 已更新:', newValue);
});
// 直接访问数据
console.log('当前 enableReadReceipt:', enableReadReceipt.value);
isDisableScroll
Ref<boolean | undefined>
示例
import { watch } from 'vue';
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { isDisableScroll } = useMessageListState();
// 监听数据变化
watch(isDisableScroll, (newValue) => {
console.log('isDisableScroll 已更新:', newValue);
});
// 直接访问数据
console.log('当前 isDisableScroll:', isDisableScroll.value);
recalledMessageIDSet
Ref<Set<string>>
示例
import { watch } from 'vue';
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { recalledMessageIDSet } = useMessageListState();
// 监听数据变化
watch(recalledMessageIDSet, (newValue) => {
console.log('recalledMessageIDSet 已更新:', newValue);
});
// 直接访问数据
console.log('当前 recalledMessageIDSet:', recalledMessageIDSet.value);
highlightMessageIDSet
Ref<Set<string>>
示例
import { watch } from 'vue';
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { highlightMessageIDSet } = useMessageListState();
// 监听数据变化
watch(highlightMessageIDSet, (newValue) => {
console.log('highlightMessageIDSet 已更新:', newValue);
});
// 直接访问数据
console.log('当前 highlightMessageIDSet:', highlightMessageIDSet.value);
接口函数
loadMoreOlderMessage
示例
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { loadMoreOlderMessage } = useMessageListState();
// 调用函数
await loadMoreOlderMessage();
loadMoreNewerMessage
示例
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { loadMoreNewerMessage } = useMessageListState();
// 调用函数
await loadMoreNewerMessage();
setEnableReadReceipt
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| enableReadReceipt | boolean | undefined |
是 | 是否启用已读回执,true 启用,false 禁用 |
示例
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { setEnableReadReceipt } = useMessageListState();
// 调用函数
await setEnableReadReceipt({ enableReadReceipt: /* boolean | undefined */ });
setIsDisableScroll
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| isDisableScroll | boolean |
是 | 是否禁用滚动,true 禁用,false 启用 |
示例
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { setIsDisableScroll } = useMessageListState();
// 调用函数
await setIsDisableScroll({ isDisableScroll: true });
highlightMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| messageID | string |
是 | 要高亮的消息ID |
| duration | number |
是 | 高亮持续时间(毫秒) |
示例
import { useMessageListState } from 'tuikit-atomicx-vue3';
const { highlightMessage } = useMessageListState();
// 调用函数
await highlightMessage({
messageID: 'example_messageID',
duration: 0,
});
RoomParticipantState
响应式数据
participantList
Ref<RoomParticipant[]>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { participantList } = useRoomParticipantState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => participantList.value, (newValue) => {
console.log('participantList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => participantList.value?.length, (newLength, oldLength) => {
console.log('participantList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 participantList:', participantList.value);
participantListCursor
Ref<string>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { participantListCursor } = useRoomParticipantState();
// 监听数据变化
watch(participantListCursor, (newValue) => {
console.log('participantListCursor 已更新:', newValue);
});
// 直接访问数据
console.log('当前 participantListCursor:', participantListCursor.value);
adminList
Ref<RoomUser[]>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { adminList } = useRoomParticipantState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => adminList.value, (newValue) => {
console.log('adminList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => adminList.value?.length, (newLength, oldLength) => {
console.log('adminList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 adminList:', adminList.value);
audienceList
Ref<RoomUser[]>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { audienceList } = useRoomParticipantState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => audienceList.value, (newValue) => {
console.log('audienceList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => audienceList.value?.length, (newLength, oldLength) => {
console.log('audienceList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 audienceList:', audienceList.value);
audienceListCursor
Ref<string>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { audienceListCursor } = useRoomParticipantState();
// 监听数据变化
watch(audienceListCursor, (newValue) => {
console.log('audienceListCursor 已更新:', newValue);
});
// 直接访问数据
console.log('当前 audienceListCursor:', audienceListCursor.value);
messageDisabledUserList
Ref<RoomUser[]>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { messageDisabledUserList } = useRoomParticipantState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => messageDisabledUserList.value, (newValue) => {
console.log('messageDisabledUserList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => messageDisabledUserList.value?.length, (newLength, oldLength) => {
console.log('messageDisabledUserList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 messageDisabledUserList:', messageDisabledUserList.value);
participantListWithVideo
Ref<RoomParticipant[]>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { participantListWithVideo } = useRoomParticipantState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => participantListWithVideo.value, (newValue) => {
console.log('participantListWithVideo 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => participantListWithVideo.value?.length, (newLength, oldLength) => {
console.log('participantListWithVideo 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 participantListWithVideo:', participantListWithVideo.value);
participantWithScreen
Ref<RoomParticipant | null>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { participantWithScreen } = useRoomParticipantState();
// 监听数据变化
watch(participantWithScreen, (newValue) => {
console.log('participantWithScreen 已更新:', newValue);
});
// 直接访问数据
console.log('当前 participantWithScreen:', participantWithScreen.value);
localParticipant
Ref<RoomParticipant | null>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { localParticipant } = useRoomParticipantState();
// 监听数据变化
watch(localParticipant, (newValue) => {
console.log('localParticipant 已更新:', newValue);
});
// 直接访问数据
console.log('当前 localParticipant:', localParticipant.value);
pendingDeviceApplications
Ref<DeviceRequestInfo[]>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { pendingDeviceApplications } = useRoomParticipantState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => pendingDeviceApplications.value, (newValue) => {
console.log('pendingDeviceApplications 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => pendingDeviceApplications.value?.length, (newLength, oldLength) => {
console.log('pendingDeviceApplications 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 pendingDeviceApplications:', pendingDeviceApplications.value);
pendingDeviceInvitations
Ref<DeviceRequestInfo[]>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { pendingDeviceInvitations } = useRoomParticipantState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => pendingDeviceInvitations.value, (newValue) => {
console.log('pendingDeviceInvitations 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => pendingDeviceInvitations.value?.length, (newLength, oldLength) => {
console.log('pendingDeviceInvitations 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 pendingDeviceInvitations:', pendingDeviceInvitations.value);
speakingUsers
Ref<Map<string, number>>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { speakingUsers } = useRoomParticipantState();
// 监听数据变化
watch(speakingUsers, (newValue) => {
console.log('speakingUsers 已更新:', newValue);
});
// 直接访问数据
console.log('当前 speakingUsers:', speakingUsers.value);
networkQualities
Ref<Map<string, NetworkInfo>>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { networkQualities } = useRoomParticipantState();
// 监听数据变化
watch(networkQualities, (newValue) => {
console.log('networkQualities 已更新:', newValue);
});
// 直接访问数据
console.log('当前 networkQualities:', networkQualities.value);
pendingParticipantList
Ref<RoomParticipant[]>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { pendingParticipantList } = useRoomParticipantState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => pendingParticipantList.value, (newValue) => {
console.log('pendingParticipantList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => pendingParticipantList.value?.length, (newLength, oldLength) => {
console.log('pendingParticipantList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 pendingParticipantList:', pendingParticipantList.value);
searchUser
Ref<unknown>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { searchUser } = useRoomParticipantState();
// 监听数据变化
watch(searchUser, (newValue) => {
console.log('searchUser 已更新:', newValue);
});
// 直接访问数据
console.log('当前 searchUser:', searchUser.value);
promoteToParticipant
Ref<unknown>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { promoteToParticipant } = useRoomParticipantState();
// 监听数据变化
watch(promoteToParticipant, (newValue) => {
console.log('promoteToParticipant 已更新:', newValue);
});
// 直接访问数据
console.log('当前 promoteToParticipant:', promoteToParticipant.value);
demoteToAudience
Ref<unknown>
示例
import { watch } from 'vue';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { demoteToAudience } = useRoomParticipantState();
// 监听数据变化
watch(demoteToAudience, (newValue) => {
console.log('demoteToAudience 已更新:', newValue);
});
// 直接访问数据
console.log('当前 demoteToAudience:', demoteToAudience.value);
接口函数
getParticipantList
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| cursor | string |
否 | =''] - 分页游标,首次获取传空字符串或不传,后续传入上次返回的 cursor |
示例
import { useRoomParticipantState } from '@tuikit-atomicx-vue3/room';
const { participantList, getParticipantList } = useRoomParticipantState();
// 获取房间参与者列表
try {
const { participantList, cursor } = await getParticipantList({ cursor: '' });
console.log('参与者列表:', participantList);
console.log('下一页游标:', cursor);
} catch (error) {
console.error('获取参与者列表失败:', error);
}
getAudienceList
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| cursor | string |
否 | =''] - 分页游标,首次获取传空字符串或不传,后续传入上次返回的 cursor |
示例
import { useRoomParticipantState } from '@tuikit-atomicx-vue3/room';
const { audienceList, getAudienceList } = useRoomParticipantState();
// 获取房间观众列表
try {
const { audienceList, cursor } = await getAudienceList({ cursor: '' });
console.log('观众列表:', audienceList);
console.log('下一页游标:', cursor);
} catch (error) {
console.error('获取观众列表失败:', error);
}
transferOwner
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 目标用户ID,将成为新的房间所有者 |
示例
import { useRoomParticipantState } from '@tuikit-atomicx-vue3/room';
const { transferOwner } = useRoomParticipantState();
// 转移房间所有者权限
try {
await transferOwner({ userId: 'user123' });
console.log('房间所有者权限转移成功');
} catch (error) {
console.log('房间所有者权限转移失败:', error);
}
setAdmin
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 目标用户ID |
示例
import { useRoomParticipantState } from '@tuikit-atomicx-vue3/room';
const { setAdmin } = useRoomParticipantState();
// 设置用户为管理员
try {
await setAdmin({ userId: 'user123' });
console.log('用户设置为管理员成功');
} catch (error) {
console.error('设置管理员失败:', error);
}
revokeAdmin
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 目标用户ID |
示例
import { useRoomParticipantState } from '@tuikit-atomicx-vue3/room';
const { revokeAdmin } = useRoomParticipantState();
// 撤销用户管理员权限
try {
await revokeAdmin({ userId: 'user123' });
console.log('管理员权限撤销成功');
} catch (error) {
console.error('撤销权限失败:', error);
}
kickParticipant
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 要踢出的用户ID |
示例
import { useRoomParticipantState } from '@tuikit-atomicx-vue3/room';
const { kickParticipant } = useRoomParticipantState();
// 踢出参与者
try {
await kickParticipant({ userId: 'user123' });
console.log('用户踢出成功');
} catch (error) {
console.error('踢出用户失败:', error);
}
updateParticipantNameCard
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 目标用户ID |
| nameCard | string |
是 | 新的名片内容 |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { updateParticipantNameCard } = useRoomParticipantState();
// 调用函数
await updateParticipantNameCard({
userId: 'user_001',
nameCard: '我的名片',
});
updateParticipantMetaData
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 目标用户ID |
| metaData | Record<string, string> |
是 | 自定义元数据键值对 |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { updateParticipantMetaData } = useRoomParticipantState();
// 调用函数
await updateParticipantMetaData({
userId: 'user_001',
metaData: { key: 'value' },
});
closeParticipantDevice
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 目标用户ID |
| deviceType | DeviceType |
是 | 要关闭的设备类型(Camera/Microphone/ScreenShare) |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { closeParticipantDevice } = useRoomParticipantState();
// 调用函数
await closeParticipantDevice({
userId: 'user_001',
deviceType: 'Camera',
});
muteParticipantMessage
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 目标用户ID |
| mute | boolean |
是 | true 表示禁言,false 表示解禁 |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { muteParticipantMessage } = useRoomParticipantState();
// 调用函数
await muteParticipantMessage({
userId: 'user_001',
mute: true,
});
disableAllDevices
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| deviceType | DeviceType |
是 | 要禁用的设备类型(Camera/Microphone/ScreenShare) |
| disable | boolean |
是 | true 表示禁用,false 表示启用 |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { disableAllDevices } = useRoomParticipantState();
// 调用函数
await disableAllDevices({
deviceType: 'Camera',
disable: true,
});
disableAllMessages
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| disable | boolean |
是 | true 表示禁用(全体禁言),false 表示启用 |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { disableAllMessages } = useRoomParticipantState();
// 调用函数
await disableAllMessages({
disable: true,
});
requestToOpenDevice
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| device | DeviceType |
是 | 要申请开启的设备类型(Camera/Microphone/ScreenShare) |
| timeout | number |
否 | =60] - 申请超时时间(秒),默认 60 秒 |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { requestToOpenDevice } = useRoomParticipantState();
// 调用函数
await requestToOpenDevice({
device: 'Camera',
timeout: 30,
});
cancelOpenDeviceRequest
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| device | DeviceType |
是 | 要取消申请的设备类型(Camera/Microphone/ScreenShare) |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { cancelOpenDeviceRequest } = useRoomParticipantState();
// 调用函数
await cancelOpenDeviceRequest({
device: 'Camera',
});
approveOpenDeviceRequest
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| device | DeviceType |
是 | 申请的设备类型(Camera/Microphone/ScreenShare) |
| userId | string |
是 | 申请者的用户 Id |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { approveOpenDeviceRequest } = useRoomParticipantState();
// 调用函数
await approveOpenDeviceRequest({
device: 'Camera',
userId: 'user_001',
});
rejectOpenDeviceRequest
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| device | DeviceType |
是 | 申请的设备类型(Camera/Microphone/ScreenShare) |
| userId | string |
是 | 申请者的用户ID |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { rejectOpenDeviceRequest } = useRoomParticipantState();
// 调用函数
await rejectOpenDeviceRequest({
device: 'Camera',
userId: 'user_001',
});
inviteToOpenDevice
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 被邀请者的用户ID |
| device | DeviceType |
是 | 邀请开启的设备类型(Camera/Microphone/ScreenShare) |
| timeout | number |
否 | =0] - 邀请超时时间(秒),0表示不超时 |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { inviteToOpenDevice } = useRoomParticipantState();
// 调用函数
await inviteToOpenDevice({
userId: 'user_001',
device: 'Camera',
timeout: 30,
});
cancelOpenDeviceInvitation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 被邀请者的用户ID |
| device | DeviceType |
是 | 邀请的设备类型(Camera/Microphone/ScreenShare) |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { cancelOpenDeviceInvitation } = useRoomParticipantState();
// 调用函数
await cancelOpenDeviceInvitation({
userId: 'user_001',
device: 'Camera',
});
acceptOpenDeviceInvitation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 邀请者的用户ID |
| device | DeviceType |
是 | 邀请的设备类型(Camera/Microphone/ScreenShare) |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { acceptOpenDeviceInvitation } = useRoomParticipantState();
// 调用函数
await acceptOpenDeviceInvitation({
userId: 'user_001',
device: 'Camera',
});
declineOpenDeviceInvitation
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 邀请者的用户ID |
| device | DeviceType |
是 | 邀请的设备类型(Camera/Microphone/ScreenShare) |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { declineOpenDeviceInvitation } = useRoomParticipantState();
// 调用函数
await declineOpenDeviceInvitation({
userId: 'user_001',
device: 'Camera',
});
muteMicrophone
示例
// 打开麦克风但不向远端推音频流(常用于会议场景下短暂静音场景)
import { useDeviceState } from 'tuikit-atomicx-vue3/room';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3/room';
const { openLocalMicrophone } = useDeviceState();
const { muteMicrophone, unmuteMicrophone } = useRoomParticipantState();
await openLocalMicrophone();
await muteMicrophone();
unmuteMicrophone
示例
import { useDeviceState } from 'tuikit-atomicx-vue3/room';
import { useRoomParticipantState } from 'tuikit-atomicx-vue3/room';
const { openLocalMicrophone } = useDeviceState();
const { muteMicrophone, unmuteMicrophone } = useRoomParticipantState();
await openLocalMicrophone();
await unmuteMicrophone();
subscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | RoomParticipantEvent |
是 | 要订阅的事件名称,可选值包括: |
| callback | Function |
是 | 事件回调函数,参数类型根据事件类型而定 |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { subscribeEvent } = useRoomParticipantState();
// 调用函数
await subscribeEvent({ event: /* RoomParticipantEvent */, callback: /* Function */ });
unsubscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | RoomParticipantEvent |
是 | 要取消订阅的事件名称 |
| callback | Function |
是 | 之前订阅时传入的回调函数(必须是同一个函数引用) |
示例
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
const { unsubscribeEvent } = useRoomParticipantState();
// 调用函数
await unsubscribeEvent({ event: /* RoomParticipantEvent */, callback: /* Function */ });
RoomState
响应式数据
scheduledRoomList
Ref<RoomInfo[]>
示例
import { watch } from 'vue';
import { useRoomState } from 'tuikit-atomicx-vue3';
const { scheduledRoomList } = useRoomState();
// 方式一:使用 getter 函数监听(推荐,可检测引用变化)
watch(() => scheduledRoomList.value, (newValue) => {
console.log('scheduledRoomList 已更新:', newValue);
});
// 方式二:监听数组长度变化
watch(() => scheduledRoomList.value?.length, (newLength, oldLength) => {
console.log('scheduledRoomList 长度变化:', oldLength, '->', newLength);
});
// 直接访问数据
console.log('当前 scheduledRoomList:', scheduledRoomList.value);
scheduledRoomListCursor
Ref<string>
示例
import { watch } from 'vue';
import { useRoomState } from 'tuikit-atomicx-vue3';
const { scheduledRoomListCursor } = useRoomState();
// 监听数据变化
watch(scheduledRoomListCursor, (newValue) => {
console.log('scheduledRoomListCursor 已更新:', newValue);
});
// 直接访问数据
console.log('当前 scheduledRoomListCursor:', scheduledRoomListCursor.value);
currentRoom
Ref<RoomInfo | null>
示例
import { watch } from 'vue';
import { useRoomState } from 'tuikit-atomicx-vue3';
const { currentRoom } = useRoomState();
// 监听数据变化
watch(currentRoom, (newValue) => {
console.log('currentRoom 已更新:', newValue);
});
// 直接访问数据
console.log('当前 currentRoom:', currentRoom.value);
接口函数
getScheduledRoomList
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| cursor | string |
是 | 分页游标,首次请求传空字符串,后续请求传上次返回的 cursor |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { getScheduledRoomList } = useRoomState();
// 首次加载
const result = await getScheduledRoomList({ cursor: '' });
console.log('预约房间列表:', result.scheduledRoomList);
// 加载下一页
if (result.cursor) {
const nextResult = await getScheduledRoomList({ cursor: result.cursor });
}
getScheduledAttendees
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
| cursor | string |
是 | 分页游标,首次请求传空字符串,后续请求传上次返回的 cursor |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { getScheduledAttendees } = useRoomState();
const result = await getScheduledAttendees({
roomId: 'room_123',
cursor: ''
});
console.log('参会人列表:', result.attendees);
console.log('总人数:', result.totalAttendeesCount);
scheduleRoom
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID,需要保证唯一性 |
| roomName | string |
否 | 房间名称 |
| password | string |
否 | 房间密码 |
| scheduleStartTime | number |
是 | 预约开始时间(Unix 时间戳,单位秒) |
| scheduleEndTime | number |
是 | 预约结束时间(Unix 时间戳,单位秒) |
| reminderSecondsBeforeStart | number |
否 | 开始前提醒时间(单位秒) |
| scheduleAttendees | string[] |
否 | 预约参会人 userId 列表 |
| isAllMicrophoneDisabled | boolean |
否 | 是否全员禁用麦克风 |
| isAllCameraDisabled | boolean |
否 | 是否全员禁用摄像头 |
| isAllScreenShareDisabled | boolean |
否 | 是否全员禁用屏幕共享 |
| isAllMessageDisabled | boolean |
否 | 是否全员禁言 |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { scheduleRoom } = useRoomState();
await scheduleRoom({
roomId: 'room_123',
options: {
roomName: '每周例会',
scheduleStartTime: Math.floor(Date.now() / 1000) + 3600,
scheduleEndTime: Math.floor(Date.now() / 1000) + 7200,
scheduleAttendees: ['user1', 'user2'],
reminderSecondsBeforeStart: 300
}
});
updateScheduledRoom
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { updateScheduledRoom } = useRoomState();
await updateScheduledRoom({
roomId: 'room_123',
options: {
roomName: '每周例会(已更改)',
scheduleStartTime: Math.floor(Date.now() / 1000) + 7200
}
});
addScheduledAttendees
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
| userIdList | string[] |
否 | 要添加的用户 ID 列表 |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { addScheduledAttendees } = useRoomState();
await addScheduledAttendees({
roomId: 'room_123',
userIdList: ['user3', 'user4']
});
removeScheduledAttendees
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
| userIdList | string[] |
否 | 要移除的用户 ID 列表 |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { removeScheduledAttendees } = useRoomState();
await removeScheduledAttendees({
roomId: 'room_123',
userIdList: ['user3']
});
cancelScheduledRoom
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { cancelScheduledRoom } = useRoomState();
await cancelScheduledRoom({ roomId: 'room_123' });
createAndJoinRoom
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID,需要保证唯一性 |
| roomName | string |
否 | 房间名称 |
| password | string |
否 | 房间密码 |
| isAllMicrophoneDisabled | boolean |
否 | 是否全员禁用麦克风 |
| isAllCameraDisabled | boolean |
否 | 是否全员禁用摄像头 |
| isAllScreenShareDisabled | boolean |
否 | 是否全员禁用屏幕共享 |
| isAllMessageDisabled | boolean |
否 | 是否全员禁言 |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { createAndJoinRoom } = useRoomState();
await createAndJoinRoom({
roomId: 'room_123',
options: {
roomName: '技术讨论室',
password: '123456'
}
});
joinRoom
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
| password | string |
否 | 房间密码(如果房间设置了密码则必填) |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { joinRoom } = useRoomState();
// 加入无密码房间
await joinRoom({ roomId: 'room_123' });
// 加入有密码房间
await joinRoom({ roomId: 'room_456', password: '123456' });
leaveRoom
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { leaveRoom } = useRoomState();
await leaveRoom();
endRoom
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { endRoom } = useRoomState();
await endRoom();
updateRoomInfo
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
| roomName | string |
否 | 新的房间名称 |
| password | string |
否 | 新的房间密码 |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { updateRoomInfo } = useRoomState();
await updateRoomInfo({
roomId: 'room_123',
options: {
roomName: '新的房间名称',
password: 'new_password'
}
});
getRoomInfo
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { getRoomInfo } = useRoomState();
const roomInfo = await getRoomInfo({ roomId: 'room_123' });
console.log('房间名称:', roomInfo.roomName);
console.log('房主:', roomInfo.ownerId);
getPendingCalls
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
| cursor | string |
是 | 分页游标,首次请求传空字符串,后续请求传上次返回的 cursor |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { getPendingCalls } = useRoomState();
const result = await getPendingCalls({
roomId: 'room_123',
cursor: ''
});
console.log('待处理呼叫:', result.calls);
callUserToRoom
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
| userIdList | string[] |
否 | 要呼叫的用户 ID 列表 |
| timeout | number |
否 | 呼叫超时时间(单位秒),超时后被呼叫方会收到 onCallTimeout 事件 |
| extensionInfo | string |
否 | 扩展信息,会透传给被呼叫方 |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { callUserToRoom } = useRoomState();
// 呼叫用户加入房间
const result = await callUserToRoom({
roomId: 'room_123',
userIdList: ['user1', 'user2'],
timeout: 30,
extensionInfo: '邀请您参加会议'
});
console.log('呼叫结果:', result);
cancelCall
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
| userIdList | string[] |
否 | 要取消呼叫的用户 ID 列表 |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { cancelCall } = useRoomState();
// 取消呼叫
await cancelCall({
roomId: 'room_123',
userIdList: ['user1', 'user2']
});
acceptCall
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { acceptCall, subscribeEvent } = useRoomState();
// 监听呼叫事件并接受
subscribeEvent('onCallReceived', async (eventInfo) => {
console.log('收到呼叫邀请:', eventInfo);
await acceptCall({ roomId: eventInfo.roomId });
});
rejectCall
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string |
是 | 房间 ID |
| extensionInfo | string |
否 | 扩展信息,会透传给呼叫方(如拒绝原因) |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { rejectCall, subscribeEvent } = useRoomState();
// 监听呼叫事件并拒绝
subscribeEvent('onCallReceived', async (eventInfo) => {
console.log('收到呼叫邀请:', eventInfo);
await rejectCall({
roomId: eventInfo.roomId,
extensionInfo: '当前不方便接听'
});
});
subscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | string |
是 | 事件名称 |
| callback | EventCallback |
是 | 事件回调函数 |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { subscribeEvent } = useRoomState();
// 订阅房间创建事件
subscribeEvent('onRoomCreated', (eventInfo) => {
console.log('房间已创建', eventInfo);
});
// 订阅房间结束事件
subscribeEvent('onRoomEnded', (eventInfo) => {
console.log('房间已结束', eventInfo);
});
// 订阅用户加入房间事件
subscribeEvent('onUserJoined', (eventInfo) => {
console.log('用户加入房间', eventInfo);
});
// 订阅呼叫接收事件
subscribeEvent('onCallReceived', (eventInfo) => {
console.log('收到呼叫邀请', eventInfo);
});
unsubscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | string |
是 | 事件名称 |
| callback | EventCallback |
是 | 事件回调函数 |
示例
import { useRoomState } from 'tuikit-atomicx-vue3';
const { unsubscribeEvent } = useRoomState();
// 定义回调函数
const handleRoomCreated = (eventInfo) => {
console.log('房间已创建', eventInfo);
};
// 取消订阅房间创建事件
unsubscribeEvent('onRoomCreated', handleRoomCreated);
// 取消订阅呼叫接收事件
const handleCallReceived = (eventInfo) => {
console.log('收到呼叫邀请', eventInfo);
};
unsubscribeEvent('onCallReceived', handleCallReceived);
VirtualBackgroundState
管理虚拟背景的状态和操作,包括虚拟背景的初始化、设置、保存等功能
响应式数据
virtualBackgroundConfig
Ref<VirtualBackgroundConfig>
属性
| 属性名 | 类型 | 描述 |
|---|---|---|
| enable | boolean |
是否开启虚拟背景 |
| type | VirtualBackgroundType |
虚拟背景类型,可选值为 'image'、'blur' |
| blurLevel | number |
虚化级别,取值范围 1-10,仅当 type 为 'blur' 时有效 |
示例
import { watch } from 'vue';
import { useVirtualBackgroundState } from 'tuikit-atomicx-vue3';
const { virtualBackgroundConfig } = useVirtualBackgroundState();
// 监听数据变化
watch(virtualBackgroundConfig, (newValue) => {
console.log('virtualBackgroundConfig 已更新:', newValue);
});
// 直接访问数据
console.log('当前 virtualBackgroundConfig:', virtualBackgroundConfig.value);
接口函数
isSupported
示例
import { useVirtualBackgroundState } from 'tuikit-atomicx-vue3';
const { isSupported } = useVirtualBackgroundState();
if (isSupported()) {
// 初始化虚拟背景
}
initVirtualBackground
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| assetsPath | string |
是 | 资源文件路径 |
示例
import { useVirtualBackgroundState } from 'tuikit-atomicx-vue3';
const { initVirtualBackground } = useVirtualBackgroundState();
// 初始化虚拟背景
await initVirtualBackground({
assetsPath: '/path/to/assets'
});
setVirtualBackground
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| enable | boolean |
是 | 是否开启虚拟背景 |
| type | VirtualBackgroundType |
是 | 虚拟背景类型,可选值为 'image'、'blur' |
| blurLevel | number |
是 | 虚化级别,取值范围 1-10,仅当 type 为 'blur' 时有效 |
| imagePath | string |
是 | 自定义背景图片路径,仅当 type 为 'image' 时有效 |
示例
import { useVirtualBackgroundState, VirtualBackgroundType } from 'tuikit-atomicx-vue3';
const { setVirtualBackground } = useVirtualBackgroundState();
// 设置虚拟背景参数
await setVirtualBackground({
enable: true,
type: VirtualBackgroundType.blur,
});
saveVirtualBackground
示例
import { useVirtualBackgroundState } from 'tuikit-atomicx-vue3';
const { saveVirtualBackground } = useVirtualBackgroundState();
// 保存虚拟背景配置
await saveVirtualBackground();
subscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | VirtualBackgroundEvent |
是 | 事件名称 |
| callback | VirtualBackgroundEventCallback |
是 | 事件回调函数 |
示例
import { useVirtualBackgroundState, VirtualBackgroundEvent } from 'tuikit-atomicx-vue3';
const { subscribeEvent } = useVirtualBackgroundState();
// 订阅虚拟背景事件
subscribeEvent(VirtualBackgroundEvent.onAbort, () => {
console.log('虚拟背景发生错误');
});
unsubscribeEvent
参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| event | VirtualBackgroundEvent |
是 | 事件名称 |
| callback | VirtualBackgroundEventCallback |
是 | 事件回调函数 |
示例
import { useVirtualBackgroundState, VirtualBackgroundEvent } from 'tuikit-atomicx-vue3';
const { unsubscribeEvent } = useVirtualBackgroundState();
// 取消订阅虚拟背景事件
unsubscribeEvent(VirtualBackgroundEvent.onAbort, () => {
console.log('虚拟背景发生错误');
});
VirtualBackgroundEvent
*虚拟背景事件列表** 通过 `useVirtualBackgroundState()` 获取状态和 `subscribeEvent` 方法来订阅事件。
事件列表
onAbort
示例
import { useVirtualBackgroundState, VirtualBackgroundEvent } from 'tuikit-atomicx-vue3';
const { subscribeEvent } = useVirtualBackgroundState();
// 监听虚拟背景错误事件
subscribeEvent(VirtualBackgroundEvent.onAbort, () => {
console.log('虚拟背景发生错误,已自动关闭');
// 建议的处理方式:
// 1. 关闭虚拟背景功能
// 2. 提示用户虚拟背景已关闭
// 3. 可选:引导用户重新开启或检查设备兼容性
});
VirtualBackgroundType
虚拟背景类型定义 提供虚拟背景相关的配置、类型和事件定义。
类型定义
VirtualBackgroundType
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| blur | 'blur' |
背景模糊 |
| image | 'image' |
自定义背景图片 |
VirtualBackgroundConfig
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| enable | boolean |
否 | 是否启用虚拟背景 |
| type | VirtualBackgroundType |
否 | 虚拟背景类型 |
| blurLevel | number |
否 | 模糊程度(仅当 type 为 blur 时有效) |
| imagePath | string |
否 | 自定义背景图片路径(仅当 type 为 image 时有效) |
示例
const config: VirtualBackgroundConfig = {
enable: true,
type: VirtualBackgroundType.blur,
blurLevel: 5
};
RoomEvent
*房间事件列表** 通过 `roomState.subscribeEvent(RoomEvent.XXX, handler)` 监听指定的事件。 您可以通过这些事件处理房间生命周期、预约房间通知和呼叫相关事件。 > **注意:** > 事件需要在事件触发之前监听,这样才能收到相应的事件通知。 > 建议在加入房间前完成事件监听,这样才能确保不会漏掉事件通知。
事件列表
onAddedToScheduledRoom
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onAddedToScheduledRoom, ({ roomInfo }) => {
console.log('被添加到预约房间:', roomInfo.roomName);
});
onRemovedFromScheduledRoom
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onRemovedFromScheduledRoom, ({ roomInfo, operator }) => {
console.log(`被 ${operator.userName} 从 ${roomInfo.roomName} 移除`);
});
onScheduledRoomCancelled
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onScheduledRoomCancelled, ({ roomInfo, operator }) => {
console.log(`房间 ${roomInfo.roomName} 被 ${operator.userName} 取消`);
});
onScheduledRoomStartingSoon
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onScheduledRoomStartingSoon, ({ roomInfo }) => {
console.log(`房间 ${roomInfo.roomName} 即将开始!`);
});
onRoomEnded
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onRoomEnded, ({ roomInfo }) => {
console.log(`房间 ${roomInfo.roomName} 已结束`);
});
onCallReceived
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallReceived, ({ roomInfo, call, extensionInfo }) => {
console.log(`${call.caller.userName} 邀请您加入 ${roomInfo.roomName}`);
// 显示接受或拒绝呼叫的 UI
});
onCallCancelled
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallCancelled, ({ roomInfo, call }) => {
console.log(`来自 ${call.caller.userName} 的呼叫已取消`);
});
onCallTimeout
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallTimeout, ({ roomInfo, call }) => {
console.log(`来自 ${call.caller.userName} 的呼叫已超时`);
});
onCallAccepted
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallAccepted, ({ roomInfo, call }) => {
console.log(`${call.callee.userName} 接受了您的呼叫`);
});
onCallRejected
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallRejected, ({ roomInfo, call, reason }) => {
console.log(`${call.callee.userName} 拒绝了您的呼叫: ${reason}`);
});
onCallHandledByOtherDevice
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallHandledByOtherDevice, ({ roomInfo, isAccepted }) => {
console.log(`呼叫已在其他设备上${isAccepted ? '接受' : '拒绝'}`);
});
onCallRevokedByAdmin
示例
import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';
const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallRevokedByAdmin, ({ roomInfo, call, operator }) => {
console.log(`呼叫被管理员 ${operator.userName} 撤销`);
});
RoomType
房间类型定义 提供预约房间和房间呼叫相关的类型定义。
类型定义
RoomType
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| Standard | 1 |
会议类型 |
| Webinar | 2 |
网络研讨会类型 |
RoomStatus
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| Scheduled | 1 |
房间已预约但未开始 |
| Running | 2 |
房间正在进行中 |
RoomCallStatus
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| None | 0 |
无活跃呼叫 |
| Calling | 1 |
呼叫进行中,等待响应 |
| Timeout | 2 |
呼叫超时无响应 |
| Rejected | 3 |
呼叫被被叫方拒绝 |
RoomCallResult
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| Success | 0 |
呼叫发起成功 |
| AlreadyInCalling | 1 |
用户已在呼叫中 |
| AlreadyInRoom | 2 |
用户已在房间中 |
CallRejectReason
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| Rejected | 0 |
用户拒绝呼叫 |
| InOtherRoom | 1 |
用户已在其他房间中 |
RoomUser
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| userId | string |
是 | 用户唯一标识 |
| userName | string |
是 | 用户显示名称 |
| avatarUrl | string |
是 | 用户头像 URL |
示例
const user: RoomUser = {
userId: 'user123',
userName: 'John Doe',
avatarUrl: 'https://example.com/avatar.png'
};
RoomInfo
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId (readonly) | string |
是 | 房间唯一标识 |
| roomType | RoomType |
是 | 房间类型 |
| roomName | string |
是 | 房间显示名称 |
| roomOwner | RoomUser |
是 | 房间所有者/创建者 |
| participantCount (readonly) | number |
否 | 房间嘉宾数量 |
| audienceCount (readonly) | number |
否 | 房间观众数量 |
| createTime (readonly) | number |
否 | 房间创建时间戳 |
| roomStatus (readonly) | RoomStatus |
否 | 房间当前状态 |
| scheduledStartTime | number |
否 | 预约开始时间(毫秒时间戳) |
| scheduledEndTime | number |
否 | 预约结束时间(毫秒时间戳) |
| startReminderInSeconds | number |
否 | 开始前多少秒发送提醒通知 |
| scheduleAttendees | RoomUser[] |
否 | 预约参会用户列表 |
| password | string |
否 | 加入房间的密码 |
| isAllMicrophoneDisabled | boolean |
否 | 是否默认禁用所有麦克风 |
| isAllCameraDisabled | boolean |
否 | 是否默认禁用所有摄像头 |
| isAllScreenShareDisabled | boolean |
否 | 是否禁用屏幕共享 |
| isAllMessageDisabled | boolean |
否 | 是否禁用消息发送 |
示例
const roomInfo: RoomInfo = {
roomId: 'room123',
roomName: 'Team Meeting',
roomOwner: { userId: 'user1', userName: 'Host', avatarUrl: '' },
participantCount: 5,
roomStatus: RoomStatus.Running
};
RoomCall
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| caller | RoomUser |
是 | 发起呼叫的用户 |
| callee | RoomUser |
是 | 被呼叫的用户 |
| status | RoomCallStatus |
否 | 呼叫的当前状态 |
示例
const call: RoomCall = {
caller: { userId: 'host', userName: 'Host User', avatarUrl: '' },
callee: { userId: 'guest', userName: 'Guest User', avatarUrl: '' },
status: RoomCallStatus.Calling
};
ScheduleRoomOptions
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomName | string |
否 | 房间显示名称 |
| password | string |
否 | 加入房间的密码 |
| scheduleStartTime | number |
是 | 预约开始时间(毫秒时间戳) |
| scheduleEndTime | number |
是 | 预约结束时间(毫秒时间戳) |
| reminderSecondsBeforeStart | number |
否 | 开始前多少秒发送提醒通知 |
| scheduleAttendees | string[] |
否 | 邀请的用户 ID 列表 |
| isAllMicrophoneDisabled | boolean |
否 | 是否默认禁用所有麦克风 |
| isAllCameraDisabled | boolean |
否 | 是否默认禁用所有摄像头 |
| isAllScreenShareDisabled | boolean |
否 | 是否禁用屏幕共享 |
| isAllMessageDisabled | boolean |
否 | 是否禁用消息发送 |
示例
const options: ScheduleRoomOptions = {
roomName: 'Weekly Standup',
scheduleStartTime: Date.now() + 3600000,
scheduleEndTime: Date.now() + 7200000,
reminderSecondsBeforeStart: 300,
scheduleAttendees: ['user1', 'user2']
};
CreateRoomOptions
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomName | string |
否 | 房间显示名称 |
| password | string |
否 | 加入房间的密码 |
| isAllMicrophoneDisabled | boolean |
否 | 是否默认禁用所有麦克风 |
| isAllCameraDisabled | boolean |
否 | 是否默认禁用所有摄像头 |
| isAllScreenShareDisabled | boolean |
否 | 是否禁用屏幕共享 |
| isAllMessageDisabled | boolean |
否 | 是否禁用消息发送 |
示例
const options: CreateRoomOptions = {
roomName: 'Quick Meeting',
password: '123456',
isAllMicrophoneDisabled: false
};
UpdateRoomOptions
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomName | string |
否 | 新的房间显示名称 |
| password | string |
否 | 新的房间密码 |
示例
const options: UpdateRoomOptions = {
roomName: 'Updated Meeting Name'
};
ParticipantEvent
事件列表
onParticipantJoined
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onParticipantJoined = (options: { userInfo: RoomUser }) => {
console.log('参与者加入房间:', options.userInfo);
};
subscribeEvent(RoomParticipantEvent.onParticipantJoined, onParticipantJoined);
unsubscribeEvent(RoomParticipantEvent.onParticipantJoined, onParticipantJoined);
onParticipantLeft
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onParticipantLeft = (options: { userInfo: RoomUser }) => {
console.log('参会者离开房间:', options.userInfo);
};
subscribeEvent(RoomParticipantEvent.onParticipantLeft, onParticipantLeft);
unsubscribeEvent(RoomParticipantEvent.onParticipantLeft, onParticipantLeft);
onOwnerChanged
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onOwnerChanged = (options: { newOwner: RoomUser }) => {
console.log('房间所有者变更:', options.newOwner);
};
subscribeEvent(RoomParticipantEvent.onOwnerChanged, onOwnerChanged);
unsubscribeEvent(RoomParticipantEvent.onOwnerChanged, onOwnerChanged);
onAdminSet
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onAdminSet = (options: { userInfo: RoomUser }) => {
console.log('用户被设为管理员:', options.userInfo);
};
subscribeEvent(RoomParticipantEvent.onAdminSet, onAdminSet);
unsubscribeEvent(RoomParticipantEvent.onAdminSet, onAdminSet);
onAdminRevoked
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onAdminRevoked = (options: { userInfo: RoomUser }) => {
console.log('用户管理员权限被撤销:', options.userInfo);
};
subscribeEvent(RoomParticipantEvent.onAdminRevoked, onAdminRevoked);
unsubscribeEvent(RoomParticipantEvent.onAdminRevoked, onAdminRevoked);
onKickedFromRoom
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onKickedFromRoom = (options: { reason: KickedOutOfRoomReason; message: string }) => {
console.log('本地用户被踢出房间:', options.reason, options.message);
};
subscribeEvent(RoomParticipantEvent.onKickedFromRoom, onKickedFromRoom);
unsubscribeEvent(RoomParticipantEvent.onKickedFromRoom, onKickedFromRoom);
onParticipantDeviceClosed
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onParticipantDeviceClosed = (options: { device: DeviceType; operator: RoomUser }) => {
console.log('本地用户媒体设备被关闭:', options.device, options.operator);
};
subscribeEvent(RoomParticipantEvent.onParticipantDeviceClosed, onParticipantDeviceClosed);
unsubscribeEvent(RoomParticipantEvent.onParticipantDeviceClosed, onParticipantDeviceClosed);
onParticipantMessageMuted
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onParticipantMessageMuted = (options: { muted: boolean; operator: RoomUser }) => {
console.log('用户被禁言/解禁:', options.muted, options.operator);
};
subscribeEvent(RoomParticipantEvent.onParticipantMessageMuted, onParticipantMessageMuted);
unsubscribeEvent(RoomParticipantEvent.onParticipantMessageMuted, onParticipantMessageMuted);
onAllDevicesDisabled
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onAllDevicesDisabled = (options: { device: DeviceType; disable: boolean; operator: RoomUser }) => {
console.log('全体参会者媒体设备被禁用/启用:', options.device, options.disable, options.operator);
};
subscribeEvent(RoomParticipantEvent.onAllDevicesDisabled, onAllDevicesDisabled);
unsubscribeEvent(RoomParticipantEvent.onAllDevicesDisabled, onAllDevicesDisabled);
onAllMessagesDisabled
示例
import { useRoomParticipantState, RoomParticipantEvent } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onAllMessagesDisabled = (options: { disable: boolean; operator: RoomUser }) => {
console.log('全体参会者发消息能力被禁用/启用:', options.disable, options.operator);
};
subscribeEvent(RoomParticipantEvent.onAllMessagesDisabled, onAllMessagesDisabled);
unsubscribeEvent(RoomParticipantEvent.onAllMessagesDisabled, onAllMessagesDisabled);
onDeviceRequestReceived
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceRequestReceived = (options: { request: DeviceRequestInfo }) => {
const { deviceType, senderUserName } = options.request;
console.log(`${senderUserName} 申请开启 ${deviceType} 设备`);
};
subscribeEvent(RoomParticipantEvent.onDeviceRequestReceived, onDeviceRequestReceived);
unsubscribeEvent(RoomParticipantEvent.onDeviceRequestReceived, onDeviceRequestReceived);
onDeviceRequestCancelled
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceRequestCancelled = (options: { request: DeviceRequestInfo }) => {
console.log('其他参会者申请开启媒体设备被取消:', options.request);
const { deviceType, senderUserName } = options.request;
console.log(`${senderUserName} 取消申请开启 ${deviceType} 设备被取消`);
};
subscribeEvent(RoomParticipantEvent.onDeviceRequestCancelled, onDeviceRequestCancelled);
unsubscribeEvent(RoomParticipantEvent.onDeviceRequestCancelled, onDeviceRequestCancelled);
onDeviceRequestTimeout
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceRequestTimeout = (options: { request: DeviceRequestInfo }) => {
const { deviceType, senderUserName } = options.request;
console.log(`${senderUserName} 申请开启 ${deviceType} 设备超时`);
};
subscribeEvent(RoomParticipantEvent.onDeviceRequestTimeout, onDeviceRequestTimeout);
unsubscribeEvent(RoomParticipantEvent.onDeviceRequestTimeout, onDeviceRequestTimeout);
onDeviceRequestApproved
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceRequestApproved = (options: { request: DeviceRequestInfo, operator: RoomUser }) => {
const { deviceType } = options.request;
const { userName } = options.operator;
console.log(`${userName} 同意我打开 ${deviceType} 设备`);
};
subscribeEvent(RoomParticipantEvent.onDeviceRequestApproved, onDeviceRequestApproved);
unsubscribeEvent(RoomParticipantEvent.onDeviceRequestApproved, onDeviceRequestApproved);
onDeviceRequestRejected
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceRequestRejected = (options: { request: DeviceRequestInfo }) => {
const { deviceType } = options.request;
const { userName } = options.operator;
console.log(`${userName} 拒绝我打开 ${deviceType} 设备`);
};
subscribeEvent(RoomParticipantEvent.onDeviceRequestRejected, onDeviceRequestRejected);
unsubscribeEvent(RoomParticipantEvent.onDeviceRequestRejected, onDeviceRequestRejected);
onDeviceRequestProcessed
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceRequestProcessed = (options: { request: DeviceRequestInfo; operator: RoomUser }) => {
const { senderUserName, deviceType } = options.request;
const { userName } = options.operator;
console.log(`${senderUserName} 处理了 ${userName} 申请打开 ${deviceType} 设备的请求`);
};
subscribeEvent(RoomParticipantEvent.onDeviceRequestProcessed, onDeviceRequestProcessed);
unsubscribeEvent(RoomParticipantEvent.onDeviceRequestProcessed, onDeviceRequestProcessed);
onDeviceInvitationReceived
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceInvitationReceived = (options: { invitation: DeviceRequestInfo }) => {
const { senderUserName, deviceType } = options.invitation;
console.log(`${senderUserName} 邀请我打开 ${deviceType} 设备`);
};
subscribeEvent(RoomParticipantEvent.onDeviceInvitationReceived, onDeviceInvitationReceived);
unsubscribeEvent(RoomParticipantEvent.onDeviceInvitationReceived, onDeviceInvitationReceived);
onDeviceInvitationCancelled
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceInvitationCancelled = (options: { invitation: DeviceRequestInfo }) => {
const { senderUserName, deviceType } = options.invitation;
console.log(`${senderUserName} 取消邀请我打开 ${deviceType} 设备`);
};
subscribeEvent(RoomParticipantEvent.onDeviceInvitationCancelled, onDeviceInvitationCancelled);
unsubscribeEvent(RoomParticipantEvent.onDeviceInvitationCancelled, onDeviceInvitationCancelled);
onDeviceInvitationTimeout
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceInvitationTimeout = (options: { invitation: DeviceRequestInfo }) => {
const { senderUserName, deviceType } = options.invitation;
console.log(`${senderUserName} 邀请我打开 ${deviceType} 设备的邀请超时`);
};
subscribeEvent(RoomParticipantEvent.onDeviceInvitationTimeout, onDeviceInvitationTimeout);
unsubscribeEvent(RoomParticipantEvent.onDeviceInvitationTimeout, onDeviceInvitationTimeout);
onDeviceInvitationAccepted
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceInvitationAccepted = (options: { invitation: DeviceRequestInfo; operator: RoomUser }) => {
const { deviceType } = options.invitation;
const { userName } = options.operator;
console.log(`${userName} 接受了打开 ${deviceType} 设备的邀请`);
};
subscribeEvent(RoomParticipantEvent.onDeviceInvitationAccepted, onDeviceInvitationAccepted);
unsubscribeEvent(RoomParticipantEvent.onDeviceInvitationAccepted, onDeviceInvitationAccepted);
onDeviceInvitationDeclined
示例
import { useRoomParticipantState, RoomParticipantEvent, DeviceRequestInfo } from '@tuikit-atomicx-vue3/room';
const { subscribeEvent, unsubscribeEvent } = useRoomParticipantState();
const onDeviceInvitationDeclined = (options: { invitation: DeviceRequestInfo }) => {
const { deviceType } = options.invitation;
const { userName } = options.operator;
console.log(`${userName} 拒绝了打开 ${deviceType} 设备的邀请`);
};
subscribeEvent(RoomParticipantEvent.onDeviceInvitationDeclined, onDeviceInvitationDeclined);
unsubscribeEvent(RoomParticipantEvent.onDeviceInvitationDeclined, onDeviceInvitationDeclined);
onUserMessageDisabled
onAudiencePromotedToParticipant
onParticipantDemotedToAudience
ParticipantType
类型定义
RoomParticipantRole
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| Owner | 0 |
房主 |
| Admin | 1 |
管理员 |
| GeneralUser | 2 |
普通用户 |
RoomParticipantStatus
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| None | 'None' |
未定义 |
| Scheduled | 'Scheduled' |
预约房间 |
| InCalling | 'InCalling' |
呼叫中 |
| CallTimeout | 'CallTimeout' |
呼叫超时 |
| CallRejected | 'CallRejected' |
呼叫被拒绝 |
| InRoom | 'InRoom' |
在房间内 |
KickedOutOfRoomReason
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| KickedByAdmin | 'KickedByAdmin' |
被管理员踢出房间 |
| ReplacedByAnotherDevice | 'ReplacedByAnotherDevice' |
被其他设备替换 |
| KickedByServer | 'KickedByServer' |
被服务端踢出 |
| ConnectionTimeout | 'ConnectionTimeout' |
连接超时 |
| InvalidStatusOnReconnect | 'InvalidStatusOnReconnect' |
离线期间态进房状发生变化(被踢出房间或者房间已解散) |
| RoomLimitExceeded | 'RoomLimitExceeded' |
房间人数超过限制 |
VideoStreamType
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| Screen | 'screen' |
屏幕流 |
| Camera | 'camera' |
摄像头流 |
FillMode
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| Fill | 'fill' |
图像铺满屏幕 |
| Fit | 'fit' |
图像长边填满屏幕,短边区域会被填充黑色 |
RoomLayoutTemplate
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| GridLayout | 'gridLayout' |
网格布局 |
| CinemaLayout | 'cinemaLayout' |
顶部拦布局 |
| SidebarLayout | 'sidebarLayout' |
侧边栏布局 |
| MobileLayout | 'MobileLayout' |
移动端布局 |
| FloatMixLayout | 'floatMixLayout' |
浮动混合布局 |
| LiveAudienceLayout | 'liveAudienceLayout' |
观众布局 |
RoomParticipant
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| nameCard | string |
是 | 用户名片 |
| role | RoomParticipantRole |
是 | 用户角色 |
| roomStatus | RoomParticipantStatus |
是 | 用户状态 |
| microphoneStatus | DeviceStatus |
是 | 麦克风状态 |
| cameraStatus | DeviceStatus |
是 | 摄像头状态 |
| screenShareStatus | DeviceStatus |
是 | 屏幕共享状态 |
| isMessageDisabled | boolean |
是 | 是否禁言 |
| metaData | Record<string, string> |
是 | 用户自定义元数据 |
示例
const participant: RoomParticipant = {
userId: 'user123',
userName: 'John Doe',
avatarUrl: 'https://example.com/avatar.jpg',
nameCard: 'John Doe',
role: RoomParticipantRole.GeneralUser,
roomStatus: RoomParticipantStatus.InRoom,
DeviceRequestInfo
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| timestamp | number |
是 | 申请时间戳 |
| senderUserId | string |
是 | 申请者用户ID |
| senderUserName | string |
是 | 申请者用户名 |
| senderNameCard | string |
是 | 申请者昵称 |
| senderAvatarUrl | string |
是 | 申请者头像URL |
| content | string |
是 | 申请内容 |
| deviceType | DeviceType |
是 | 申请设备类型 |
示例
const deviceRequestInfo: DeviceRequestInfo = {
timestamp: 1714339200,
senderUserId: 'user123',
senderUserName: 'John Doe',
senderNameCard: 'John Doe',
senderAvatarUrl: 'https://example.com/avatar.jpg',
content: '申请使用摄像头',
deviceType: DeviceType.Camera,
};
BeautyType
类型定义
TRTCBeautyStyle
枚举值
| 枚举值 | 值 | 描述 |
|---|---|---|
| TRTCBeautyStyleSmooth | 0 |
|
| TRTCBeautyStyleNature | 1 |
FreeBeautyConfig
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| beautyLevel | number |
是 | |
| whitenessLevel | number |
是 | |
| ruddinessLevel | number |
是 |
示例
import { FreeBeautyConfig } from '@tuikit-atomicx-vue3';
const config: FreeBeautyConfig = {
beautyLevel: 0.5,
whitenessLevel: 0.5,
ruddinessLevel: 0.5,
};
AsrEvent
事件列表
onReceiveTranscriberMessage
onRealtimeTranscriberStarted
onRealtimeTranscriberStopped
onRealtimeTranscriberError
AsrType
类型定义
TranscriberMessage
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| segmentId | string |
是 | |
| speakerUserId | string |
是 | |
| sourceText | string |
是 | |
| translationTexts | Map<TranscriberLanguage, string> |
否 | |
| timestamp | number |
是 | |
| isCompleted | boolean |
是 |
示例
import { TranscriberMessage } from '@tuikit-atomicx-vue3';
const message: TranscriberMessage = {
segmentId: '123456789',
speakerUserId: 'user123',
sourceText: 'Hello, world!',
translationTexts: new Map([
['zh', '你好,世界!'],
['en', 'Hello, world!'],
]),
timestamp: 1640995200000,
isCompleted: true,
};
RealtimeTranscriberEventInfoMap
属性
| 属性名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| roomId | string | number |
是 | |
| message | TranscriberMessage |
是 | |
| roomId | string | number |
是 | |
| transcriberRobotId | string |
是 | |
| sourceLanguage | TranscriberLanguage |
是 | |
| roomId | string | number |
是 | |
| transcriberRobotId | string |
是 | |
| roomId | string | number |
是 | |
| transcriberRobotId | string |
是 | |
| error | number |
是 | |
| errorMessage | string |
是 |
示例
import { RealtimeTranscriberEventInfoMap } from 'tuikit-atomicx-vue3';
const eventInfo: RealtimeTranscriberEventInfoMap[RealtimeTranscriberEvent.onReceiveTranscriberMessage] = {
roomId: '123456789',
message: {
segmentId: '123456789',
speakerUserId: 'user123',
sourceText: 'Hello, world!',
translationTexts: new Map([
['zh', '你好,世界!'],
['en', 'Hello, world!'],
]),
timestamp: 1640995200000,
isCompleted: true,
},
};
ASRTools
语音识别工具组件 * 用于在视频会议中显示实时字幕和转录消息列表的语音识别组件。
使用示例
示例
<template>
<Subtitle />
</template>
<script setup>
import { Subtitle } from 'tuikit-atomicx-vue3';
</script>
AudioSettingPanel
音频设置面板组件 * 用于展示音频设置面板,支持自定义视图展示。
组件属性 (Props)
| 属性名 | 类型 | 描述 |
|---|---|---|
| micTestVisible | boolean |
是否显示麦克风测试按钮,默认 true |
| inputVolumeLevelVisible | boolean |
是否显示输入音量等级,默认 true |
| inputVolumeVisible | boolean |
是否支持输入音量设置,默认 true |
| speakerTestVisible | boolean |
是否支持扬声器测试,默认 true |
| outputVolumeVisible | boolean |
是否支持输出音量设置,默认 true |
使用示例
示例
<template>
<AudioSettingPanel />
</template>
<script setup>
import { AudioSettingPanel } from '@tuikit-atomicx-vue3/room';
</script>
<style scoped>
.audio-setting-panel-container {
width: 400px;
height: 300px;
}
</style>
Avatar
头像组件 * 用于展示用户或群组头像,支持图片、文字、在线状态和未读消息徽章等功能。
组件属性 (Props)
| 属性名 | 类型 | 描述 |
|---|---|---|
| src | string |
头像图片 URL |
| size | 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs' | number |
头像尺寸,支持预设尺寸或自定义数值,默认 'md' |
| shape | 'circular' | 'square' | 'rounded' |
头像形状,圆形/方形/圆角,默认 'circular' |
| alt | string |
图片替代文本,也用于生成文字头像 |
| className | string |
自定义类名 |
| style | CSSProperties |
自定义样式 |
| isShowOnlineStatus | boolean |
是否显示在线状态指示器,默认 false |
| isOnline | boolean |
用户是否在线 |
| unreadCount | number |
未读消息数量,为 true 时显示小红点,为数字时显示具体数量 |
| maxUnreadCount | number |
最大未读消息数量,超过时显示 max+,默认 99 |
| isDotUnreadCount | boolean |
是否以小红点形式显示未读消息,默认 false |
组件事件 (Events)
| 事件名 | 回调参数类型 | 描述 |
|---|---|---|
| click | void |
点击头像时触发(通过 onClick prop 传入) |
使用示例
示例
<template>
<Avatar
:src="userAvatar"
size="lg"
shape="circular"
:is-show-online-status="true"
:is-online="true"
:unread-count="5"
@click="handleClick"
/>
</template>
<script setup>
import { Avatar } from 'tuikit-atomicx-vue3';
const userAvatar = 'https://example.com/avatar.png';
function handleClick() {
console.log('Avatar clicked');
}
</script>
FreeBeautyPanel
美颜设置面板组件,用于配置视频通话中的美颜效果,支持磨皮、美白、红润等美颜功能。
组件事件 (Events)
| 事件名 | 回调参数类型 | 描述 |
|---|---|---|
| close | void |
面板关闭时触发,用于通知父组件关闭面板 |
使用示例
示例
<template>
<FreeBeautyPanel
@close="handleClose"
/>
</template>
<script setup>
import { FreeBeautyPanel } from 'tuikit-atomicx-vue3';
function handleClose() {
console.log('Panel closed');
}
</script>
RoomParticipantList
房间参与者列表组件 * 用于展示房间参与者列表,支持分页获取参与者列表,支持搜索参与者,支持呼叫参与者,支持踢出参与者,支持设置参与者为管理员,支持设置参与者为房主等功能。
使用示例
示例
<template>
<div class="room-participant-list-container">
<RoomParticipantList />
</div>
</template>
<script setup>
import { RoomParticipantList, useRoomParticipantState } from '@tuikit-atomicx-vue3/room';
const { participantList, getParticipantList } = useRoomParticipantState();
onMounted(async () => {
await getParticipantList({ cursor: '' });
});
</script>
<style scoped>
.room-participant-list-container {
width: 400px;
height: 100vh;
}
</style>
RoomParticipantView
房间参与者视图组件 * 用于展示房间参与者视频流及屏幕共享流,支持自定义视图展示。 * * @props
组件属性 (Props)
| 属性名 | 类型 | 描述 |
|---|---|---|
| participant | RoomParticipant |
房间参与者 |
| streamType | VideoStreamType |
视频流类型 |
| fillMode | FillMode |
填充模式 |
使用示例
示例
<template>
<div class="room-participant-view-container">
<RoomParticipantView
:participant="participant"
:stream-type="streamType"
/>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { RoomParticipantView, useRoomParticipantState } from '@tuikit-atomicx-vue3/room';
const { getParticipantList, participantListWithVideo } = useRoomParticipantState();
const participant = computed(() => participantListWithVideo.value[0]);
const streamType = VideoStreamType.Camera;
onMounted(async () => {
await getParticipantList({ cursor: '' });
});
</script>
<style scoped>
.room-participant-list-container {
width: 400px;
height: 300px;
}
</style>
RoomView
房间视图组件 * 用于展示房间参与者视频流及屏幕共享流,支持自定义视图展示,支持自定义布局模板。
组件属性 (Props)
| 属性名 | 类型 | 描述 |
|---|---|---|
| layoutTemplate | RoomLayoutTemplate |
布局模板,默认 'RoomLayoutTemplate.GridLayout' |
组件事件 (Events)
| 事件名 | 回调参数类型 | 描述 |
|---|---|---|
| stream | void |
double-click - 有视频流区域被双击时触发,参数为 { participant: RoomParticipant; streamType: VideoStreamType } |
使用示例
示例
<template>
<div class="room-view-container">
<RoomView />
</div>
</template>
<script setup>
import { RoomView } from '@tuikit-atomicx-vue3/room';
import { RoomLayoutTemplate } from '@tuikit-atomicx-vue3/room';
</script>
<style scoped>
.room-view-container {
width: 100vw;
height: 100vh;
}
</style>
ScheduleRoomPanel
预约房间管理组件,用于创建和管理预约房间,支持房间预约、参与者管理、安全设置等功能。
使用示例
示例
<template>
<ScheduledRoomList />
</template>
<script setup>
import { ScheduledRoomList } from 'tuikit-atomicx-vue3';
</script>
VideoSettingPanel
视频设置面板组件 * 用于展示视频设置面板,支持自定义视图展示。
组件属性 (Props)
| 属性名 | 类型 | 描述 |
|---|---|---|
| cameraSelectVisible | boolean |
是否显示摄像头选择,默认 true |
| videoPreviewVisible | boolean |
是否显示视频预览,默认 true |
| videoProfileVisible | boolean |
是否显示视频设置,默认 true |
| switchMirrorVisible | boolean |
是否显示镜像开关,默认 true |
使用示例
示例
<template>
<VideoSettingPanel />
</template>
<script setup>
import { VideoSettingPanel } from '@tuikit-atomicx-vue3/room';
</script>
<style scoped>
.video-setting-panel-container {
width: 400px;
height: 300px;
}
</style>
VirtualBackgroundPanel
虚拟背景设置面板组件 * 用于配置视频通话中的虚拟背景效果,支持背景模糊和自定义背景图片。
组件属性 (Props)
| 属性名 | 类型 | 描述 |
|---|---|---|
| assetsPath | string |
虚拟背景资源文件路径,用于加载虚拟背景所需的模型和图片资源 |
组件事件 (Events)
| 事件名 | 回调参数类型 | 描述 |
|---|---|---|
| close | void |
面板关闭时触发,用于通知父组件关闭面板 |
使用示例
示例
<template>
<VirtualBackgroundPanel
:assets-path="assetsPath"
@close="handleClose"
/>
</template>
<script setup>
import { VirtualBackgroundPanel } from 'tuikit-atomicx-vue3';
const assetsPath = 'https://web.sdk.qcloud.com/hybrid/trtc-sdk-v5/assets';
function handleClose() {
console.log('Panel closed');
}
</script>
Interface
类型定义
LoginUserInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| userId | string | 登录用户的 userId |
| userName | string | 登录用户的 userName |
| avatarUrl | string | 登录用户的头像 URL |
| customInfo | Record<string, any> | 自定义资料信息对象 |
SetSelfInfoParams
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| userName | string | 用户昵称 |
| avatarUrl | string | 用户头像 URL |
| customInfo | Record<string, any> | 可选,自定义信息 |
LoginParams
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| userId | string | 用户ID |
| userSig | string | 用户签名 |
| sdkAppId | number | SDK 应用 ID |
TUIRoomInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| roomId | string | 房间 ID |
| roomName | string | 房间名称,默认为 roomId |
| roomType | TUIRoomType | 房间类型,默认为 TUIRoomType.kConference |
| isSeatEnabled | boolean | 是否开启麦位控制,该属性 2.0.0 版本以后支持,默认为 false |
| seatMode | TUISeatMode | 上麦模式(开启麦位控制后生效),该属性 2.0.0 版本以后支持,默认为 TUISeatMode.kFreeToTake |
| password | string | 房间密码,默认为空字符串,该属性 2.5.0 版本以后支持 |
| isMicrophoneDisableForAllUser | boolean | 是否开启全员禁音(创建房间可选参数,默认值为 false) |
| isScreenShareDisableForAllUser | boolean | 是否开启禁止屏幕分享(创建房间可选参数,该属性自 v2.2.0 版本以后支持,默认值为 false) |
| isCameraDisableForAllUser | boolean | 是否开启全员禁画(创建房间可选参数, 默认值为 false) |
| isMessageDisableForAllUser | boolean | 是否允许所有用户发消息(创建房间可选参数,默认值为 false) |
| maxSeatCount | number | 最大麦位数量,默认为 6 |
| roomOwner | string | 房间主持人ID,只读,v2.4.1 以上建议使用 ownerId |
| ownerId | string | 房间主持人ID,只读,该属性 2.4.1 版本以后支持 |
| ownerName | string | 房间主持人昵称,只读,该属性 2.4.1 版本以后支持 |
| ownerAvatarUrl | string | 房间主持人头像地址,只读,该属性 2.4.1 版本以后支持 |
| createTime | number | 房间创建时间,只读,精确到秒 |
| roomMemberCount | number | 房间成员数量,只读 |
TUIEnterRoomOptions
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| password | string | 房间密码,默认为空,表示没有密码 |
TUISeatLockParams
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| lockSeat | boolean | 锁定麦位 |
| lockVideo | boolean | 锁定麦位视频 |
| lockAudio | boolean | 锁定麦位音频 |
TUIMessage
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| messageId | string | 消息 Id |
| message | string | 消息内容 |
| timestamp | number | 时间戳信息, 精确到秒 |
| userId | string | 用户 Id |
| userName | string | 用户名称 |
| avatarUrl | string | 用户头像地址 |
TUINetwork
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| userId | string | 用户 Id |
| quality | TUINetworkQuality | 网络质量 |
| upLoss | number | 上行丢包率,单位 (%) 该数值越小越好,目前仅本地用户有该信息 |
| downLoss | number | 下行丢包率,单位 (%) 该数值越小越好,目前仅本地用户有该信息 |
| delay | number | 网络延迟,单位 ms,目前仅本地用户有该信息 |
TUIVideoEncoderParams
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| fps | number | 帧率设置 |
| bitrate | number | 目标编码码率设置 |
| quality | TUIVideoQuality | 上行视频分辨率 |
| videoResolution | TUIVideoQuality | 上行视频分辨率(自 v1.6.0 版本开始支持,v1.6.0 之前版本请使用 quality 参数) |
| resolutionMode | TUIResolutionMode | 横竖屏模式 |
TUIUserInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| userId | string | 用户 Id |
| userName | string | 用户名称 |
| nameCard | string | 房间内用户名称,自 v2.5.0 支持 |
| avatarUrl | string | 用户头像地址 |
| userRole | TUIRole | 用户角色 |
| hasAudioStream | boolean | 是否有音频流 |
| hasVideoStream | boolean | 是否有视频流 |
| hasScreenStream | boolean | 是否有屏幕分享流 |
| isMessageDisabled | boolean | 是否被禁止发送消息 |
| roomCustomInfo | object | 用户房间自定义字段 |
TUISeatInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| index | number | 麦位序号 |
| userId | string | 麦位对应的用户 Id |
| userName | string | 用户名称 |
| nameCard | string | 房间内用户名称,自 v2.5.0 支持 |
| avatarUrl | string | 用户头像地址 |
| isLocked | boolean | 当前麦位是否被锁 |
| isVideoLocked | boolean | 当前麦位是否禁止视频 |
| isAudioLocked | boolean | 当前麦位是否禁止音频 |
SeatInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| index | number | 座位索引 |
| isLocked | boolean | 座位是否被锁定 |
| isVideoLocked | boolean | 座位视频是否被锁定 |
| isAudioLocked | boolean | 座位音频是否被锁定 |
| userInfo | SeatUserInfo | undefined | 座位上的用户信息,座位为空时为 undefined |
SeatUserInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| roomId | string | 房间 ID |
| userId | string | 用户 ID |
| userName | string | 用户名称 |
| avatarUrl | string | 用户头像 URL |
| microphoneStatus | DeviceStatus | 麦克风状态 |
| cameraStatus | DeviceStatus | 摄像头状态 |
| onSeatTimestamp | number | 上座时间戳 |
| networkQuality | NetworkQuality | undefined | 网络质量 |
| customInfo | Record<string, any> | 自定义信息 |
TUIRequest
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| requestAction | TUIRequestAction | 请求类型 |
| timestamp | number | 请求发起时间 |
| requestId | string | 请求 ID |
| userId | string | 发起请求的用户 ID |
| userName | string | 用户名称 |
| nameCard | string | 房间内用户名称,自 v2.5.0 支持 |
| avatarUrl | string | 用户头像地址 |
| content | string | 其他内容 |
TUIRequestCallback
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| requestCallbackType | TUIRequestCallbackType | 请求回调类型 |
| requestId | string | 请求 ID |
| userId | string | 用户 Id |
| code | number | 请求响应码 |
| message | string | 请求补充说明 |
TUIDeviceInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| deviceId | string | 设备 Id |
| deviceName | string | 设备名称 |
| deviceProperties | Record<string, any> | 设备属性对象 |
NetworkInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| quality | NetworkQuality | 网络质量等级 |
| upLoss | number | 上行丢包率,单位 (%) |
| downLoss | number | 下行丢包率,单位 (%) |
| delay | number | 网络延迟,单位 ms |
TUIConferenceInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| scheduleStartTime | number | 预定会议开始时间。 |
| scheduleEndTime | number | 预定会议结束时间。 |
| scheduleAttendees | string[] | 邀请参会成员列表。 |
| reminderSecondsBeforeStart | number | 会议开始前提醒时间(秒)。 |
| status | TUIConferenceStatus | 房间状态(只读)。 |
| basicRoomInfo | TUIRoomInfo | 房间信息。 |
TUIConferenceModifyInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| scheduleStartTime | number | 预定会议开始时间 |
| scheduleEndTime | number | 预定会议结束时间 |
| basicRoomInfo | object | 房间基本信息 |
| basicRoomInfo.roomId | string | 房间 ID |
| basicRoomInfo.roomName | string | 房间名称 |
TUIInvitation
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| status | TUIInvitationStatus | 会中邀请状态 |
| invitee | TUIUserInfo | 受邀者 |
| inviter | TUIUserInfo | 邀请者 |
TUILiveInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| basicRoomInfo | TUIRoomInfo | 房间信息,只读 |
| isGiftEnabled | boolean | 直播间是否支持礼物 |
| isLikeEnabled | boolean | 直播间是否支持点赞 |
| isPublicVisible | boolean | 直播间是否公开 |
| activityStatus | number | 直播间活跃状态: 用户自定义标记 |
| viewCount | number | 累计观看次数,只读 |
| coverUrl | string | 直播间封面图片 HTTP URL 地址,最大支持 200 个字节 |
| backgroundUrl | string | 直播间背景图片 HTTP URL 地址,最大支持 200 个字节 |
| categoryList | Array<number> | 直播间分类标签,单个房间最大支持3个标记 |
TUILiveModifyInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| roomId | string | 直播间 ID |
| isPublicVisible | boolean | 可选,直播间是否公开 |
| activityStatus | number | 可选,直播间活跃状态: 用户自定义标记 |
| coverUrl | string | 可选,直播间封面图片 HTTP URL 地址,最大支持 200 个字节 |
| backgroundUrl | string | 可选,直播间背景图片 HTTP URL 地址,最大支持 200 个字节 |
| categoryList | Array<number> | 可选,直播间分类标签,单个房间最大支持3个标记 |
TUILiveModifyFlag
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| kNone | number | 不修改 |
| kActivityStatus | number | 直播间活跃状态,支持自定义设置 |
| kCoverUrl | number | 直播间封面 |
| kCategory | number | 直播间分类 |
| kEnableGift | number | 直播间支持发送礼物标记 |
| kEnableLike | number | 直播支持点赞标记 |
| kPublic | number | 直播间公开标记 |
| kBackgroundUrl | number | 直播间背景 |
AudienceInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| userId | string | 用户 ID |
| userName | string | 用户名称 |
| avatarUrl | string | 用户头像 URL |
| customInfo | Record<string, any> | 自定义信息 |
| userRole | TUIRole | 用户角色 |
| isMessageDisabled | boolean | 是否禁止发送消息 |
LiveUserInfo
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| userId | string | 用户 ID |
| userName | string | 用户名称 |
| avatarUrl | string | 用户头像 URL |
SearchResult
属性列表
| 属性名 | 类型 | 描述 |
|---|---|---|
| resultList | Array<T> | 搜索结果列表 |
| hasMore | boolean | 是否有更多结果 |
| cursor | string | 分页游标 |
| totalCount | number | 总结果数量 |
| params | Record<string, any> | 搜索参数 |