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 - 设备状态管理(摄像头、麦克风、扬声器)

🏠 房间模块

📺 直播模块

🎤 连麦与互动

💬 即时通信模块

⚙️ 设置模块

🎨 高级功能

Event 事件列表

📡 Asr

  • Asr - asr 模块事件定义(4 个事件)

📡 Participant

  • Participant - participant 模块事件定义(24 个事件)

📡 Room

  • Room - room 模块事件定义(12 个事件)

📡 VirtualBackground

Type 类型列表

📋 Asr

  • Asr - asr 模块类型定义(2 个类型)

📋 Beauty

  • Beauty - beauty 模块类型定义(2 个类型)

📋 Participant

  • Participant - participant 模块类型定义(8 个类型)

📋 Room

  • Room - room 模块类型定义(11 个类型)

📋 VirtualBackground

Component 组件列表

🧩 ASRTools

  • ASRTools - 语音识别工具组件 * 用于在视频会议中显示实时字幕和转录消息列表的语音识别组件。

🧩 AudioSettingPanel

  • AudioSettingPanel - 音频设置面板组件 * 用于展示音频设置面板,支持自定义视图展示。

🧩 Avatar

  • Avatar - 头像组件 * 用于展示用户或群组头像,支持图片、文字、在线状态和未读消息徽章等功能。

🧩 FreeBeautyPanel

  • FreeBeautyPanel - 美颜设置面板组件,用于配置视频通话中的美颜效果,支持磨皮、美白、红润等美颜功能。

🧩 RoomParticipantList

  • RoomParticipantList - 房间参与者列表组件 * 用于展示房间参与者列表,支持分页获取参与者列表,支持搜索参与者,支持呼叫参与者,支持踢出参与者,支持设置参与者为管理员,支持设置参与者为房主等功能。

🧩 RoomParticipantView

  • RoomParticipantView - 房间参与者视图组件 * 用于展示房间参与者视频流及屏幕共享流,支持自定义视图展示。 * * @props

🧩 RoomView

  • RoomView - 房间视图组件 * 用于展示房间参与者视频流及屏幕共享流,支持自定义视图展示,支持自定义布局模板。

🧩 ScheduleRoomPanel

  • ScheduleRoomPanel - 预约房间管理组件,用于创建和管理预约房间,支持房间预约、参与者管理、安全设置等功能。

🧩 VideoSettingPanel

  • VideoSettingPanel - 视频设置面板组件 * 用于展示视频设置面板,支持自定义视图展示。

🧩 VirtualBackgroundPanel

  • VirtualBackgroundPanel - 虚拟背景设置面板组件 * 用于配置视频通话中的虚拟背景效果,支持背景模糊和自定义背景图片。

Interface 接口列表

📝 接口定义

LiveListState

响应式数据

currentLive

const currentLive: Ref<LiveInfo | null>
转换TUILiveInfo为LiveInfo格式 将TUIRoomEngine返回的直播信息转换为应用内部使用的LiveInfo格式 @param {TUILiveInfo} liveInfo - TUIRoomEngine返回的直播信息 @returns {LiveInfo} 转换后的直播信息对象
类型: Ref<LiveInfo | null>

示例

const tuiLiveInfo = await roomEngine.getLiveInfo();
const liveInfo = getLiveInfo(tuiLiveInfo);
console.log('转换后的直播信息:', liveInfo);

liveList

const liveList: Ref<any>
直播列表数据,包含所有直播间的信息 存储当前获取到的所有直播间信息列表
类型: Ref<any>

示例

import { useLiveListState } from 'tuikit-atomicx-vue3';

const { liveList } = useLiveListState();

// 监听数据变化
watch(liveList, (newValue) => {
  console.log('liveList 更新:', newValue);
});

// 直接访问数据
console.log('当前 liveList:', liveList.value);

liveListCursor

const liveListCursor: Ref<any>
直播列表分页游标,用于获取下一页数据 用于分页获取直播列表的游标标识
类型: Ref<any>

示例

import { useLiveListState } from 'tuikit-atomicx-vue3';

const { liveListCursor } = useLiveListState();

// 监听数据变化
watch(liveListCursor, (newValue) => {
  console.log('liveListCursor 更新:', newValue);
});

// 直接访问数据
console.log('当前 liveListCursor:', liveListCursor.value);

接口函数

createLive

function createLive(liveParams: CreateLiveParams)
创建直播间 创建一个新的直播间,支持设置直播间名称、封面、背景、麦位模式等配置

参数 (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

function joinLive(joinParams: JoinLiveParams)
加入直播间 通过直播间ID加入指定的直播间

参数 (JoinLiveParams)

参数名 类型 必填 描述
liveId string 直播间ID

示例

import { useLiveListState } from 'tuikit-atomicx-vue3';

const { joinLive } = useLiveListState();

// 通过ID加入直播间
await joinLive({
  liveId: 'live_room_123456'
});

leaveLive

function leaveLive()
离开直播间 退出当前加入的直播间,清空直播间状态

示例

import { useLiveListState } from 'tuikit-atomicx-vue3';

const { leaveLive } = useLiveListState();

// 离开直播间
try {
  await leaveLive();
  console.log('成功离开直播间');
} catch (error) {
  console.error('离开直播间失败:', error);
}

endLive

function endLive()
结束直播 主播结束当前直播,销毁直播间

示例

import { useLiveListState } from 'tuikit-atomicx-vue3';

const { endLive } = useLiveListState();

// 结束直播(主播操作)
try {
  await endLive();
  console.log('直播已结束');
} catch (error) {
  console.error('结束直播失败:', error);
}

updateLiveInfo

function updateLiveInfo(updateParams: UpdateLiveInfoParams)
更新直播间信息 更新直播间的基本信息,如封面、背景、分类等

参数 (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

function queryMetaData(queryParams: { keys: string[] })
查询元数据 查询直播间的自定义元数据信息

参数

参数名 类型 必填 描述
keys string[] 要查询的元数据键名列表

示例

import { useLiveListState } from 'tuikit-atomicx-vue3';

const { queryMetaData } = useLiveListState();

// 通过键查询元数据
await queryMetaData({
  keys: ['roomTitle', 'announcement', 'customData']
});

updateLiveMetaData

function updateLiveMetaData(metaParams: { metaData: Record<string, string> })
更新直播间元数据 更新直播间的自定义元数据

参数

参数名 类型 必填 描述
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

function fetchLiveList(listParams: { category?: string; cursor?: string; count?: number })
获取直播列表 支持分页获取直播列表,可指定游标和数量进行分页查询

参数

参数名 类型 必填 默认值 描述
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

const seatList: Ref<any>
麦位列表,包含所有麦位的状态和用户信息 存储当前直播间的所有麦位信息
类型: Ref<any>

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { seatList } = useLiveSeatState();

// 监听数据变化
watch(seatList, (newValue) => {
  console.log('seatList 更新:', newValue);
});

// 直接访问数据
console.log('当前 seatList:', seatList.value);

canvas

const canvas: Ref<any>
画布配置,用于视频渲染和布局管理 视频渲染的画布配置信息
类型: Ref<any>

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { canvas } = useLiveSeatState();

// 监听数据变化
watch(canvas, (newValue) => {
  console.log('canvas 更新:', newValue);
});

// 直接访问数据
console.log('当前 canvas:', canvas.value);

speakingUsers

const speakingUsers: Ref<any>
正在发言的用户列表 当前正在发言的用户信息列表
类型: Ref<any>

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { speakingUsers } = useLiveSeatState();

// 监听数据变化
watch(speakingUsers, (newValue) => {
  console.log('speakingUsers 更新:', newValue);
});

// 直接访问数据
console.log('当前 speakingUsers:', speakingUsers.value);

networkQualities

const networkQualities: Ref<any>
网络质量信息,包含各用户的网络状态 各用户的网络连接质量信息
类型: Ref<any>

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { networkQualities } = useLiveSeatState();

// 监听数据变化
watch(networkQualities, (newValue) => {
  console.log('networkQualities 更新:', newValue);
});

// 直接访问数据
console.log('当前 networkQualities:', networkQualities.value);

接口函数

takeSeat

function takeSeat(seatParams: { seatIndex: number })
用户上麦 用户申请上到指定麦位,普通用户直接上麦,管理员需要使用其他方式

参数

参数名 类型 必填 描述
seatIndex number 麦位索引

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { takeSeat } = useLiveSeatState();

// 上第1个麦位
await takeSeat({
  seatIndex: 1
});

leaveSeat

function leaveSeat(seatParams: { seatIndex: number })
用户下麦 用户主动离开当前麦位

参数

参数名 类型 必填 描述
seatIndex number 麦位索引

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { leaveSeat } = useLiveSeatState();

// 离开第1个麦位
await leaveSeat({
  seatIndex: 1
});

lockSeat

function lockSeat(lockParams: { seatIndex: number })
锁定麦位 管理员锁定指定麦位,防止用户上麦

参数

参数名 类型 必填 描述
seatIndex number 麦位索引

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { lockSeat } = useLiveSeatState();

// 锁定第2个麦位
await lockSeat({
  seatIndex: 2
});

unLockSeat

function unLockSeat(unlockParams: { seatIndex: number })
解锁麦位 管理员解锁指定麦位,允许用户上麦

参数

参数名 类型 必填 描述
seatIndex number 麦位索引

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { unLockSeat } = useLiveSeatState();

// 解锁第2个麦位
await unLockSeat({
  seatIndex: 2
});

kickUserOutOfSeat

function kickUserOutOfSeat(kickParams: { seatIndex: number; userId: string })
踢用户下麦 管理员强制将指定用户踢下麦位

参数

参数名 类型 必填 描述
seatIndex number 麦位索引
userId string 用户ID

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { kickUserOutOfSeat } = useLiveSeatState();

// 将用户踢下麦位
await kickUserOutOfSeat({
  seatIndex: 1,
  userId: 'user_123'
});

moveUserToSeat

function moveUserToSeat(moveParams: { userId: string; targetIndex: number; policy: MoveSeatPolicy })
移动用户到指定麦位 管理员将用户移动到指定的麦位,支持不同的移动策略

参数

参数名 类型 必填 描述
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

function openRemoteCamera(params: { userId: string; policy: DeviceControlPolicy })
开启远端摄像头 管理员解锁指定用户的摄像头,允许用户开启摄像头

参数

参数名 类型 必填 描述
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

function closeRemoteCamera(params: { userId: string })
关闭远端摄像头 管理员强制关闭指定用户的摄像头

参数

参数名 类型 必填 描述
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

function openRemoteMicrophone(params: { userId: string; policy: DeviceControlPolicy })
开启远端麦克风 管理员解锁指定用户的麦克风,允许用户开启麦克风

参数

参数名 类型 必填 描述
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

function closeRemoteMicrophone(params: { userId: string })
关闭远端麦克风 管理员强制关闭指定用户的麦克风

参数

参数名 类型 必填 描述
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

function muteMicrophone(): Promise<void>
静音本地麦克风 用户静音自己的麦克风

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { muteMicrophone } = useLiveSeatState();

// 静音本地麦克风
await muteMicrophone();
console.log('Microphone muted');

unmuteMicrophone

function unmuteMicrophone(): Promise<void>
取消静音本地麦克风 用户取消静音自己的麦克风

示例

import { useLiveSeatState } from 'tuikit-atomicx-vue3';

const { unmuteMicrophone } = useLiveSeatState();

// 取消静音本地麦克风
await unmuteMicrophone();
console.log('Microphone unmuted');

startPlayStream

function startPlayStream(params: { view: string }): Promise<any>
开始播放流 开始播放麦位的音视频流到指定容器

参数

参数名 类型 必填 描述
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

function stopPlayStream(): Promise<any>
停止播放流 停止播放麦位的音视频流

示例

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

const monitorLiveInfoList: Ref<any>
监控的直播间信息列表 正在监控的直播间信息列表
类型: Ref<any>

示例

import { useLiveMonitorState } from 'tuikit-atomicx-vue3';

const { monitorLiveInfoList } = useLiveMonitorState();

// 监听数据变化
watch(monitorLiveInfoList, (newValue) => {
  console.log('monitorLiveInfoList 更新:', newValue);
});

// 直接访问数据
console.log('当前 monitorLiveInfoList:', monitorLiveInfoList.value);

接口函数

init

function init(config: InitConfig)
初始化直播监控模块 初始化监控配置和播放器管理器,必须在使用其他功能前调用

参数

参数名 类型 必填 描述
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

function getLiveList(page: number, pageSize: number): Promise<MonitorLiveInfo[]>
获取直播列表 分页获取直播间列表,用于监控管理

参数

参数名 类型 必填 描述
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

function closeRoom(liveId: string): Promise<void>
关闭直播间 强制关闭指定的直播间,并从监控列表中移除

参数

参数名 类型 必填 描述
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

function sendMessage(liveId: string, message: MonitorMessage): void
发送监控消息 向指定直播间发送监控消息(一期暂不支持)

参数

参数名 类型 必填 描述
liveId string 直播间ID
message MonitorMessage 要发送的消息

示例

import { useLiveMonitorState } from 'tuikit-atomicx-vue3';

const { sendMessage } = useLiveMonitorState();

// 发送警告消息(暂不支持)
sendMessage('live_123', {
  type: 'warning',
  content: '请遵守直播规范'
});

startPlay

function startPlay(liveId: string, viewId: string): Promise<void>
开始播放直播 开始播放指定直播间的内容,创建播放器并绑定事件监听

参数

参数名 类型 必填 描述
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

function stopPlay(liveId: string): Promise<void>
停止播放直播 停止播放指定直播间的内容,销毁播放器并清理资源

参数

参数名 类型 必填 描述
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

function muteLiveAudio(liveId: string, mute: boolean): Promise<void>
控制直播音频静音 控制指定直播间的音频静音状态

参数

参数名 类型 必填 描述
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

const inputRawValue: Ref<any>
输入框的原始文本内容 消息输入框中的原始文本内容
类型: Ref<any>

示例

import { useMessageInputState } from 'tuikit-atomicx-vue3';

const { inputRawValue } = useMessageInputState();

// 监听数据变化
watch(inputRawValue, (newValue) => {
  console.log('inputRawValue 更新:', newValue);
});

// 直接访问数据
console.log('当前 inputRawValue:', inputRawValue.value);

isPeerTyping

const isPeerTyping: Ref<any>
对方是否正在输入 标识对方用户是否正在输入消息
类型: Ref<any>

示例

import { useMessageInputState } from 'tuikit-atomicx-vue3';

const { isPeerTyping } = useMessageInputState();

// 监听数据变化
watch(isPeerTyping, (newValue) => {
  console.log('isPeerTyping 更新:', newValue);
});

// 直接访问数据
console.log('当前 isPeerTyping:', isPeerTyping.value);

接口函数

updateRawValue

function updateRawValue(value: string | InputContent[]): void
更新输入框原始值 更新消息输入框的原始值,支持文本和结构化内容,同时触发输入状态

参数

参数名类型必填描述
valuestring | 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

function setEditorInstance(instance: Editor | null): void
设置编辑器实例 设置或更新编辑器实例,如果已存在编辑器实例则先销毁再设置新实例

参数

参数名类型必填描述
instanceEditor | null编辑器实例,传入 null 表示清除当前实例

示例

import { useMessageInputState } from 'tuikit-atomicx-vue3';

const { setEditorInstance } = useMessageInputState();

// 设置编辑器实例
setEditorInstance(editorInstance);

// 清除编辑器实例
setEditorInstance(null);

setContent

function setContent(content: string | InputContent[]): void
设置编辑器内容 设置编辑器的内容,支持文本和结构化内容,设置后会自动聚焦编辑器

参数

参数名类型必填描述
contentstring | 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

function insertContent(content: string | InputContent[], focus?: boolean): void
插入内容到编辑器 在编辑器当前光标位置插入内容,支持文本和结构化内容

参数

参数名类型必填描述
contentstring | InputContent[]要插入的内容
focusboolean插入后是否聚焦编辑器,默认为 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

function focusEditor(): void
聚焦编辑器 将焦点设置到编辑器,使用户可以直接输入内容

示例

import { useMessageInputState } from 'tuikit-atomicx-vue3';

const { focusEditor } = useMessageInputState();

// 聚焦编辑器
focusEditor();

blurEditor

function blurEditor(): void
失焦编辑器 移除编辑器的焦点,通常用于隐藏键盘或结束编辑状态

示例

import { useMessageInputState } from 'tuikit-atomicx-vue3';

const { blurEditor } = useMessageInputState();

// 失焦编辑器
blurEditor();

sendMessage

function sendMessage(msg?: string | InputContent[]): Promise<void>
发送消息 发送消息到当前会话,支持文本、图片、视频、文件等多种类型的消息

参数

参数名类型必填描述
msgstring | 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

const forwardMessageIDList: Ref<any>
要转发的消息ID列表 选中需要转发的消息ID列表
类型: Ref<any>

示例

import { useMessageActionState } from 'tuikit-atomicx-vue3';

const { forwardMessageIDList } = useMessageActionState();

// 监听数据变化
watch(forwardMessageIDList, (newValue) => {
  console.log('forwardMessageIDList 更新:', newValue);
});

// 直接访问数据
console.log('当前 forwardMessageIDList:', forwardMessageIDList.value);

isForwardMessageSelectionDone

const isForwardMessageSelectionDone: Ref<any>
消息转发选择是否完成 标识消息转发目标选择是否已完成
类型: Ref<any>

示例

import { useMessageActionState } from 'tuikit-atomicx-vue3';

const { isForwardMessageSelectionDone } = useMessageActionState();

// 监听数据变化
watch(isForwardMessageSelectionDone, (newValue) => {
  console.log('isForwardMessageSelectionDone 更新:', newValue);
});

// 直接访问数据
console.log('当前 isForwardMessageSelectionDone:', isForwardMessageSelectionDone.value);

forwardConversationIDList

const forwardConversationIDList: Ref<any>
转发目标会话ID列表 消息转发的目标会话ID列表
类型: Ref<any>

示例

import { useMessageActionState } from 'tuikit-atomicx-vue3';

const { forwardConversationIDList } = useMessageActionState();

// 监听数据变化
watch(forwardConversationIDList, (newValue) => {
  console.log('forwardConversationIDList 更新:', newValue);
});

// 直接访问数据
console.log('当前 forwardConversationIDList:', forwardConversationIDList.value);

quotedMessage

const quotedMessage: Ref<any>
被引用的消息信息 当前被引用回复的消息信息
类型: Ref<any>

示例

import { useMessageActionState } from 'tuikit-atomicx-vue3';

const { quotedMessage } = useMessageActionState();

// 监听数据变化
watch(quotedMessage, (newValue) => {
  console.log('quotedMessage 更新:', newValue);
});

// 直接访问数据
console.log('当前 quotedMessage:', quotedMessage.value);

接口函数

forwardMessage

function forwardMessage(params: IForwardMessageParams): Promise<Array<PromiseSettledResult<unknown>>>
转发消息 将选中的消息转发到指定会话,支持合并转发和逐条转发两种模式

参数

参数名类型必填描述
isMergeForwardboolean是否合并转发
messageIDListstring[]要转发的消息ID列表
conversationIDListstring[]目标会话ID列表
useOfflinePushboolean是否使用离线推送

示例

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

function setForwardMessageIDList(messageIDList: string[]): void
设置转发消息ID列表 设置要转发的消息ID列表,新的ID会与现有列表合并并去重

参数

参数名类型必填描述
messageIDListstring[]要转发的消息ID列表

示例

import { useMessageActionState } from 'tuikit-atomicx-vue3';

const { setForwardMessageIDList } = useMessageActionState();

// 设置转发消息ID列表
setForwardMessageIDList(['msg_001', 'msg_002', 'msg_003']);

setIsForwardMessageSelectionDone

function setIsForwardMessageSelectionDone(isSelectionDone: boolean): void
设置转发消息选择完成状态 标记转发消息选择是否完成

参数

参数名类型必填描述
isSelectionDoneboolean是否完成消息选择

示例

import { useMessageActionState } from 'tuikit-atomicx-vue3';

const { setIsForwardMessageSelectionDone } = useMessageActionState();

// 标记消息选择完成
setIsForwardMessageSelectionDone(true);

// 重置消息选择状态
setIsForwardMessageSelectionDone(false);

setForwardConversationIDList

function setForwardConversationIDList(conversationIDList: string[]): void
设置转发目标会话ID列表 设置要转发到的会话ID列表,新的ID会与现有列表合并并去重

参数

参数名类型必填描述
conversationIDListstring[]目标会话ID列表

示例

import { useMessageActionState } from 'tuikit-atomicx-vue3';

const { setForwardConversationIDList } = useMessageActionState();

// 设置转发目标会话
setForwardConversationIDList(['C2C_user123', 'GROUP_group456']);

quoteMessage

function quoteMessage(message: MessageModel | undefined): void
引用消息 设置要引用的消息,该消息将在发送新消息时作为引用显示

参数

参数名类型必填描述
messageMessageModel | 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

function clearQuotedMessage(): void
清除引用消息 清除当前引用的消息,取消消息引用状态

示例

import { useMessageActionState } from 'tuikit-atomicx-vue3';

const { clearQuotedMessage } = useMessageActionState();

// 清除引用消息
clearQuotedMessage();

copyTextMessage

function copyTextMessage(message: MessageModel): Promise<boolean>
复制文本消息 复制指定消息的文本内容到剪贴板,会自动将表情键转换为表情名称

参数

参数名类型必填描述
messageMessageModel要复制的消息对象

示例

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

function deleteMessage(message: MessageModel): Promise<unknown>
删除消息 删除指定的消息,将其从会话中移除

参数

参数名类型必填描述
messageMessageModel要删除的消息对象

示例

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

function recallMessage(message: MessageModel): Promise<unknown>
撤回消息 撤回已发送的消息,消息将显示为"已撤回"状态

参数

参数名类型必填描述
messageMessageModel要撤回的消息对象

示例

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

function resetMessageActionState(): void
重置消息操作状态 重置所有消息操作相关状态,包括引用消息和转发列表

示例

import { useMessageActionState } from 'tuikit-atomicx-vue3';

const { resetMessageActionState } = useMessageActionState();

// 重置所有消息操作状态
resetMessageActionState();

ConversationListState

响应式数据

conversationList

const conversationList: Ref<any>
会话列表数据 所有会话的列表数据
类型: Ref<any>

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { conversationList } = useConversationListState();

// 监听数据变化
watch(conversationList, (newValue) => {
  console.log('conversationList 更新:', newValue);
});

// 直接访问数据
console.log('当前 conversationList:', conversationList.value);

activeConversation

const activeConversation: Ref<any>
当前活跃的会话 当前选中并正在进行的会话
类型: Ref<any>

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { activeConversation } = useConversationListState();

// 监听数据变化
watch(activeConversation, (newValue) => {
  console.log('activeConversation 更新:', newValue);
});

// 直接访问数据
console.log('当前 activeConversation:', activeConversation.value);

totalUnRead

const totalUnRead: Ref<any>
未读消息总数 所有会话的未读消息总数统计
类型: Ref<any>

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { totalUnRead } = useConversationListState();

// 监听数据变化
watch(totalUnRead, (newValue) => {
  console.log('totalUnRead 更新:', newValue);
});

// 直接访问数据
console.log('当前 totalUnRead:', totalUnRead.value);

netStatus

const netStatus: Ref<any>
网络连接状态 当前网络连接的状态信息
类型: Ref<any>

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { netStatus } = useConversationListState();

// 监听数据变化
watch(netStatus, (newValue) => {
  console.log('netStatus 更新:', newValue);
});

// 直接访问数据
console.log('当前 netStatus:', netStatus.value);

接口函数

markConversationUnread

function markConversationUnread(conversationID: string, isUnread: boolean): Promise<void>
标记会话未读状态 标记指定会话为已读或未读状态,智能处理不同的未读状态场景

参数

参数名类型必填描述
conversationIDstring会话ID
isUnreadboolean是否标记为未读

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { markConversationUnread } = useConversationListState();

// 标记会话为未读
await markConversationUnread('C2Cuser123', true);

// 标记会话为已读
await markConversationUnread('C2Cuser123', false);

setActiveConversation

function setActiveConversation(conversationID: string): Promise<void>
设置活跃会话 切换到指定的会话,如果与当前活跃会话不同,会自动标记为已读并切换会话

参数

参数名类型必填描述
conversationIDstring要设置为活跃的会话ID

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { setActiveConversation } = useConversationListState();

// 切换到指定会话
await setActiveConversation('C2Cuser123');

pinConversation

function pinConversation(conversationID: string, isPin: boolean): Promise<unknown>
置顶会话 设置指定会话的置顶状态,置顶的会话会显示在会话列表顶部

参数

参数名类型必填描述
conversationIDstring会话ID
isPinboolean是否置顶

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { pinConversation } = useConversationListState();

// 置顶会话
await pinConversation('C2Cuser123', true);

// 取消置顶
await pinConversation('C2Cuser123', false);

deleteConversation

function deleteConversation(conversationID: string): Promise<unknown>
删除会话 删除指定的会话,删除后会话将从会话列表中移除

参数

参数名类型必填描述
conversationIDstring要删除的会话ID

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { deleteConversation } = useConversationListState();

// 删除会话
try {
  await deleteConversation('C2Cuser123');
  console.log('会话删除成功');
} catch (error) {
  console.error('删除会话失败:', error);
}

muteConversation

function muteConversation(conversationID: string, isMuted: boolean): Promise<unknown>
会话免打扰设置 设置指定会话的免打扰状态,免打扰的会话不会显示消息通知

参数

参数名类型必填描述
conversationIDstring会话ID
isMutedboolean是否开启免打扰

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { muteConversation } = useConversationListState();

// 开启免打扰
await muteConversation('C2Cuser123', true);

// 关闭免打扰
await muteConversation('C2Cuser123', false);

setConversationDraft

function setConversationDraft(options: SetConversationDraftParams): Promise<unknown>
设置会话草稿 为指定会话设置草稿内容,用于保存用户未发送的消息内容

参数

参数名类型必填描述
conversationIDstring会话ID
draftTextstring草稿内容

示例

import { useConversationListState } from 'tuikit-atomicx-vue3';

const { setConversationDraft } = useConversationListState();

// 设置会话草稿
await setConversationDraft({
  conversationID: 'C2Cuser123',
  draftText: '这是一条草稿消息'
});

createC2CConversation

function createC2CConversation(userID: string): Promise<ConversationModel>
创建单聊会话 创建与指定用户的单聊会话

参数

参数名类型必填描述
userIDstring目标用户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

function createGroupConversation(options: CreateGroupParams): Promise<ConversationModel>
创建群聊会话 创建群聊并返回对应的会话对象,支持不同类型的群组

参数

参数名类型必填描述
groupIDstring群组ID(可选)
namestring群组名称
typestring群组类型
memberListstring[]初始成员列表

示例

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

const friendList: Ref<any>
好友列表
类型: Ref<any>

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { friendList } = useContactListState();

// 监听数据变化
watch(friendList, (newValue) => {
  console.log('friendList 更新:', newValue);
});

// 直接访问数据
console.log('当前 friendList:', friendList.value);

groupList

const groupList: Ref<any>
群组列表
类型: Ref<any>

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { groupList } = useContactListState();

// 监听数据变化
watch(groupList, (newValue) => {
  console.log('groupList 更新:', newValue);
});

// 直接访问数据
console.log('当前 groupList:', groupList.value);

blackList

const blackList: Ref<any>
黑名单列表
类型: Ref<any>

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { blackList } = useContactListState();

// 监听数据变化
watch(blackList, (newValue) => {
  console.log('blackList 更新:', newValue);
});

// 直接访问数据
console.log('当前 blackList:', blackList.value);

friendApplicationUnreadCount

const friendApplicationUnreadCount: Ref<any>
好友申请未读数
类型: Ref<any>

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { friendApplicationUnreadCount } = useContactListState();

// 监听数据变化
watch(friendApplicationUnreadCount, (newValue) => {
  console.log('friendApplicationUnreadCount 更新:', newValue);
});

// 直接访问数据
console.log('当前 friendApplicationUnreadCount:', friendApplicationUnreadCount.value);

friendGroupList

const friendGroupList: Ref<any>
好友分组列表
类型: Ref<any>

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { friendGroupList } = useContactListState();

// 监听数据变化
watch(friendGroupList, (newValue) => {
  console.log('friendGroupList 更新:', newValue);
});

// 直接访问数据
console.log('当前 friendGroupList:', friendGroupList.value);

friendApplicationList

const friendApplicationList: Ref<any>
好友申请列表
类型: Ref<any>

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { friendApplicationList } = useContactListState();

// 监听数据变化
watch(friendApplicationList, (newValue) => {
  console.log('friendApplicationList 更新:', newValue);
});

// 直接访问数据
console.log('当前 friendApplicationList:', friendApplicationList.value);

groupApplicationList

const groupApplicationList: Ref<any>
群申请列表
类型: Ref<any>

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { groupApplicationList } = useContactListState();

// 监听数据变化
watch(groupApplicationList, (newValue) => {
  console.log('groupApplicationList 更新:', newValue);
});

// 直接访问数据
console.log('当前 groupApplicationList:', groupApplicationList.value);

接口函数

setGroupApplicationList

function setGroupApplicationList(listParams: { applicationList: any[] })
设置群组申请列表 更新群组申请列表数据

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { setGroupApplicationList } = useContactListState();

// 设置群申请列表
await setGroupApplicationList({
  applicationList: []
});

setFriendList

function setFriendList(listParams: { friendList: any[] })
设置好友列表 更新好友列表数据

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { setFriendList } = useContactListState();

// 设置好友列表
await setFriendList({
  friendList: []
});

setGroupList

function setGroupList(listParams: { groupList: any[] })
设置群组列表 更新群组列表数据

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { setGroupList } = useContactListState();

// 设置群组列表
await setGroupList({
  groupList: []
});

setBlackList

function setBlackList(listParams: { blackList: any[] })
设置黑名单列表 更新黑名单列表数据

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { setBlackList } = useContactListState();

// 设置黑名单
await setBlackList({
  blackList: []
});

setFriendApplicationUnreadCount

function setFriendApplicationUnreadCount(countParams: { count: number })
设置好友申请未读数 更新好友申请的未读数量

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { setFriendApplicationUnreadCount } = useContactListState();

// 设置好友申请未读数
await setFriendApplicationUnreadCount({
  count: 5
});

setFriendGroupList

function setFriendGroupList(listParams: { groupList: any[] })
设置好友分组列表 更新好友分组列表数据

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { setFriendGroupList } = useContactListState();

// 设置好友分组列表
await setFriendGroupList({
  groupList: []
});

setFriendApplicationList

function setFriendApplicationList(listParams: { applicationList: any[] })
设置好友申请列表 更新好友申请列表数据

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { setFriendApplicationList } = useContactListState();

// 设置好友申请列表
await setFriendApplicationList({
  applicationList: []
});

initContactListWatcher

function initContactListWatcher(watcherParams?: { autoUpdate?: boolean })
初始化联系人监听器 初始化联系人列表的数据监听

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { initContactListWatcher } = useContactListState();

// 初始化通讯录监听器
await initContactListWatcher({
  autoUpdate: true
});

addFriend

function addFriend(options: AddFriendParams): Promise<unknown>
添加好友 向指定用户发送好友申请,支持设置备注、分组、申请理由等信息

参数

参数名类型必填描述
userIDstring要添加的用户ID
addSourcestring添加来源
remarkstring好友备注
groupNamestring好友分组名称
wordingstring申请理由
typenumber申请类型

示例

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

function markFriendApplicationAsRead(): Promise<unknown>
标记好友申请为已读 将所有未读的好友申请标记为已读状态,清除未读数量

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { markFriendApplicationAsRead } = useContactListState();

// 标记好友申请为已读
try {
  await markFriendApplicationAsRead();
  console.log('好友申请已标记为已读');
} catch (error) {
  console.error('标记已读失败:', error);
}

acceptFriendApplication

function acceptFriendApplication(options: FriendApplicationParams): Promise<unknown>
接受好友申请 接受指定用户的好友申请,可以设置好友备注

参数

参数名类型必填描述
userIDstring申请用户的ID
remarkstring好友备注
typenumber申请类型

示例

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

function refuseFriendApplication(userID: string): Promise<unknown>
拒绝好友申请 拒绝指定用户的好友申请

参数

参数名类型必填描述
userIDstring申请用户的ID

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { refuseFriendApplication } = useContactListState();

// 拒绝好友申请
try {
  await refuseFriendApplication('user123');
  console.log('好友申请已拒绝');
} catch (error) {
  console.error('拒绝申请失败:', error);
}

addToBlacklist

function addToBlacklist(userIDList: string[]): Promise<unknown>
添加到黑名单 将指定用户添加到黑名单,被拉黑的用户无法发送消息

参数

参数名类型必填描述
userIDListstring[]要添加到黑名单的用户ID列表

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { addToBlacklist } = useContactListState();

// 添加用户到黑名单
try {
  await addToBlacklist(['user123', 'user456']);
  console.log('用户已添加到黑名单');
} catch (error) {
  console.error('添加到黑名单失败:', error);
}

removeFromBlacklist

function removeFromBlacklist(userIDList: string[]): Promise<unknown>
从黑名单移除 将指定用户从黑名单中移除,恢复正常的消息收发

参数

参数名类型必填描述
userIDListstring[]要从黑名单移除的用户ID列表

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { removeFromBlacklist } = useContactListState();

// 从黑名单移除用户
try {
  await removeFromBlacklist(['user123', 'user456']);
  console.log('用户已从黑名单移除');
} catch (error) {
  console.error('从黑名单移除失败:', error);
}

deleteFriend

function deleteFriend(options: DeleteFriendParams): Promise<unknown>
删除好友 从好友列表中删除指定的好友

参数

参数名类型必填描述
userIDstring要删除的好友用户ID
typestring删除类型

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { deleteFriend } = useContactListState();

// 删除好友
try {
  await deleteFriend({
    userID: 'user123',
    type: 'both'
  });
  console.log('好友删除成功');
} catch (error) {
  console.error('删除好友失败:', error);
}

setFriendRemark

function setFriendRemark(options: FriendRemarkParams): Promise<unknown>
设置好友备注 修改指定好友的备注名称

参数

参数名类型必填描述
userIDstring好友用户ID
remarkstring新的备注名称

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { setFriendRemark } = useContactListState();

// 设置好友备注
try {
  await setFriendRemark({
    userID: 'user123',
    remark: '小王同事'
  });
  console.log('好友备注设置成功');
} catch (error) {
  console.error('设置备注失败:', error);
}

createFriendGroup

function createFriendGroup(options: FriendGroupParams): Promise<unknown>
创建好友分组 创建一个新的好友分组,用于管理和分类好友

参数

参数名类型必填描述
namestring分组名称
userIDListstring[]要添加到分组的用户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

function deleteFriendGroup(name: string): Promise<unknown>
删除好友分组 删除指定的好友分组,分组中的好友会移到默认分组

参数

参数名类型必填描述
namestring要删除的分组名称

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { deleteFriendGroup } = useContactListState();

// 删除好友分组
try {
  await deleteFriendGroup('工作同事');
  console.log('好友分组删除成功');
} catch (error) {
  console.error('删除分组失败:', error);
}

addToFriendGroup

function addToFriendGroup(options: FriendGroupParams): Promise<unknown>
添加好友到分组 将指定好友添加到指定的分组中

参数

参数名类型必填描述
namestring分组名称
userIDListstring[]要添加的好友用户ID列表

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { addToFriendGroup } = useContactListState();

// 添加好友到分组
try {
  await addToFriendGroup({
    name: '工作同事',
    userIDList: ['user789']
  });
  console.log('好友已添加到分组');
} catch (error) {
  console.error('添加到分组失败:', error);
}

removeFromFriendGroup

function removeFromFriendGroup(options: FriendGroupParams): Promise<unknown>
从分组移除好友 将指定好友从指定分组中移除

参数

参数名类型必填描述
namestring分组名称
userIDListstring[]要移除的好友用户ID列表

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { removeFromFriendGroup } = useContactListState();

// 从分组移除好友
try {
  await removeFromFriendGroup({
    name: '工作同事',
    userIDList: ['user789']
  });
  console.log('好友已从分组移除');
} catch (error) {
  console.error('从分组移除失败:', error);
}

renameFriendGroup

function renameFriendGroup(options: RenameFriendGroupParams): Promise<unknown>
重命名好友分组 修改指定好友分组的名称

参数

参数名类型必填描述
oldNamestring原分组名称
newNamestring新分组名称

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { renameFriendGroup } = useContactListState();

// 重命名好友分组
try {
  await renameFriendGroup({
    oldName: '工作同事',
    newName: '公司同事'
  });
  console.log('分组重命名成功');
} catch (error) {
  console.error('重命名分组失败:', error);
}

joinGroup

function joinGroup(options: JoinGroupParams): Promise<unknown>
加入群组 申请加入指定的群组

参数

参数名类型必填描述
groupIDstring要加入的群组ID
applyMessagestring申请加群的理由
typestring加群类型

示例

import { useContactListState } from 'tuikit-atomicx-vue3';

const { joinGroup } = useContactListState();

// 申请加入群组
try {
  await joinGroup({
    groupID: 'group123',
    applyMessage: '我想加入这个群组学习交流'
  });
  console.log('加群申请已发送');
} catch (error) {
  console.error('加入群组失败:', error);
}

acceptGroupApplication

function acceptGroupApplication(options: GroupApplicationParams): Promise<unknown>
接受群组申请 接受用户的入群申请,并从申请列表中移除该申请

参数

参数名类型必填描述
applicationGroupApplication群组申请对象
handleMessagestring处理消息

示例

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

function refuseGroupApplication(options: GroupApplicationParams): Promise<unknown>
拒绝群组申请 拒绝用户的入群申请,并从申请列表中移除该申请

参数

参数名类型必填描述
applicationGroupApplication群组申请对象
handleMessagestring拒绝理由

示例

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

const groupID: Ref<any>
群组ID
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { groupID } = useGroupSettingState();

// 监听数据变化
watch(groupID, (newValue) => {
  console.log('groupID 更新:', newValue);
});

// 直接访问数据
console.log('当前 groupID:', groupID.value);

groupType

const groupType: Ref<any>
群组类型
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { groupType } = useGroupSettingState();

// 监听数据变化
watch(groupType, (newValue) => {
  console.log('groupType 更新:', newValue);
});

// 直接访问数据
console.log('当前 groupType:', groupType.value);

groupName

const groupName: Ref<any>
群组名称
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { groupName } = useGroupSettingState();

// 监听数据变化
watch(groupName, (newValue) => {
  console.log('groupName 更新:', newValue);
});

// 直接访问数据
console.log('当前 groupName:', groupName.value);

avatar

const avatar: Ref<any>
用户头像URL
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { avatar } = useGroupSettingState();

// 监听数据变化
watch(avatar, (newValue) => {
  console.log('avatar 更新:', newValue);
});

// 直接访问数据
console.log('当前 avatar:', avatar.value);

introduction

const introduction: Ref<any>
群组介绍
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { introduction } = useGroupSettingState();

// 监听数据变化
watch(introduction, (newValue) => {
  console.log('introduction 更新:', newValue);
});

// 直接访问数据
console.log('当前 introduction:', introduction.value);

notification

const notification: Ref<any>
群组公告
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { notification } = useGroupSettingState();

// 监听数据变化
watch(notification, (newValue) => {
  console.log('notification 更新:', newValue);
});

// 直接访问数据
console.log('当前 notification:', notification.value);

isMuted

const isMuted: Ref<any>
是否已静音
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { isMuted } = useGroupSettingState();

// 监听数据变化
watch(isMuted, (newValue) => {
  console.log('isMuted 更新:', newValue);
});

// 直接访问数据
console.log('当前 isMuted:', isMuted.value);

isPinned

const isPinned: Ref<any>
是否已置顶
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { isPinned } = useGroupSettingState();

// 监听数据变化
watch(isPinned, (newValue) => {
  console.log('isPinned 更新:', newValue);
});

// 直接访问数据
console.log('当前 isPinned:', isPinned.value);

groupOwner

const groupOwner: Ref<any>
群主信息
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { groupOwner } = useGroupSettingState();

// 监听数据变化
watch(groupOwner, (newValue) => {
  console.log('groupOwner 更新:', newValue);
});

// 直接访问数据
console.log('当前 groupOwner:', groupOwner.value);

adminMembers

const adminMembers: Ref<any>
管理员列表
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { adminMembers } = useGroupSettingState();

// 监听数据变化
watch(adminMembers, (newValue) => {
  console.log('adminMembers 更新:', newValue);
});

// 直接访问数据
console.log('当前 adminMembers:', adminMembers.value);

allMembers

const allMembers: Ref<any>
所有成员列表
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { allMembers } = useGroupSettingState();

// 监听数据变化
watch(allMembers, (newValue) => {
  console.log('allMembers 更新:', newValue);
});

// 直接访问数据
console.log('当前 allMembers:', allMembers.value);

memberCount

const memberCount: Ref<any>
成员总数
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { memberCount } = useGroupSettingState();

// 监听数据变化
watch(memberCount, (newValue) => {
  console.log('memberCount 更新:', newValue);
});

// 直接访问数据
console.log('当前 memberCount:', memberCount.value);

maxMemberCount

const maxMemberCount: Ref<any>
最大成员数
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { maxMemberCount } = useGroupSettingState();

// 监听数据变化
watch(maxMemberCount, (newValue) => {
  console.log('maxMemberCount 更新:', newValue);
});

// 直接访问数据
console.log('当前 maxMemberCount:', maxMemberCount.value);

currentUserID

const currentUserID: Ref<any>
当前用户ID
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { currentUserID } = useGroupSettingState();

// 监听数据变化
watch(currentUserID, (newValue) => {
  console.log('currentUserID 更新:', newValue);
});

// 直接访问数据
console.log('当前 currentUserID:', currentUserID.value);

currentUserRole

const currentUserRole: Ref<any>
当前用户角色
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { currentUserRole } = useGroupSettingState();

// 监听数据变化
watch(currentUserRole, (newValue) => {
  console.log('currentUserRole 更新:', newValue);
});

// 直接访问数据
console.log('当前 currentUserRole:', currentUserRole.value);

nameCard

const nameCard: Ref<any>
用户名片
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { nameCard } = useGroupSettingState();

// 监听数据变化
watch(nameCard, (newValue) => {
  console.log('nameCard 更新:', newValue);
});

// 直接访问数据
console.log('当前 nameCard:', nameCard.value);

isMuteAllMembers

const isMuteAllMembers: Ref<any>
是否禁言所有成员
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { isMuteAllMembers } = useGroupSettingState();

// 监听数据变化
watch(isMuteAllMembers, (newValue) => {
  console.log('isMuteAllMembers 更新:', newValue);
});

// 直接访问数据
console.log('当前 isMuteAllMembers:', isMuteAllMembers.value);

isInGroup

const isInGroup: Ref<any>
是否在群组中
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { isInGroup } = useGroupSettingState();

// 监听数据变化
watch(isInGroup, (newValue) => {
  console.log('isInGroup 更新:', newValue);
});

// 直接访问数据
console.log('当前 isInGroup:', isInGroup.value);

inviteOption

const inviteOption: Ref<any>
邀请选项
类型: Ref<any>

示例

import { useGroupSettingState } from 'tuikit-atomicx-vue3';

const { inviteOption } = useGroupSettingState();

// 监听数据变化
watch(inviteOption, (newValue) => {
  console.log('inviteOption 更新:', newValue);
});

// 直接访问数据
console.log('当前 inviteOption:', inviteOption.value);

接口函数

getGroupMemberList

function getGroupMemberList(params?: GetGroupMemberListParams): Promise<GroupMember[]>
获取群组成员列表 获取指定群组的成员列表,支持分页加载和数据合并

参数

参数名类型必填描述
groupIDstring群组ID,不传则使用当前群组ID
countnumber获取成员数量,默认100
offsetnumber偏移量,用于分页,默认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

function updateGroupProfile(params: UpdateGroupProfileParams): Promise<void>
更新群组资料 更新群组的基本信息,包括群名称、头像、简介、公告等,并进行参数验证

参数

参数名类型必填描述
groupIDstring群组ID,不传则使用当前群组ID
namestring群组名称,长度限制1-30字符
avatarstring群组头像URL,长度限制500字符以内
introductionstring群组简介,长度限制130字符以内
notificationstring群组公告,长度限制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

function addGroupMember(params: AddGroupMemberParams): Promise<AddGroupMemberResult>
添加群组成员 向群组中添加新成员,添加成功后自动刷新成员列表

参数

参数名类型必填描述
groupIDstring群组ID,不传则使用当前群组ID
userIDListstring[]要添加的用户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

function deleteGroupMember(params: DeleteGroupMemberParams): Promise<void>
删除群组成员 从群组中移除指定成员,删除成功后自动更新本地成员列表

参数

参数名类型必填描述
groupIDstring群组ID,不传则使用当前群组ID
userIDListstring[]要删除的用户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

function changeGroupOwner(params: ChangeGroupOwnerParams): Promise<void>
转让群主 将群主身份转让给指定的群成员,只有群主才能执行此操作

参数

参数名类型必填描述
groupIDstring群组ID,不传则使用当前群组ID
newOwnerIDstring新群主的用户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

function setGroupMemberRole(params: SetGroupMemberRoleParams): Promise<void>
设置群组成员角色 设置指定群成员的角色(普通成员、管理员),设置成功后自动刷新成员列表

参数

参数名类型必填描述
groupIDstring群组ID,不传则使用当前群组ID
userIDstring要设置角色的用户ID
roleGroupMemberRole新的角色类型

示例

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

function setGroupMemberNameCard(params: SetGroupMemberNameCardParams): Promise<void>
设置群组成员名片 设置指定群成员的群名片(群昵称),通常用于设置自己的群名片

参数

参数名类型必填描述
groupIDstring群组ID,不传则使用当前群组ID
userIDstring用户ID,不传则使用当前用户ID
nameCardstring群名片内容

示例

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

function setChatPinned(value: boolean): Promise<void>
设置聊天置顶状态 设置当前群组聊天的置顶状态,置顶的聊天会显示在聊天列表顶部

参数

参数名类型必填描述
valueboolean是否置顶,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

function setChatMuted(value: boolean): Promise<void>
设置聊天免打扰状态 设置当前群组聊天的免打扰状态,开启后不会收到消息通知

参数

参数名类型必填描述
valueboolean是否免打扰,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

function setGroupMemberMuteTime(params: SetGroupMemberMuteTimeParams): Promise<void>
设置群组成员禁言时间 对指定群成员设置禁言时间,禁言期间该成员无法发送消息

参数

参数名类型必填描述
groupIDstring群组ID,不传则使用当前群组ID
userIDstring要禁言的用户ID
timenumber禁言时间(秒),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

function setMuteAllMember(value: boolean): Promise<void>
设置全员禁言 设置群组的全员禁言状态,开启后除管理员和群主外的所有成员都无法发言

参数

参数名类型必填描述
valueboolean是否全员禁言,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

function dismissGroup(groupID?: string): Promise<void>
解散群组 解散指定的群组,只有群主才能执行此操作,解散后群组将被永久删除

参数

参数名类型必填描述
groupIDstring群组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

function quitGroup(groupID?: string): Promise<void>
退出群组 退出指定的群组,退出后将不再接收群组消息

参数

参数名类型必填描述
groupIDstring群组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

function hasPermission(permission: GroupPermission, role?: GroupMemberRole, groupType?: GroupType): boolean
检查权限 检查指定角色在指定群组类型中是否拥有某项权限

参数

参数名类型必填描述
permissionGroupPermission要检查的权限类型
roleGroupMemberRole用户角色,不传则使用当前用户角色
groupTypeGroupType群组类型,不传则使用当前群组类型

示例

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

function canOperateOnMember(targetMember: GroupMember): boolean
检查是否可以对指定成员进行操作 根据当前用户角色和目标成员角色,判断是否可以对目标成员进行管理操作

参数

参数名类型必填描述
targetMemberGroupMember目标成员信息

示例

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

function getAvailablePermissions(): GroupPermission[]
获取当前用户可用的权限列表 根据当前用户在当前群组中的角色,获取所有可用的权限列表

示例

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

function initWatcher(): void
初始化数据监听器 初始化TUIStore数据变化监听器,实现群组状态的自动同步更新。该函数在模块加载时自动调用,通常不需要手动调用。

示例

// 该函数在模块加载时自动调用,监听以下数据变化:
// - 当前会话变化:自动更新群组信息和用户状态
// - 群组资料变化:同步更新群组ID等信息
// - 会话切换:自动重置或更新相关状态
// 通常不需要手动调用此函数

VideoMixerState

响应式数据

publishVideoQuality

const publishVideoQuality: Ref<TUIVideoQuality>
发布视频质量 当前设置的视频发布质量等级
类型: Ref<TUIVideoQuality>

示例

import { useVideoMixerState, TUIVideoQuality } from 'tuikit-atomicx-vue3';

const { publishVideoQuality } = useVideoMixerState();

// 监听视频质量变化
watch(publishVideoQuality, (newValue) => {
  console.log('视频质量更新:', newValue);
});

// 设置视频质量
publishVideoQuality.value = TUIVideoQuality.kVideoQuality_720p;

isVideoMixerEnabled

const isVideoMixerEnabled: Ref<boolean>
视频混流是否启用 标识当前视频混流功能是否已启用
类型: Ref<boolean>

示例

import { useVideoMixerState } from 'tuikit-atomicx-vue3';

const { isVideoMixerEnabled, enableLocalVideoMixer } = useVideoMixerState();

// 监听混流状态变化
watch(isVideoMixerEnabled, (newValue) => {
  console.log('视频混流状态:', newValue ? '已启用' : '未启用');
});

// 检查混流状态
if (!isVideoMixerEnabled.value) {
  enableLocalVideoMixer();
}

mediaSourceList

const mediaSourceList: Ref<MediaSource[]>
媒体源列表 当前已添加的所有媒体源列表,包括摄像头、屏幕共享、图片、视频等
类型: 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

const activeMediaSource: ComputedRef<MediaSource | null>
当前活跃的媒体源 当前被选中的媒体源,用于编辑和操作
类型: 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

function enableLocalVideoMixer(): void
启用本地视频混流 启用视频混流功能,初始化媒体源管理器

示例

import { useVideoMixerState } from 'tuikit-atomicx-vue3';

const { enableLocalVideoMixer, isVideoMixerEnabled } = useVideoMixerState();

// 启用视频混流
enableLocalVideoMixer();
console.log('视频混流已启用:', isVideoMixerEnabled.value);

addMediaSource

function addMediaSource(source: MediaSource): Promise<void>
添加媒体源到混流 向混流器添加新的媒体源,支持摄像头、屏幕共享、图片、视频、文字等类型

参数

参数名类型必填描述
sourceMediaSource媒体源对象,包含类型、配置和布局信息

示例

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

function updateMediaSource(source: MediaSource, config: Partial<MediaSource>): Promise<void>
更新媒体源配置 更新指定媒体源的配置,如布局位置、大小等

参数

参数名类型必填描述
sourceMediaSource要更新的媒体源对象
configPartial<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

function removeMediaSource(source: MediaSource): Promise<void>
移除媒体源 从混流器中移除指定的媒体源

参数

参数名类型必填描述
sourceMediaSource要移除的媒体源对象

示例

import { useVideoMixerState } from 'tuikit-atomicx-vue3';

const { removeMediaSource, mediaSourceList } = useVideoMixerState();

// 移除第一个媒体源
const source = mediaSourceList.value[0];
if (source) {
  await removeMediaSource(source);
  console.log('媒体源已移除');
}

clearMediaSource

function clearMediaSource(): void
清空所有媒体源 清空当前添加的所有媒体源,释放相关资源

示例

import { useVideoMixerState } from 'tuikit-atomicx-vue3';

const { clearMediaSource, mediaSourceList } = useVideoMixerState();

// 清空所有媒体源
clearMediaSource();
console.log('所有媒体源已清空,当前数量:', mediaSourceList.value.length);

ASRState

响应式数据

recentTranscripts

const recentTranscripts: Ref<any>
最近的语音转录记录
类型: Ref<any>

示例

import { useASRState } from 'tuikit-atomicx-vue3';

const { recentTranscripts } = useASRState();

// 监听数据变化
watch(recentTranscripts, (newValue) => {
  console.log('recentTranscripts 更新:', newValue);
});

// 直接访问数据
console.log('当前 recentTranscripts:', recentTranscripts.value);

transcriptHistory

const transcriptHistory: Ref<any>
语音转录历史记录
类型: Ref<any>

示例

import { useASRState } from 'tuikit-atomicx-vue3';

const { transcriptHistory } = useASRState();

// 监听数据变化
watch(transcriptHistory, (newValue) => {
  console.log('transcriptHistory 更新:', newValue);
});

// 直接访问数据
console.log('当前 transcriptHistory:', transcriptHistory.value);

接口函数

setRecentTranscriptsDuration

function setRecentTranscriptsDuration(duration: number): void
设置最近转录消息的时间窗口 设置用于判断"最近消息"的时间窗口大小,超过此时间的消息将不会出现在最近转录列表中

参数

参数名类型必填描述
durationnumber时间窗口大小,单位为毫秒

示例

import { useASRState } from 'tuikit-atomicx-vue3';

const { setRecentTranscriptsDuration } = useASRState();

// 设置最近消息窗口为5秒
setRecentTranscriptsDuration(5000);

// 设置最近消息窗口为10秒
setRecentTranscriptsDuration(10000);

clearHistory

function clearHistory(): void
清空转录历史记录 清空所有已存储的转录消息,包括最近消息和历史记录

示例

import { useASRState } from 'tuikit-atomicx-vue3';

const { clearHistory, transcriptHistory } = useASRState();

// 清除所有转写记录
clearHistory();
console.log('转录记录已清空:', transcriptHistory.value.length === 0);

exportTranscripts

function exportTranscripts(): string
导出转录记录为文本格式 将所有转录历史记录导出为格式化的文本内容,包含会议日期、时间和发言记录。如果没有记录则返回空字符串

示例

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

const keyword: Ref<any>
搜索关键词
类型: Ref<any>

示例

import { useSearchState } from 'tuikit-atomicx-vue3';

const { keyword } = useSearchState();

// 监听数据变化
watch(keyword, (newValue) => {
  console.log('keyword 更新:', newValue);
});

// 直接访问数据
console.log('当前 keyword:', keyword.value);

results

const results: Ref<any>
搜索结果
类型: Ref<any>

示例

import { useSearchState } from 'tuikit-atomicx-vue3';

const { results } = useSearchState();

// 监听数据变化
watch(results, (newValue) => {
  console.log('results 更新:', newValue);
});

// 直接访问数据
console.log('当前 results:', results.value);

isLoading

const isLoading: Ref<any>
是否正在加载
类型: Ref<any>

示例

import { useSearchState } from 'tuikit-atomicx-vue3';

const { isLoading } = useSearchState();

// 监听数据变化
watch(isLoading, (newValue) => {
  console.log('isLoading 更新:', newValue);
});

// 直接访问数据
console.log('当前 isLoading:', isLoading.value);

error

const error: Ref<any>
错误信息
类型: Ref<any>

示例

import { useSearchState } from 'tuikit-atomicx-vue3';

const { error } = useSearchState();

// 监听数据变化
watch(error, (newValue) => {
  console.log('error 更新:', newValue);
});

// 直接访问数据
console.log('当前 error:', error.value);

searchAdvancedParams

const searchAdvancedParams: Ref<any>
高级搜索参数
类型: Ref<any>

示例

import { useSearchState } from 'tuikit-atomicx-vue3';

const { searchAdvancedParams } = useSearchState();

// 监听数据变化
watch(searchAdvancedParams, (newValue) => {
  console.log('searchAdvancedParams 更新:', newValue);
});

// 直接访问数据
console.log('当前 searchAdvancedParams:', searchAdvancedParams.value);

selectedSearchType

const selectedSearchType: Ref<any>
选中的搜索类型
类型: Ref<any>

示例

import { useSearchState } from 'tuikit-atomicx-vue3';

const { selectedSearchType } = useSearchState();

// 监听数据变化
watch(selectedSearchType, (newValue) => {
  console.log('selectedSearchType 更新:', newValue);
});

// 直接访问数据
console.log('当前 selectedSearchType:', selectedSearchType.value);

接口函数

setKeyword

function setKeyword(keyword: string): void
设置搜索关键词 设置搜索关键词,并自动触发相应的搜索操作

参数

参数名类型必填描述
keywordstring搜索关键词

示例

import { useSearchState } from 'tuikit-atomicx-vue3';

const { setKeyword } = useSearchState();

// 设置搜索关键词
setKeyword('hello world');

// 清除搜索关键词
setKeyword('');

loadMore

function loadMore(type?: SearchType): Promise<void>
加载更多搜索结果 加载指定搜索类型的更多结果,支持分页加载

参数

参数名类型必填描述
typeSearchType搜索类型,如 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

function setSelectedType(type: SearchType | 'all'): void
设置选中的搜索类型 设置当前选中的搜索类型,可以切换不同的搜索内容类型

参数

参数名类型必填描述
typeSearchType | '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

function setSearchMessageAdvancedParams(params: SearchCloudMessagesParams): void
设置消息搜索高级参数 设置消息搜索的高级参数,包括会话ID、发送者ID列表、消息类型列表等

参数

参数名类型必填描述
paramsSearchCloudMessagesParams消息搜索高级参数对象

示例

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

function setSearchUserAdvancedParams(params: SearchCloudUsersParams): void
设置用户搜索高级参数 设置用户搜索的高级参数

参数

参数名类型必填描述
paramsSearchCloudUsersParams用户搜索高级参数对象

示例

import { useSearchState } from 'tuikit-atomicx-vue3';

const { setSearchUserAdvancedParams } = useSearchState();

// 设置用户搜索高级参数
setSearchUserAdvancedParams({
  // 用户搜索参数
});

setSearchGroupAdvancedParams

function setSearchGroupAdvancedParams(params: SearchCloudGroupsParams): void
设置群组搜索高级参数 设置群组搜索的高级参数

参数

参数名类型必填描述
paramsSearchCloudGroupsParams群组搜索高级参数对象

示例

import { useSearchState } from 'tuikit-atomicx-vue3';

const { setSearchGroupAdvancedParams } = useSearchState();

// 设置群组搜索高级参数
setSearchGroupAdvancedParams({
  // 群组搜索参数
});

SeatStore

响应式数据

liveOwnerUserId

const liveOwnerUserId: Ref<any>
直播间主播用户ID
类型: Ref<any>

示例

import { useSeatStore } from 'tuikit-atomicx-vue3';

const { liveOwnerUserId } = useSeatStore();

// 监听数据变化
watch(liveOwnerUserId, (newValue) => {
  console.log('liveOwnerUserId 更新:', newValue);
});

// 直接访问数据
console.log('当前 liveOwnerUserId:', liveOwnerUserId.value);

localUserId

const localUserId: Ref<any>
本地用户ID
类型: Ref<any>

示例

import { useSeatStore } from 'tuikit-atomicx-vue3';

const { localUserId } = useSeatStore();

// 监听数据变化
watch(localUserId, (newValue) => {
  console.log('localUserId 更新:', newValue);
});

// 直接访问数据
console.log('当前 localUserId:', localUserId.value);

seatList

const seatList: Ref<any>
麦位列表,包含所有麦位的状态和用户信息 存储当前直播间的所有麦位信息
类型: Ref<any>

示例

import { useSeatStore } from 'tuikit-atomicx-vue3';

const { seatList } = useSeatStore();

// 监听数据变化
watch(seatList, (newValue) => {
  console.log('seatList 更新:', newValue);
});

// 直接访问数据
console.log('当前 seatList:', seatList.value);

coHostUserList

const coHostUserList: Ref<any>
连麦主播列表
类型: Ref<any>

示例

import { useSeatStore } from 'tuikit-atomicx-vue3';

const { coHostUserList } = useSeatStore();

// 监听数据变化
watch(coHostUserList, (newValue) => {
  console.log('coHostUserList 更新:', newValue);
});

// 直接访问数据
console.log('当前 coHostUserList:', coHostUserList.value);

sentDeviceRequestMap

const sentDeviceRequestMap: Ref<any>
已发送的设备请求映射
类型: Ref<any>

示例

import { useSeatStore } from 'tuikit-atomicx-vue3';

const { sentDeviceRequestMap } = useSeatStore();

// 监听数据变化
watch(sentDeviceRequestMap, (newValue) => {
  console.log('sentDeviceRequestMap 更新:', newValue);
});

// 直接访问数据
console.log('当前 sentDeviceRequestMap:', sentDeviceRequestMap.value);

receivedDeviceRequestMap

const receivedDeviceRequestMap: Ref<any>
已接收的设备请求映射
类型: Ref<any>

示例

import { useSeatStore } from 'tuikit-atomicx-vue3';

const { receivedDeviceRequestMap } = useSeatStore();

// 监听数据变化
watch(receivedDeviceRequestMap, (newValue) => {
  console.log('receivedDeviceRequestMap 更新:', newValue);
});

// 直接访问数据
console.log('当前 receivedDeviceRequestMap:', receivedDeviceRequestMap.value);

userInfoMap

const userInfoMap: Ref<any>
用户信息映射表
类型: Ref<any>

示例

import { useSeatStore } from 'tuikit-atomicx-vue3';

const { userInfoMap } = useSeatStore();

// 监听数据变化
watch(userInfoMap, (newValue) => {
  console.log('userInfoMap 更新:', newValue);
});

// 直接访问数据
console.log('当前 userInfoMap:', userInfoMap.value);

接口函数

getUserInfo

function getUserInfo(userId: string): Promise<AudienceInfo>
获取用户信息 根据用户ID异步获取用户的详细信息,包括用户名、头像、角色等

参数

参数名类型必填描述
userIdstring用户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

function convertUserInfoToAudienceInfo(userInfo: TUIUserInfo): AudienceInfo
转换用户信息为观众信息 将 TUIUserInfo 格式的用户信息转换为 AudienceInfo 格式

参数

参数名类型必填描述
userInfoTUIUserInfoTUIUserInfo 格式的用户信息对象

示例

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

const realtimeMessageList: Ref<TranscriberMessage[]>
实时转写消息列表
类型: 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

function startRealtimeTranscriber(config: Object): Promise<string>
开始实时转写

参数

参数名 类型 必填 描述
sourceLanguage TranscriberLanguage 源语言
translationLanguages TranscriberLanguage[] 目标翻译语言

示例

import { useAITranscriberState } from 'tuikit-atomicx-vue3';

const { startRealtimeTranscriber } = useAITranscriberState();
const transcriberRobotId = await startRealtimeTranscriber({
  sourceLanguage: 'zh',
  translationLanguages: ['en'],
});

stopRealtimeTranscriber

function stopRealtimeTranscriber(): Promise<void>
停止实时转写

示例

import { useAITranscriberState } from 'tuikit-atomicx-vue3';

const { stopRealtimeTranscriber } = useAITranscriberState();
await stopRealtimeTranscriber();

updateRealTimeTranscriber

function updateRealTimeTranscriber(config: Object): Promise<string>
更新实时转写

参数

参数名 类型 必填 描述
sourceLanguage TranscriberLanguage 源语言
translationLanguages TranscriberLanguage[] 目标翻译语言

示例

import { useAITranscriberState } from 'tuikit-atomicx-vue3';

const { updateRealTimeTranscriber } = useAITranscriberState();
await updateRealTimeTranscriber({
  sourceLanguage: 'zh',
  translationLanguages: ['en'],
});

subscribeEvent

function subscribeEvent(event: RealtimeTranscriberEvent, callback: RealtimeTranscriberEventCallback): void
订阅实时转写事件

参数

参数名 类型 必填 描述
event RealtimeTranscriberEvent 事件名称
callback RealtimeTranscriberEventCallback 事件回调函数

示例

import { useAITranscriberState, RealtimeTranscriberEvent } from 'tuikit-atomicx-vue3';

const { subscribeEvent } = useAITranscriberState();
subscribeEvent(RealtimeTranscriberEvent.onReceiveTranscriberMessage, (eventInfo) => {
  console.log('onReceiveTranscriberMessage', eventInfo);
});

unsubscribeEvent

function unsubscribeEvent(event: RealtimeTranscriberEvent, callback: RealtimeTranscriberEventCallback): void
取消订阅实时转写事件

参数

参数名 类型 必填 描述
event RealtimeTranscriberEvent 事件名称
callback RealtimeTranscriberEventCallback 事件回调函数

示例

import { useAITranscriberState, RealtimeTranscriberEvent } from 'tuikit-atomicx-vue3';

const { unsubscribeEvent } = useAITranscriberState();
unsubscribeEvent(RealtimeTranscriberEvent.onReceiveTranscriberMessage, (eventInfo) => {
  console.log('onReceiveTranscriberMessage', eventInfo);
});

BarrageState

管理直播间弹幕功能,包括文本消息和自定义消息的发送、接收和存储

响应式数据

messageList

const messageList: Ref<Barrage[]>
存储当前直播间的所有弹幕消息,包括文本消息和自定义消息
类型: 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

function sendTextMessage(): Promise<void>
向当前直播间发送文本弹幕消息,支持扩展信息

示例

import { useBarrageState } from 'tuikit-atomicx-vue3';

const { sendTextMessage } = useBarrageState();

// 调用函数
await sendTextMessage();

sendCustomMessage

function sendCustomMessage(): Promise<void>
向当前直播间发送自定义弹幕消息,用于发送特殊业务数据如礼物、点赞等

示例

import { useBarrageState } from 'tuikit-atomicx-vue3';

const { sendCustomMessage } = useBarrageState();

// 调用函数
await sendCustomMessage();

appendLocalTip

function appendLocalTip(): Promise<void>
向消息列表中添加本地生成的提示消息,不会发送到服务器

示例

import { useBarrageState } from 'tuikit-atomicx-vue3';

const { appendLocalTip } = useBarrageState();

// 调用函数
await appendLocalTip();

BattleState

管理直播间PK功能,包括PK邀请、接受、拒绝、退出以及PK过程中的事件处理和状态管理

响应式数据

currentBattleInfo

const currentBattleInfo: Ref<BattleInfo | undefined>
存储当前正在进行的PK的详细信息
类型: 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

const battleUsers: Ref<SeatUserInfo[]>
存储当前PK中所有参与用户的信息
类型: 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

const battleScore: Ref<Map<string, number>>
存储PK中每个用户的当前积分
类型: 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

function subscribeEvent(event: BattleEvent, callback: Function): Promise<void>
订阅指定的PK事件,当事件触发时会调用回调函数

参数

参数名 类型 必填 描述
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

function unsubscribeEvent(event: BattleEvent, callback: Function): Promise<void>
取消订阅指定的PK事件回调函数

参数

参数名 类型 必填 描述
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

function requestBattle(options: Object): Promise<void>
向指定用户发起PK邀请,可以配置PK参数和超时时间

参数

参数名 类型 必填 描述
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

function cancelBattleRequest(options: Object): Promise<void>
取消已发出的PK邀请

参数

参数名 类型 必填 描述
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

function acceptBattle(options: Object): Promise<void>
接受收到的PK邀请,开始PK

参数

参数名 类型 必填 描述
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

function rejectBattle(options: Object): Promise<void>
拒绝收到的PK邀请

参数

参数名 类型 必填 描述
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

function exitBattle(options: Object): Promise<void>
退出当前正在进行的PK

参数

参数名 类型 必填 描述
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

const userID: Ref<unknown>
类型: 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

const nick: Ref<unknown>
类型: 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

const avatar: Ref<unknown>
类型: 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

const signature: Ref<unknown>
类型: 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

const remark: Ref<unknown>
类型: 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

const isMuted: Ref<unknown>
类型: 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

const isPinned: Ref<unknown>
类型: 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

const isContact: Ref<unknown>
类型: 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

function setChatPinned(value: boolean): Promise<void>
切换当前C2C会话的置顶状态,置顶的会话会显示在会话列表顶部

参数

参数名 类型 必填 描述
value boolean 置顶状态,true为置顶,false为取消置顶

示例

const { setChatPinned, isPinned } = useC2CSettingState();

// 置顶会话
setChatPinned(true);

// 取消置顶
setChatPinned(false);

// 切换置顶状态
const togglePin = () => {
  setChatPinned(!isPinned.value);
};

setChatMuted

function setChatMuted(value: boolean): Promise<void>
切换当前C2C会话的静音状态,静音后不会收到该会话的消息提醒

参数

参数名 类型 必填 描述
value boolean 静音状态,true为静音,false为取消静音

示例

const { setChatMuted, isMuted } = useC2CSettingState();

// 静音会话
setChatMuted(true);

// 取消静音
setChatMuted(false);

// 切换静音状态
const toggleMute = () => {
  setChatMuted(!isMuted.value);
};

setUserRemark

function setUserRemark(remark: string): Promise<void>
为当前C2C会话的对方用户设置备注名,仅在双方为好友关系时有效

参数

参数名 类型 必填 描述
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

const connected: Ref<SeatUserInfo[]>
当前已上麦并建立连麦连接的用户列表
类型: 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

const invitees: Ref<LiveUserInfo[]>
已发送连麦邀请但尚未响应的用户列表
类型: 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

const applicants: Ref<LiveUserInfo[]>
已申请连麦并等待主播审批的用户列表
类型: 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

const candidates: Ref<Array>
可供邀请连麦的候选用户列表
类型: 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

function applyForSeat(options: object): Promise<void>
向主播发送上麦申请请求

参数

参数名 类型 必填 描述
seatIndex number 麦位索引,指定要申请的麦位位置
timeout number 超时时间(秒),超过此时间未响应将自动取消申请

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { applyForSeat } = useCoGuestState();

// 调用函数
await applyForSeat({
  seatIndex: 0,
  timeout: 30,
});

cancelApplication

function cancelApplication(): Promise<void>
取消当前用户的待处理上麦申请

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { cancelApplication } = useCoGuestState();

// 调用函数
await cancelApplication();

acceptApplication

function acceptApplication(options: object): Promise<void>
主播接受观众的上麦申请请求

参数

参数名 类型 必填 描述
userId string 要接受的申请者用户 ID

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { acceptApplication } = useCoGuestState();

// 调用函数
await acceptApplication({
  userId: 'user_001',
});

rejectApplication

function rejectApplication(options: object): Promise<void>
主播拒绝观众的上麦申请请求

参数

参数名 类型 必填 描述
userId string 要拒绝的申请者用户 ID

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { rejectApplication } = useCoGuestState();

// 调用函数
await rejectApplication({
  userId: 'user_001',
});

inviteToSeat

function inviteToSeat(options: object): Promise<void>
主播向用户发送连麦邀请

参数

参数名 类型 必填 描述
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

function cancelInvitation(options: object): Promise<void>
主播取消已发送给用户的待处理邀请

参数

参数名 类型 必填 描述
inviteeId string 要取消邀请的被邀请者用户 ID

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { cancelInvitation } = useCoGuestState();

// 调用函数
await cancelInvitation({
  inviteeId: 'example_inviteeId',
});

acceptInvitation

function acceptInvitation(options: object): Promise<void>
观众接受主播发送的连麦邀请

参数

参数名 类型 必填 描述
inviterId string 发送邀请的主播用户 ID

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { acceptInvitation } = useCoGuestState();

// 调用函数
await acceptInvitation({
  inviterId: 'example_inviterId',
});

rejectInvitation

function rejectInvitation(options: object): Promise<void>
观众拒绝主播发送的连麦邀请

参数

参数名 类型 必填 描述
inviterId string 发送邀请的主播用户 ID

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { rejectInvitation } = useCoGuestState();

// 调用函数
await rejectInvitation({
  inviterId: 'example_inviterId',
});

disConnect

function disConnect(): Promise<void>
观众断开当前麦位连接并离开连麦

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { disConnect } = useCoGuestState();

// 调用函数
await disConnect();

subscribeEvent

function subscribeEvent(event: HostEvent | GuestEvent, callback: Function): void
订阅指定的连麦事件,当事件触发时执行回调函数

参数

参数名 类型 必填 描述
event HostEvent | GuestEvent 要订阅的事件类型
callback Function 回调函数,接收事件信息作为参数

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { subscribeEvent } = useCoGuestState();

// 调用函数
await subscribeEvent({ event: /* HostEvent | GuestEvent */, callback: /* Function */ });

unsubscribeEvent

function unsubscribeEvent(event: HostEvent | GuestEvent, callback: Function): void
取消订阅指定的连麦事件并移除已注册的回调函数

参数

参数名 类型 必填 描述
event HostEvent | GuestEvent 要取消订阅的事件类型
callback Function 要移除的回调函数

示例

import { useCoGuestState } from 'tuikit-atomicx-vue3';

const { unsubscribeEvent } = useCoGuestState();

// 调用函数
await unsubscribeEvent({ event: /* HostEvent | GuestEvent */, callback: /* Function */ });

CoHostState

管理直播连麦功能,包括连麦邀请、接受、拒绝、退出以及连麦过程中的用户管理和事件处理

响应式数据

coHostStatus

const coHostStatus: ComputedRef<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

const connected: Ref<SeatUserInfo[]>
存储当前已连麦的用户信息列表
类型: 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

const applicant: Ref<SeatUserInfo | null>
存储当前申请连麦的用户信息
类型: 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

const invitees: Ref<SeatUserInfo[]>
存储当前已发出连麦邀请的用户列表
类型: 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

const candidates: ComputedRef<SeatUserInfo[]>
计算可以邀请连麦的用户列表,排除自己、已连麦用户、已邀请用户和申请者
类型: 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

function requestHostConnection(params: Object): Promise<Map<string, TUIConnectionCode>>
向指定直播间发起连麦请求,可以配置布局模板和超时时间

参数

参数名 类型 必填 描述
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

function cancelHostConnection(params: Object): Promise<void>
取消已发出的连麦请求

参数

参数名 类型 必填 描述
liveId string 目标直播间ID

示例

const { cancelHostConnection } = useCoHostState();

// 取消连麦请求
try {
  await cancelHostConnection({
    liveId: 'live_123'
  });
  console.log('连麦请求已取消');
} catch (error) {
  console.error('取消连麦请求失败:', error);
}

acceptHostConnection

function acceptHostConnection(params: Object): Promise<void>
接受收到的连麦请求,开始连麦

参数

参数名 类型 必填 描述
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

function rejectHostConnection(params: Object): Promise<void>
拒绝收到的连麦请求

参数

参数名 类型 必填 描述
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

function exitHostConnection(): Promise<void>
退出当前的连麦状态,断开连麦连接

示例

const { exitHostConnection, coHostStatus } = useCoHostState();

// 退出连麦
const handleExitCoHost = async () => {
  if (coHostStatus.value === CoHostStatus.Connected) {
    try {
      await exitHostConnection();
      console.log('已退出连麦');
    } catch (error) {
      console.error('退出连麦失败:', error);
    }
  }
};

subscribeEvent

function subscribeEvent(event: CoHostEvent, callback: CoHostEventCallback): Promise<void>
订阅指定的连麦事件,当事件触发时会调用回调函数

参数

参数名 类型 必填 描述
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

function unsubscribeEvent(event: CoHostEvent, callback: CoHostEventCallback): Promise<void>
取消订阅指定的连麦事件回调函数

参数

参数名 类型 必填 描述
event CoHostEvent 要取消订阅的连麦事件类型
callback CoHostEventCallback 要移除的回调函数

示例

const { subscribeEvent, unsubscribeEvent } = useCoHostState();

const handleCoHostRequest = (eventInfo) => {
  console.log('连麦请求:', eventInfo);
};

// 订阅事件
subscribeEvent(CoHostEvent.onCoHostRequestReceived, handleCoHostRequest);

// 取消订阅
unsubscribeEvent(CoHostEvent.onCoHostRequestReceived, handleCoHostRequest);

DeviceState

管理音视频设备的状态和操作,包括麦克风、摄像头、扬声器和屏幕分享等功能

响应式数据

microphoneStatus

const microphoneStatus: Ref<DeviceStatus>
当前麦克风的开启/关闭状态
类型: 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

const microphoneList: Ref<TUIDeviceInfo[]>
系统中可用的麦克风设备列表
类型: 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

const currentMicrophone: Ref<TUIDeviceInfo | null>
当前正在使用的麦克风设备信息
类型: 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

const microphoneLastError: Ref<DeviceError>
记录麦克风操作的最后一次错误状态
类型: 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

const isMicrophoneTesting: Ref<boolean>
是否正在进行麦克风设备测试
类型: 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

const currentMicVolume: Ref<number>
实时的麦克风音量检测值
类型: 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

const captureVolume: Ref<number>
麦克风音频采集的音量大小,范围0-100
类型: 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

const testingMicVolume: Ref<number>
麦克风测试过程中的音量检测值
类型: 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

const cameraStatus: Ref<DeviceStatus>
当前摄像头的开启/关闭状态
类型: 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

const cameraList: Ref<TUIDeviceInfo[]>
系统中可用的摄像头设备列表
类型: 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

const currentCamera: Ref<TUIDeviceInfo | null>
当前正在使用的摄像头设备信息
类型: 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

const cameraLastError: Ref<DeviceError>
记录摄像头操作的最后一次错误状态
类型: 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

const isCameraTesting: Ref<boolean>
是否正在进行摄像头设备测试
类型: 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

const isCameraTestLoading: Ref<boolean>
摄像头测试是否正在加载中
类型: 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

const isFrontCamera: Ref<boolean>
当前使用的是否为前置摄像头(移动端)
类型: 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

const localMirrorType: Ref<MirrorType>
本地视频画面的镜像显示模式
类型: 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

const localVideoQuality: Ref<VideoQuality>
本地视频的画质设置
类型: 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

const speakerList: Ref<TUIDeviceInfo[]>
系统中可用的扬声器设备列表
类型: 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

const currentSpeaker: Ref<TUIDeviceInfo | null>
当前正在使用的扬声器设备信息
类型: 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

const outputVolume: Ref<number>
扬声器音频输出的音量大小,范围0-100
类型: 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

const currentAudioRoute: Ref<AudioRoute>
当前音频输出的路由方式(扬声器/听筒等)
类型: 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

const isSpeakerTesting: Ref<boolean>
是否正在进行扬声器设备测试
类型: 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

const screenStatus: Ref<DeviceStatus>
当前屏幕分享的开启/关闭状态
类型: 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

const screenLastError: Ref<DeviceError>
记录屏幕分享操作的最后一次错误状态
类型: 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

const networkInfo: Ref<NetworkInfo | null>
当前网络连接的质量和状态信息
类型: 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

function openLocalMicrophone(): Promise<void>
开启本地麦克风设备,开始音频采集,并处理各种可能的错误情况

示例

const { openLocalMicrophone } = useDeviceState();

// 开启麦克风
try {
  await openLocalMicrophone();
  console.log('麦克风开启成功');
} catch (error) {
  console.error('麦克风开启失败:', error);
}

closeLocalMicrophone

function closeLocalMicrophone(): Promise<void>
关闭本地麦克风设备,停止音频采集

示例

const { closeLocalMicrophone } = useDeviceState();

// 关闭麦克风
await closeLocalMicrophone();

muteLocalAudio

function muteLocalAudio(): Promise<void>
静音本地音频,不关闭麦克风设备但停止音频传输

示例

const { muteLocalAudio } = useDeviceState();

// 静音本地音频
await muteLocalAudio();

unmuteLocalAudio

function unmuteLocalAudio(): Promise<void>
取消静音本地音频,恢复音频传输

示例

const { unmuteLocalAudio } = useDeviceState();

// 取消静音本地音频
await unmuteLocalAudio();

getMicrophoneList

function getMicrophoneList(): Promise<void>
获取系统中可用的麦克风设备列表,并更新当前选中的麦克风

示例

const { getMicrophoneList, microphoneList } = useDeviceState();

// 获取麦克风列表
try {
  await getMicrophoneList();
  console.log('麦克风列表:', microphoneList.value);
} catch (error) {
  console.error('获取麦克风列表失败:', error);
}

setCurrentMicrophone

function setCurrentMicrophone(options: Object): Promise<void>
切换到指定的麦克风设备

参数

参数名 类型 必填 描述
deviceId string 要切换到的麦克风设备ID

示例

const { setCurrentMicrophone } = useDeviceState();

// 切换麦克风设备
await setCurrentMicrophone({ deviceId: 'microphone-device-id' });

startMicrophoneTest

function startMicrophoneTest(options: Object): Promise<void>
开始麦克风设备测试,可以检测麦克风音量变化

参数

参数名 类型 必填 描述
interval number =200] - 音量检测间隔(毫秒)

示例

const { startMicrophoneTest } = useDeviceState();

// 开始麦克风测试(默认200ms间隔)
await startMicrophoneTest({});

// 开始麦克风测试(自定义间隔)
await startMicrophoneTest({ interval: 100 });

stopMicrophoneTest

function stopMicrophoneTest(): Promise<void>
停止麦克风设备测试,取消音量检测

示例

const { stopMicrophoneTest } = useDeviceState();

// 停止麦克风测试
await stopMicrophoneTest();

setCaptureVolume

function setCaptureVolume(volume: number): Promise<void>
设置麦克风采集音量大小

参数

参数名 类型 必填 描述
volume number 音量大小(0-100)

示例

const { setCaptureVolume } = useDeviceState();

// 设置采集音量为80%
await setCaptureVolume(80);

getSpeakerList

function getSpeakerList(): Promise<void>
获取系统中可用的扬声器设备列表,并更新当前选中的扬声器

示例

const { getSpeakerList, speakerList } = useDeviceState();

// 获取扬声器列表
try {
  await getSpeakerList();
  console.log('扬声器列表:', speakerList.value);
} catch (error) {
  console.error('获取扬声器列表失败:', error);
}

setCurrentSpeaker

function setCurrentSpeaker(options: Object): Promise<void>
切换到指定的扬声器设备

参数

参数名 类型 必填 描述
deviceId string 要切换到的扬声器设备ID

示例

const { setCurrentSpeaker } = useDeviceState();

// 切换扬声器设备
await setCurrentSpeaker({ deviceId: 'speaker-device-id' });

setAudioRoute

function setAudioRoute(output: AudioRoute): Promise<void>
设置音频输出路由,可以选择扬声器或听筒模式

参数

参数名 类型 必填 描述
output AudioRoute 音频路由类型

示例

const { setAudioRoute } = useDeviceState();

// 设置为扬声器模式
await setAudioRoute(AudioRoute.Speakerphone);

// 设置为听筒模式
await setAudioRoute(AudioRoute.Earpiece);

startSpeakerTest

function startSpeakerTest(options: Object): Promise<void>
开始扬声器设备测试,播放指定的音频文件来测试扬声器

参数

参数名 类型 必填 描述
filePath string 测试音频文件路径

示例

const { startSpeakerTest } = useDeviceState();

// 开始扬声器测试
await startSpeakerTest({ filePath: '/path/to/test-audio.mp3' });

stopSpeakerTest

function stopSpeakerTest(): Promise<void>
停止扬声器设备测试,停止播放测试音频

示例

const { stopSpeakerTest } = useDeviceState();

// 停止扬声器测试
await stopSpeakerTest();

setOutputVolume

function setOutputVolume(volume: number): Promise<void>
设置扬声器播放音量大小

参数

参数名 类型 必填 描述
volume number 音量大小(0-100)

示例

const { setOutputVolume } = useDeviceState();

// 设置播放音量为60%
await setOutputVolume(60);

openLocalCamera

function openLocalCamera(): Promise<void>
开启本地摄像头设备,在移动端会根据前后摄像头设置进行开启

示例

const { openLocalCamera } = useDeviceState();

// 开启摄像头
try {
  await openLocalCamera();
  console.log('摄像头开启成功');
} catch (error) {
  console.error('摄像头开启失败:', error);
}

closeLocalCamera

function closeLocalCamera(): Promise<void>
关闭本地摄像头设备,停止视频采集

示例

const { closeLocalCamera } = useDeviceState();

// 关闭摄像头
await closeLocalCamera();

getCameraList

function getCameraList(): Promise<void>
获取系统中可用的摄像头设备列表,并更新当前选中的摄像头

示例

const { getCameraList, cameraList } = useDeviceState();

// 获取摄像头列表
try {
  await getCameraList();
  console.log('摄像头列表:', cameraList.value);
} catch (error) {
  console.error('获取摄像头列表失败:', error);
}

setCurrentCamera

function setCurrentCamera(options: Object): Promise<void>
切换到指定的摄像头设备

参数

参数名 类型 必填 描述
deviceId string 要切换到的摄像头设备ID

示例

const { setCurrentCamera } = useDeviceState();

// 切换摄像头设备
await setCurrentCamera({ deviceId: 'camera-device-id' });

switchCamera

function switchCamera(options: Object): Promise<void>
在移动端切换前置和后置摄像头

参数

参数名 类型 必填 描述
isFrontCamera boolean 是否切换到前置摄像头

示例

const { switchCamera } = useDeviceState();

// 切换到前置摄像头
await switchCamera({ isFrontCamera: true });

// 切换到后置摄像头
await switchCamera({ isFrontCamera: false });

switchMirror

function switchMirror(options: Object): Promise<void>
设置本地视频的镜像显示模式

参数

参数名 类型 必填 描述
mirror MirrorType 镜像类型(自动、启用、禁用)

示例

const { switchMirror } = useDeviceState();

// 启用镜像
await switchMirror({ mirror: MirrorType.Enable });

// 禁用镜像
await switchMirror({ mirror: MirrorType.Disable });

// 自动镜像
await switchMirror({ mirror: MirrorType.Auto });

updateVideoQuality

function updateVideoQuality(options: Object): Promise<void>
更新本地视频的质量设置

参数

参数名 类型 必填 描述
quality VideoQuality 视频质量(360P、540P、720P、1080P)

示例

const { updateVideoQuality } = useDeviceState();

// 设置为720P
await updateVideoQuality({ quality: VideoQuality.Quality720P });

// 设置为1080P
await updateVideoQuality({ quality: VideoQuality.Quality1080P });

startCameraTest

function startCameraTest(options: Object): Promise<void>
开始摄像头设备测试,在指定的视图中显示摄像头画面

参数

参数名 类型 必填 描述
view string 显示摄像头画面的视图ID

示例

const { startCameraTest } = useDeviceState();

// 开始摄像头测试
try {
  await startCameraTest({ view: 'camera-preview' });
  console.log('摄像头测试开始');
} catch (error) {
  console.error('摄像头测试失败:', error);
}

stopCameraTest

function stopCameraTest(): Promise<void>
停止摄像头设备测试,关闭摄像头预览

示例

const { stopCameraTest } = useDeviceState();

// 停止摄像头测试
await stopCameraTest();

startScreenShare

function startScreenShare(options?: Object): Promise<void>
开始屏幕分享,可以选择是否包含系统音频和指定分享的视图

参数

参数名 类型 必填 描述
screenAudio boolean 是否包含系统音频
view string 指定分享的视图ID

示例

const { startScreenShare } = useDeviceState();

// 开始屏幕分享(包含系统音频)
try {
  await startScreenShare({ screenAudio: true });
  console.log('屏幕分享开始成功');
} catch (error) {
  console.error('屏幕分享开始失败:', error);
}

// 开始屏幕分享(指定视图)
await startScreenShare({ view: 'window-123' });

stopScreenShare

function stopScreenShare(): Promise<void>
停止当前的屏幕分享

示例

const { stopScreenShare } = useDeviceState();

// 停止屏幕分享
await stopScreenShare();

FreeBeautyState

响应式数据

beautyConfig

const beautyConfig: Ref<FreeBeautyConfig>
包含磨皮、美白、红润三个维度的数值
类型: 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

function setFreeBeauty(config: FreeBeautyConfig): Promise<void>
更新内部缓存配置并调用实验性接口 `enableTestBeautyStyle` 进行预览。 注意:此方法仅用于调整时的实时预览,不会更新 `beautyConfig` 的值,也不会正式应用到推流中,直到调用 `saveBeautySetting`。

参数

参数名 类型 必填 描述
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

function saveBeautySetting(): Promise<void>
将当前的缓存预览配置同步到 `beautyConfig` 状态中。 如果当前摄像头处于开启状态 (DeviceStatus.On),会立即调用 `setBeautyStyle` 接口将美颜效果应用到视频流中。 保存后会清空内部的缓存配置。

示例

import { useFreeBeautyState } from 'tuikit-atomicx-vue3';

const { saveBeautySetting } = useFreeBeautyState();

// 调用函数
await saveBeautySetting();

LiveAudienceState

管理直播房间中的观众状态,包括观众列表、观众数量、管理员操作和事件订阅等功能

响应式数据

audienceList

const audienceList: AudienceInfo[]
计算属性,返回当前房间的观众列表(过滤掉主播)
类型: 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

const audienceCount: number
计算属性,返回当前房间的观众数量,当观众数量超过最大限制时显示总用户数
类型: 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

function fetchAudienceList(): Promise<AudienceInfo[]>
从房间引擎获取当前房间的用户列表,过滤掉主播,并更新观众列表状态

示例

const { fetchAudienceList, audienceList } = useLiveAudienceState();

// 获取观众列表
try {
  const list = await fetchAudienceList();
  console.log('观众列表:', list);
} catch (error) {
  console.error('获取观众列表失败:', error);
}

setAdministrator

function setAdministrator(params: Object): Promise<void>
将指定用户设置为房间管理员,管理员拥有更高的权限

参数

参数名 类型 必填 描述
userId string 用户ID

示例

const { setAdministrator } = useLiveAudienceState();

// 设置用户为管理员
await setAdministrator({ userId: 'user123' });

revokeAdministrator

function revokeAdministrator(params: Object): Promise<void>
将指定用户的管理员权限撤销,恢复为普通用户

参数

参数名 类型 必填 描述
userId string 用户ID

示例

const { revokeAdministrator } = useLiveAudienceState();

// 撤销用户管理员权限
await revokeAdministrator({ userId: 'user123' });

kickUserOutOfRoom

function kickUserOutOfRoom(params: Object): Promise<void>
将指定用户从当前房间中移除,该用户将无法继续参与直播

参数

参数名 类型 必填 描述
userId string 用户ID

示例

const { kickUserOutOfRoom } = useLiveAudienceState();

// 将用户踢出房间
await kickUserOutOfRoom({ userId: 'user123' });

disableSendMessage

function disableSendMessage(params: Object): Promise<void>
管理员可以禁用或启用指定用户在房间中发送消息的权限

参数

参数名 类型 必填 描述
userId string 用户ID
isDisable boolean 是否禁用消息发送

示例

const { disableSendMessage } = useLiveAudienceState();

// 禁用用户发送消息
await disableSendMessage({ userId: 'user123', isDisable: true });

// 启用用户发送消息
await disableSendMessage({ userId: 'user123', isDisable: false });

subscribeEvent

function subscribeEvent(event: LiveAudienceEvent, callback: Function): Promise<void>
订阅指定的观众事件,当事件触发时会调用对应的回调函数

参数

参数名 类型 必填 描述
event LiveAudienceEvent 要订阅的事件类型
callback Function 事件回调函数

示例

const { subscribeEvent } = useLiveAudienceState();

// 订阅观众加入事件
subscribeEvent(LiveAudienceEvent.onAudienceJoined, (eventInfo) => {
  console.log('观众加入:', eventInfo.audience);
});

unsubscribeEvent

function unsubscribeEvent(event: LiveAudienceEvent, callback: Function): Promise<void>
取消订阅指定的观众事件,移除对应的事件回调函数

参数

参数名 类型 必填 描述
event LiveAudienceEvent 要取消订阅的事件类型
callback Function 要移除的事件回调函数

示例

const { unsubscribeEvent } = useLiveAudienceState();

// 定义回调函数
const handleAudienceJoined = (eventInfo) => {
  console.log('观众加入:', eventInfo.audience);
};

// 取消订阅观众加入事件
unsubscribeEvent(LiveAudienceEvent.onAudienceJoined, handleAudienceJoined);

LoginState

响应式数据

loginUserInfo

const loginUserInfo: Ref<LoginUserInfo | null>
存储当前登录用户的详细信息,包括用户ID、昵称、头像等
类型: 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

const logout: Ref<unknown>
退出当前用户的登录状态,清空用户信息
类型: 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

function login(options: LoginParams): Promise<void>
使用提供的参数登录到 TUI 系统

参数

参数名 类型 必填 描述
userId string 用户ID
userSig string 用户签名
sdkAppId number SDK应用ID

示例

await login({
  userId: 'user123',
  userSig: 'signature',
  sdkAppId: 123456
});

setSelfInfo

function setSelfInfo(options: SetSelfInfoParams): Promise<void>
更新当前登录用户的个人资料信息

参数

参数名 类型 必填 描述
userName string 用户昵称
avatarUrl string 用户头像URL
customInfo Record<string, any> 自定义信息

示例

await setSelfInfo({
  userName: '新昵称',
  avatarUrl: 'https://example.com/avatar.jpg',
  customInfo: { level: 5 }
});

MessageListState

管理聊天消息列表的状态和操作,包括消息加载、滚动控制、已读回执、消息高亮等功能

响应式数据

activeConversationID

const activeConversationID: Ref<string | undefined>
当前正在查看的会话唯一标识符,切换会话时会自动更新
类型: 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

const messageList: Ref<readonly MessageModel[] | undefined>
当前会话的消息列表,包含所有已加载的消息,会随着消息发送、接收、撤回等操作自动更新
类型: 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

const hasMoreOlderMessage: Ref<boolean | undefined>
标识当前会话是否还有更早的历史消息可以加载,用于判断是否显示加载更多按钮
类型: 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

const hasMoreNewerMessage: Ref<boolean | undefined>
标识当前会话是否有更新的消息可以加载,用于消息同步场景
类型: 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

const enableReadReceipt: Ref<boolean | undefined>
控制是否显示消息的已读回执状态,启用后可以看到对方是否已读消息
类型: 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

const isDisableScroll: Ref<boolean | undefined>
控制消息列表是否禁用自动滚动,通常在用户查看历史消息时禁用
类型: 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

const recalledMessageIDSet: Ref<Set<string>>
存储所有已撤回消息的ID,用于在引用消息中标识被撤回的原消息
类型: 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

const highlightMessageIDSet: Ref<Set<string>>
存储当前需要高亮显示的消息ID,用于实现消息定位和高亮效果
类型: 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

function loadMoreOlderMessage(): Promise<void>
加载当前会话的更多历史消息(更早的消息),用于实现消息列表的上拉加载功能

示例

import { useMessageListState } from 'tuikit-atomicx-vue3';

const { loadMoreOlderMessage } = useMessageListState();

// 调用函数
await loadMoreOlderMessage();

loadMoreNewerMessage

function loadMoreNewerMessage(): Promise<void>

示例

import { useMessageListState } from 'tuikit-atomicx-vue3';

const { loadMoreNewerMessage } = useMessageListState();

// 调用函数
await loadMoreNewerMessage();

setEnableReadReceipt

function setEnableReadReceipt(enableReadReceipt: boolean | undefined): void
启用或禁用消息已读回执功能

参数

参数名 类型 必填 描述
enableReadReceipt boolean | undefined 是否启用已读回执,true 启用,false 禁用

示例

import { useMessageListState } from 'tuikit-atomicx-vue3';

const { setEnableReadReceipt } = useMessageListState();

// 调用函数
await setEnableReadReceipt({ enableReadReceipt: /* boolean | undefined */ });

setIsDisableScroll

function setIsDisableScroll(isDisableScroll: boolean): void
设置消息列表是否禁用自动滚动功能

参数

参数名 类型 必填 描述
isDisableScroll boolean 是否禁用滚动,true 禁用,false 启用

示例

import { useMessageListState } from 'tuikit-atomicx-vue3';

const { setIsDisableScroll } = useMessageListState();

// 调用函数
await setIsDisableScroll({ isDisableScroll: true });

highlightMessage

function highlightMessage(options: object): void
临时高亮显示指定的消息,在指定时间后自动取消高亮,用于消息定位和提示

参数

参数名 类型 必填 描述
messageID string 要高亮的消息ID
duration number 高亮持续时间(毫秒)

示例

import { useMessageListState } from 'tuikit-atomicx-vue3';

const { highlightMessage } = useMessageListState();

// 调用函数
await highlightMessage({
  messageID: 'example_messageID',
  duration: 0,
});

RoomParticipantState

响应式数据

participantList

const participantList: Ref<RoomParticipant[]>
包含当前房间内所有通过 getParticipantList 获取的参与者信息,会随着参与者加入/离开自动更新
类型: 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

const participantListCursor: Ref<string>
用于分页获取参与者列表时的游标,空字符串表示已获取全部数据
类型: 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

const adminList: Ref<RoomUser[]>
房间管理员列表
类型: 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

const audienceList: Ref<RoomUser[]>
房间观众列表
类型: 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

const audienceListCursor: Ref<string>
用于分页获取观众列表时的游标,空字符串表示已获取全部数据
类型: 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

const messageDisabledUserList: Ref<RoomUser[]>
房间被禁言的用户列表
类型: 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

const participantListWithVideo: Ref<RoomParticipant[]>
过滤出所有摄像头状态为开启的参与者,用于视频布局展示
类型: 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

const participantWithScreen: Ref<RoomParticipant | null>
当前正在进行屏幕共享的参与者信息,如果没有人共享屏幕则为 null
类型: 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

const localParticipant: Ref<RoomParticipant | null>
当前登录用户在房间内的参与者信息,如果未加入房间则为 null
类型: 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

const pendingDeviceApplications: Ref<DeviceRequestInfo[]>
其他参与者向管理员/房主申请开启设备的请求列表,管理员可以批准或拒绝
类型: 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

const pendingDeviceInvitations: Ref<DeviceRequestInfo[]>
管理员/房主邀请当前用户开启设备的请求列表,用户可以接受或拒绝
类型: 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

const speakingUsers: Ref<Map<string, number>>
存储当前正在说话的用户及其音量值,Map 的 key 为 userId,value 为音量值(0-100)
类型: 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

const networkQualities: Ref<Map<string, NetworkInfo>>
存储各参与者的网络质量信息,Map 的 key 为 userId,value 为网络信息对象
类型: 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

const pendingParticipantList: Ref<RoomParticipant[]>
包含已被预约或正在呼叫中但尚未进入房间的参与者列表
类型: 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

const searchUser: Ref<unknown>
类型: 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

const promoteToParticipant: Ref<unknown>
类型: 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

const demoteToAudience: Ref<unknown>
类型: 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

function getParticipantList(options: Object): Promise<{ participantList: RoomParticipant[]; cursor: string }>
* 分页获取房间内的参与者列表,首次调用时会自动获取前 300 名参与者,后续可通过 cursor 继续获取。 用户加入房间后,必须手动调用 `getParticipantList({ cursor: '' })` 来获取房间中已有的参与者列表。 用户调用 `getParticipantList` 后,会自动获取房间中已有的参与者列表,并更新 `participantList` 状态。

参数

参数名 类型 必填 描述
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

function getAudienceList(options: Object): Promise<{ audienceList: RoomUser[]; cursor: string }>
* 分页获取房间内的观众列表,首次调用时会自动获取前 300 名观众,后续可通过 cursor 继续获取。 用户加入房间后,必须手动调用 `getAudienceList({ cursor: '' })` 来获取房间中已有的观众列表。 用户调用 `getAudienceList` 后,会自动获取房间中已有的观众列表,并更新 `audienceList` 状态。

参数

参数名 类型 必填 描述
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

function transferOwner(options: Object): Promise<void>
将房间所有者权限转移给指定用户,只有当前房间所有者才能执行此操作。转移后,当前用户将变为普通成员

参数

参数名 类型 必填 描述
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

function setAdmin(options: Object): Promise<void>
将指定用户设置为房间管理员,赋予管理权限。只有房间所有者才能执行此操作

参数

参数名 类型 必填 描述
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

function revokeAdmin(options: Object): Promise<void>
撤销指定用户的管理员权限,将其降级为普通用户。只有房间所有者才能执行此操作

参数

参数名 类型 必填 描述
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

function kickParticipant(options: Object): Promise<void>
将指定用户踢出房间,只有房间所有者或管理员才能执行此操作

参数

参数名 类型 必填 描述
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

function updateParticipantNameCard(options: Object): Promise<void>
更新指定用户在房间内的显示名称(名片),房主和管理员可以修改任意用户的名片,普通用户只能修改自己的名片

参数

参数名 类型 必填 描述
userId string 目标用户ID
nameCard string 新的名片内容

示例

import { useRoomParticipantState } from 'tuikit-atomicx-vue3';

const { updateParticipantNameCard } = useRoomParticipantState();

// 调用函数
await updateParticipantNameCard({
  userId: 'user_001',
  nameCard: '我的名片',
});

updateParticipantMetaData

function updateParticipantMetaData(options: Object): Promise<void>
更新指定用户的自定义元数据信息,可用于存储业务相关的扩展数据

参数

参数名 类型 必填 描述
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

function closeParticipantDevice(options: Object): Promise<void>
管理员/房主强制关闭指定用户的设备(摄像头、麦克风或屏幕共享),被关闭设备的用户将收到 onParticipantDeviceClosed 事件通知

参数

参数名 类型 必填 描述
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

function muteParticipantMessage(options: Object): Promise<void>
管理员/房主对指定用户进行禁言或解禁操作,被禁言的用户将无法发送消息,用户将收到 onParticipantMessageMuted 事件通知

参数

参数名 类型 必填 描述
userId string 目标用户ID
mute boolean true 表示禁言,false 表示解禁

示例

import { useRoomParticipantState } from 'tuikit-atomicx-vue3';

const { muteParticipantMessage } = useRoomParticipantState();

// 调用函数
await muteParticipantMessage({
  userId: 'user_001',
  mute: true,
});

disableAllDevices

function disableAllDevices(options: Object): Promise<void>
管理员/房主禁用或启用房间内所有用户的指定设备,禁用后用户无法自行开启该设备。所有用户将收到 onAllDevicesDisabled 事件通知

参数

参数名 类型 必填 描述
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

function disableAllMessages(options: Object): Promise<void>
管理员/房主禁用或启用房间内所有用户的消息发送权限(全体禁言)。所有用户将收到 onAllMessagesDisabled 事件通知

参数

参数名 类型 必填 描述
disable boolean true 表示禁用(全体禁言),false 表示启用

示例

import { useRoomParticipantState } from 'tuikit-atomicx-vue3';

const { disableAllMessages } = useRoomParticipantState();

// 调用函数
await disableAllMessages({
  disable: true,
});

requestToOpenDevice

function requestToOpenDevice(options: Object): Promise<void>
普通用户向管理员/房主申请开启指定设备(当设备被全体禁用时使用)。管理员将收到 onDeviceRequestReceived 事件通知

参数

参数名 类型 必填 描述
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

function cancelOpenDeviceRequest(options: Object): Promise<void>
取消之前发起的设备开启申请。管理员将收到 onDeviceRequestCancelled 事件通知

参数

参数名 类型 必填 描述
device DeviceType 要取消申请的设备类型(Camera/Microphone/ScreenShare)

示例

import { useRoomParticipantState } from 'tuikit-atomicx-vue3';

const { cancelOpenDeviceRequest } = useRoomParticipantState();

// 调用函数
await cancelOpenDeviceRequest({
  device: 'Camera',
});

approveOpenDeviceRequest

function approveOpenDeviceRequest(options: Object): Promise<void>
管理员/房主批准用户的设备开启申请,申请者将收到 onDeviceRequestApproved 事件通知并可以开启设备

参数

参数名 类型 必填 描述
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

function rejectOpenDeviceRequest(options: Object): Promise<void>
管理员/房主拒绝用户的设备开启申请,申请者将收到 onDeviceRequestRejected 事件通知

参数

参数名 类型 必填 描述
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

function inviteToOpenDevice(options: Object): Promise<void>
管理员/房主邀请指定用户开启设备,被邀请者将收到 onDeviceInvitationReceived 事件通知

参数

参数名 类型 必填 描述
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

function cancelOpenDeviceInvitation(options: Object): Promise<void>
管理员/房主取消之前发起的设备开启邀请,被邀请者将收到 onDeviceInvitationCancelled 事件通知

参数

参数名 类型 必填 描述
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

function acceptOpenDeviceInvitation(options: Object): Promise<void>
用户接受管理员/房主的设备开启邀请,邀请者将收到 onDeviceInvitationAccepted 事件通知

参数

参数名 类型 必填 描述
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

function declineOpenDeviceInvitation(options: Object): Promise<void>
用户拒绝管理员/房主的设备开启邀请,邀请者将收到 onDeviceInvitationDeclined 事件通知

参数

参数名 类型 必填 描述
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

function muteMicrophone(): Promise<void>
静音本地麦克风, 常用于打开麦克风场景下但不向远端推音频流

示例

// 打开麦克风但不向远端推音频流(常用于会议场景下短暂静音场景)
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

function unmuteMicrophone(): Promise<void>
取消静音本地麦克风,恢复 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 unmuteMicrophone();

subscribeEvent

function subscribeEvent(event: RoomParticipantEvent, callback: Function): void
订阅房间参与者相关的事件,当事件触发时会调用回调函数

参数

参数名 类型 必填 描述
event RoomParticipantEvent 要订阅的事件名称,可选值包括:
callback Function 事件回调函数,参数类型根据事件类型而定

示例

import { useRoomParticipantState } from 'tuikit-atomicx-vue3';

const { subscribeEvent } = useRoomParticipantState();

// 调用函数
await subscribeEvent({ event: /* RoomParticipantEvent */, callback: /* Function */ });

unsubscribeEvent

function unsubscribeEvent(event: RoomParticipantEvent, callback: Function): void
取消之前订阅的房间参与者事件

参数

参数名 类型 必填 描述
event RoomParticipantEvent 要取消订阅的事件名称
callback Function 之前订阅时传入的回调函数(必须是同一个函数引用)

示例

import { useRoomParticipantState } from 'tuikit-atomicx-vue3';

const { unsubscribeEvent } = useRoomParticipantState();

// 调用函数
await unsubscribeEvent({ event: /* RoomParticipantEvent */, callback: /* Function */ });

RoomState

响应式数据

scheduledRoomList

const scheduledRoomList: Ref<RoomInfo[]>
包含当前用户所有预约房间的列表,会随着预约房间的创建、更新、取消等操作自动更新
类型: 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

const scheduledRoomListCursor: Ref<string>
用于分页加载预约房间列表,空字符串表示没有更多数据
类型: 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

const currentRoom: Ref<RoomInfo | null>
当用户加入房间后会更新为当前房间信息,离开房间后会置为 null
类型: 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

function getScheduledRoomList(options: object): Promise<{ scheduledRoomList: RoomInfo[]; cursor: string }>
分页获取当前用户的预约房间列表,结果会同步更新到 scheduledRoomList 响应式数据中

参数

参数名 类型 必填 描述
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

function getScheduledAttendees(options: object): Promise<{ attendees: RoomUser[]; cursor: string; totalAttendeesCount: number }>
分页获取指定预约房间的参会人员列表

参数

参数名 类型 必填 描述
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

function scheduleRoom(options: object): Promise<void>
创建一个新的预约房间,可设置房间名称、密码、开始结束时间、参会人等信息

参数

参数名 类型 必填 描述
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

function updateScheduledRoom(options: object): Promise<void>
更新已存在的预约房间配置,只有房间创建者可以更新

参数

参数名 类型 必填 描述
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

function addScheduledAttendees(options: object): Promise<void>
向预约房间中添加参会人员,被添加的用户会收到 onAddedToScheduledRoom 事件通知

参数

参数名 类型 必填 描述
roomId string 房间 ID
userIdList string[] 要添加的用户 ID 列表

示例

import { useRoomState } from 'tuikit-atomicx-vue3';

const { addScheduledAttendees } = useRoomState();
await addScheduledAttendees({
  roomId: 'room_123',
  userIdList: ['user3', 'user4']
});

removeScheduledAttendees

function removeScheduledAttendees(options: object): Promise<void>
从预约房间中移除参会人员,被移除的用户会收到 onRemovedFromScheduledRoom 事件通知

参数

参数名 类型 必填 描述
roomId string 房间 ID
userIdList string[] 要移除的用户 ID 列表

示例

import { useRoomState } from 'tuikit-atomicx-vue3';

const { removeScheduledAttendees } = useRoomState();
await removeScheduledAttendees({
  roomId: 'room_123',
  userIdList: ['user3']
});

cancelScheduledRoom

function cancelScheduledRoom(options: object): Promise<void>
取消已创建的预约房间,所有参会人会收到 onScheduledRoomCancelled 事件通知

参数

参数名 类型 必填 描述
roomId string 房间 ID

示例

import { useRoomState } from 'tuikit-atomicx-vue3';

const { cancelScheduledRoom } = useRoomState();
await cancelScheduledRoom({ roomId: 'room_123' });

createAndJoinRoom

function createAndJoinRoom(options: object): Promise<void>
创建一个新房间并立即加入,创建者自动成为房主。成功后 currentRoom 会更新为当前房间信息

参数

参数名 类型 必填 描述
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

function joinRoom(options: object): Promise<void>
加入已存在的房间,成功后 currentRoom 会更新为当前房间信息

参数

参数名 类型 必填 描述
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

function leaveRoom(): Promise<void>
离开当前所在房间,成功后 currentRoom 会置为 null。如果是房主离开,房间不会被销毁

示例

import { useRoomState } from 'tuikit-atomicx-vue3';

const { leaveRoom } = useRoomState();
await leaveRoom();

endRoom

function endRoom(): Promise<void>
结束当前房间,只有房主可以调用。房间结束后所有成员会被踢出,并收到 onRoomEnded 事件通知

示例

import { useRoomState } from 'tuikit-atomicx-vue3';

const { endRoom } = useRoomState();
await endRoom();

updateRoomInfo

function updateRoomInfo(options: object): Promise<void>
更新房间的基本信息,如房间名称、密码等

参数

参数名 类型 必填 描述
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

function getRoomInfo(options: object): Promise<RoomInfo>
获取指定房间的详细信息

参数

参数名 类型 必填 描述
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

function getPendingCalls(options: object): Promise<{ calls: RoomCall[]; cursor: string }>
分页获取指定房间中待处理的呼叫请求列表

参数

参数名 类型 必填 描述
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

function callUserToRoom(options: object): Promise<Map<string, RoomCallResult>>
向指定用户发送加入房间的呼叫邀请,被呼叫用户会收到 onCallReceived 事件通知

参数

参数名 类型 必填 描述
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

function cancelCall(options: object): Promise<void>
取消对指定用户的呼叫邀请,被取消的用户会收到 onCallCancelled 事件通知

参数

参数名 类型 必填 描述
roomId string 房间 ID
userIdList string[] 要取消呼叫的用户 ID 列表

示例

import { useRoomState } from 'tuikit-atomicx-vue3';

const { cancelCall } = useRoomState();
// 取消呼叫
await cancelCall({
  roomId: 'room_123',
  userIdList: ['user1', 'user2']
});

acceptCall

function acceptCall(options: object): Promise<void>
接受来自其他用户的呼叫邀请,接受后会自动加入对应房间。呼叫方会收到 onCallAccepted 事件通知

参数

参数名 类型 必填 描述
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

function rejectCall(options: object): Promise<void>
拒绝来自其他用户的呼叫邀请。呼叫方会收到 onCallRejected 事件通知

参数

参数名 类型 必填 描述
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

function subscribeEvent(event: string, callback: EventCallback): void
订阅房间事件

参数

参数名 类型 必填 描述
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

function unsubscribeEvent(event: string, callback: EventCallback): void
取消订阅房间事件

参数

参数名 类型 必填 描述
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

const virtualBackgroundConfig: Ref<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

function isSupported(): boolean
检测当前环境是否支持虚拟背景

示例

import { useVirtualBackgroundState } from 'tuikit-atomicx-vue3';

const { isSupported } = useVirtualBackgroundState();
if (isSupported()) {
  // 初始化虚拟背景
}

initVirtualBackground

function initVirtualBackground(params: Object): Promise<void>
初始化虚拟背景

参数

参数名 类型 必填 描述
assetsPath string 资源文件路径

示例

import { useVirtualBackgroundState } from 'tuikit-atomicx-vue3';

const { initVirtualBackground } = useVirtualBackgroundState();
// 初始化虚拟背景
await initVirtualBackground({
  assetsPath: '/path/to/assets'
});

setVirtualBackground

function setVirtualBackground(params: VirtualBackgroundConfig): Promise<void>
设置虚拟背景参数 注意:此方法仅用于调整时的实时预览,不会更新 `virtualBackgroundConfig` 的值,也不会正式应用到推流中,直到调用 `saveVirtualBackground`。

参数

参数名 类型 必填 描述
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

function saveVirtualBackground(): Promise<void>
保存并应用虚拟背景配置

示例

import { useVirtualBackgroundState } from 'tuikit-atomicx-vue3';

const { saveVirtualBackground } = useVirtualBackgroundState();
// 保存虚拟背景配置
await saveVirtualBackground();

subscribeEvent

function subscribeEvent(event: VirtualBackgroundEvent, callback: VirtualBackgroundEventCallback): void
订阅虚拟背景事件

参数

参数名 类型 必填 描述
event VirtualBackgroundEvent 事件名称
callback VirtualBackgroundEventCallback 事件回调函数

示例

import { useVirtualBackgroundState, VirtualBackgroundEvent } from 'tuikit-atomicx-vue3';

const { subscribeEvent } = useVirtualBackgroundState();
// 订阅虚拟背景事件
subscribeEvent(VirtualBackgroundEvent.onAbort, () => {
  console.log('虚拟背景发生错误');
});

unsubscribeEvent

function unsubscribeEvent(event: VirtualBackgroundEvent, callback: VirtualBackgroundEventCallback): void
取消订阅虚拟背景事件

参数

参数名 类型 必填 描述
event VirtualBackgroundEvent 事件名称
callback VirtualBackgroundEventCallback 事件回调函数

示例

import { useVirtualBackgroundState, VirtualBackgroundEvent } from 'tuikit-atomicx-vue3';

const { unsubscribeEvent } = useVirtualBackgroundState();
// 取消订阅虚拟背景事件
unsubscribeEvent(VirtualBackgroundEvent.onAbort, () => {
  console.log('虚拟背景发生错误');
});

VirtualBackgroundEvent

*虚拟背景事件列表** 通过 `useVirtualBackgroundState()` 获取状态和 `subscribeEvent` 方法来订阅事件。

事件列表

onAbort

onAbort
虚拟背景运行过程中发生错误时触发。 当虚拟背景处理器遇到无法恢复的错误时会触发此事件, 例如:WebGL 上下文丢失、模型加载失败、内存不足等情况。 收到此事件后,建议关闭虚拟背景功能并提示用户。

示例

import { useVirtualBackgroundState, VirtualBackgroundEvent } from 'tuikit-atomicx-vue3';

const { subscribeEvent } = useVirtualBackgroundState();

// 监听虚拟背景错误事件
subscribeEvent(VirtualBackgroundEvent.onAbort, () => {
  console.log('虚拟背景发生错误,已自动关闭');
  // 建议的处理方式:
  // 1. 关闭虚拟背景功能
  // 2. 提示用户虚拟背景已关闭
  // 3. 可选:引导用户重新开启或检查设备兼容性
});

VirtualBackgroundType

虚拟背景类型定义 提供虚拟背景相关的配置、类型和事件定义。

类型定义

VirtualBackgroundType

enum VirtualBackgroundType
表示虚拟背景的类型。

枚举值

枚举值 描述
blur 'blur' 背景模糊
image 'image' 自定义背景图片

VirtualBackgroundConfig

interface 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

onAddedToScheduledRoom
当您被添加到预约房间作为参与者时触发。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onAddedToScheduledRoom, ({ roomInfo }) => {
  console.log('被添加到预约房间:', roomInfo.roomName);
});

onRemovedFromScheduledRoom

onRemovedFromScheduledRoom
当您被从预约房间中移除时触发。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onRemovedFromScheduledRoom, ({ roomInfo, operator }) => {
  console.log(`被 ${operator.userName} 从 ${roomInfo.roomName} 移除`);
});

onScheduledRoomCancelled

onScheduledRoomCancelled
当您参与的预约房间被取消时触发。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onScheduledRoomCancelled, ({ roomInfo, operator }) => {
  console.log(`房间 ${roomInfo.roomName} 被 ${operator.userName} 取消`);
});

onScheduledRoomStartingSoon

onScheduledRoomStartingSoon
当预约房间即将开始时触发(提醒通知)。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onScheduledRoomStartingSoon, ({ roomInfo }) => {
  console.log(`房间 ${roomInfo.roomName} 即将开始!`);
});

onRoomEnded

onRoomEnded
当当前房间已结束时触发。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onRoomEnded, ({ roomInfo }) => {
  console.log(`房间 ${roomInfo.roomName} 已结束`);
});

onCallReceived

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

onCallCancelled
当来电被呼叫者取消时触发。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallCancelled, ({ roomInfo, call }) => {
  console.log(`来自 ${call.caller.userName} 的呼叫已取消`);
});

onCallTimeout

onCallTimeout
当来电超时未响应时触发。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallTimeout, ({ roomInfo, call }) => {
  console.log(`来自 ${call.caller.userName} 的呼叫已超时`);
});

onCallAccepted

onCallAccepted
当您发出的呼叫被被叫方接受时触发。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallAccepted, ({ roomInfo, call }) => {
  console.log(`${call.callee.userName} 接受了您的呼叫`);
});

onCallRejected

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

onCallHandledByOtherDevice
当来电在其他设备上被处理(接受/拒绝)时触发。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallHandledByOtherDevice, ({ roomInfo, isAccepted }) => {
  console.log(`呼叫已在其他设备上${isAccepted ? '接受' : '拒绝'}`);
});

onCallRevokedByAdmin

onCallRevokedByAdmin
当呼叫被管理员撤销/取消时触发。

示例

import { useRoomState, RoomEvent } from 'tuikit-atomicx-vue3';

const roomState = useRoomState();
roomState.subscribeEvent(RoomEvent.onCallRevokedByAdmin, ({ roomInfo, call, operator }) => {
  console.log(`呼叫被管理员 ${operator.userName} 撤销`);
});

RoomType

房间类型定义 提供预约房间和房间呼叫相关的类型定义。

类型定义

RoomType

enum RoomType
房间类型定义 提供预约房间和房间呼叫相关的类型定义。

枚举值

枚举值 描述
Standard 1 会议类型
Webinar 2 网络研讨会类型

RoomStatus

enum RoomStatus
表示房间的当前状态。

枚举值

枚举值 描述
Scheduled 1 房间已预约但未开始
Running 2 房间正在进行中

RoomCallStatus

enum RoomCallStatus
表示房间呼叫/邀请的当前状态。

枚举值

枚举值 描述
None 0 无活跃呼叫
Calling 1 呼叫进行中,等待响应
Timeout 2 呼叫超时无响应
Rejected 3 呼叫被被叫方拒绝

RoomCallResult

enum RoomCallResult
发起房间呼叫的结果。

枚举值

枚举值 描述
Success 0 呼叫发起成功
AlreadyInCalling 1 用户已在呼叫中
AlreadyInRoom 2 用户已在房间中

CallRejectReason

enum CallRejectReason
表示呼叫被拒绝的原因。

枚举值

枚举值 描述
Rejected 0 用户拒绝呼叫
InOtherRoom 1 用户已在其他房间中

RoomUser

interface RoomUser
表示房间系统中的用户信息。

属性

属性名 类型 必填 描述
userId string 用户唯一标识
userName string 用户显示名称
avatarUrl string 用户头像 URL

示例

const user: RoomUser = {
  userId: 'user123',
  userName: 'John Doe',
  avatarUrl: 'https://example.com/avatar.png'
};

RoomInfo

interface 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

interface 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

type 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

type CreateRoomOptions
创建并立即加入新房间时的配置选项。

属性

属性名 类型 必填 描述
roomName string 房间显示名称
password string 加入房间的密码
isAllMicrophoneDisabled boolean 是否默认禁用所有麦克风
isAllCameraDisabled boolean 是否默认禁用所有摄像头
isAllScreenShareDisabled boolean 是否禁用屏幕共享
isAllMessageDisabled boolean 是否禁用消息发送

示例

const options: CreateRoomOptions = {
  roomName: 'Quick Meeting',
  password: '123456',
  isAllMicrophoneDisabled: false
};

UpdateRoomOptions

type UpdateRoomOptions
更新现有房间时的配置选项。

属性

属性名 类型 必填 描述
roomName string 新的房间显示名称
password string 新的房间密码

示例

const options: UpdateRoomOptions = {
  roomName: 'Updated Meeting Name'
};

ParticipantEvent

事件列表

onParticipantJoined

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

onUserMessageDisabled

onAudiencePromotedToParticipant

onAudiencePromotedToParticipant

onParticipantDemotedToAudience

onParticipantDemotedToAudience

ParticipantType

类型定义

RoomParticipantRole

enum RoomParticipantRole
表示房间参与者的角色。

枚举值

枚举值 描述
Owner 0 房主
Admin 1 管理员
GeneralUser 2 普通用户

RoomParticipantStatus

enum RoomParticipantStatus
表示房间参与者的状态。

枚举值

枚举值 描述
None 'None' 未定义
Scheduled 'Scheduled' 预约房间
InCalling 'InCalling' 呼叫中
CallTimeout 'CallTimeout' 呼叫超时
CallRejected 'CallRejected' 呼叫被拒绝
InRoom 'InRoom' 在房间内

KickedOutOfRoomReason

enum KickedOutOfRoomReason
表示被踢出房间的原因。

枚举值

枚举值 描述
KickedByAdmin 'KickedByAdmin' 被管理员踢出房间
ReplacedByAnotherDevice 'ReplacedByAnotherDevice' 被其他设备替换
KickedByServer 'KickedByServer' 被服务端踢出
ConnectionTimeout 'ConnectionTimeout' 连接超时
InvalidStatusOnReconnect 'InvalidStatusOnReconnect' 离线期间态进房状发生变化(被踢出房间或者房间已解散)
RoomLimitExceeded 'RoomLimitExceeded' 房间人数超过限制

VideoStreamType

enum VideoStreamType
表示视频流类型。

枚举值

枚举值 描述
Screen 'screen' 屏幕流
Camera 'camera' 摄像头流

FillMode

enum FillMode
表示填充模式。

枚举值

枚举值 描述
Fill 'fill' 图像铺满屏幕
Fit 'fit' 图像长边填满屏幕,短边区域会被填充黑色

RoomLayoutTemplate

enum RoomLayoutTemplate
表示房间布局模板。

枚举值

枚举值 描述
GridLayout 'gridLayout' 网格布局
CinemaLayout 'cinemaLayout' 顶部拦布局
SidebarLayout 'sidebarLayout' 侧边栏布局
MobileLayout 'MobileLayout' 移动端布局
FloatMixLayout 'floatMixLayout' 浮动混合布局
LiveAudienceLayout 'liveAudienceLayout' 观众布局

RoomParticipant

interface RoomParticipant
表示房间参与者,继承自 RoomUser。

属性

属性名 类型 必填 描述
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

interface 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

enum TRTCBeautyStyle
表示美颜风格。

枚举值

枚举值 描述
TRTCBeautyStyleSmooth 0
TRTCBeautyStyleNature 1

FreeBeautyConfig

type 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

onReceiveTranscriberMessage

onRealtimeTranscriberStarted

onRealtimeTranscriberStarted

onRealtimeTranscriberStopped

onRealtimeTranscriberStopped

onRealtimeTranscriberError

onRealtimeTranscriberError

AsrType

类型定义

TranscriberMessage

interface TranscriberMessage
**Transcriber Message** The message of the transcriber.

属性

属性名 类型 必填 描述
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

type RealtimeTranscriberEventInfoMap
**Realtime Transcriber Event Info Map** The event info map of the realtime transcriber.

属性

属性名 类型 必填 描述
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

当前登录用户信息,包括用户ID、用户名、头像和自定义资料信息。

属性列表

属性名类型描述
userIdstring登录用户的 userId
userNamestring登录用户的 userName
avatarUrlstring登录用户的头像 URL
customInfoRecord<string, any>自定义资料信息对象

SetSelfInfoParams

设置用户个人信息的参数。

属性列表

属性名类型描述
userNamestring用户昵称
avatarUrlstring用户头像 URL
customInfoRecord<string, any>可选,自定义信息

LoginParams

用户登录参数。

属性列表

属性名类型描述
userIdstring用户ID
userSigstring用户签名
sdkAppIdnumberSDK 应用 ID

TUIRoomInfo

房间信息,用户可使用 roomEngine.fetchRoomInfo获取房间信息。

属性列表

属性名类型描述
roomIdstring房间 ID
roomNamestring房间名称,默认为 roomId
roomTypeTUIRoomType房间类型,默认为 TUIRoomType.kConference
isSeatEnabledboolean是否开启麦位控制,该属性 2.0.0 版本以后支持,默认为 false
seatModeTUISeatMode上麦模式(开启麦位控制后生效),该属性 2.0.0 版本以后支持,默认为 TUISeatMode.kFreeToTake
passwordstring房间密码,默认为空字符串,该属性 2.5.0 版本以后支持
isMicrophoneDisableForAllUserboolean是否开启全员禁音(创建房间可选参数,默认值为 false)
isScreenShareDisableForAllUserboolean是否开启禁止屏幕分享(创建房间可选参数,该属性自 v2.2.0 版本以后支持,默认值为 false)
isCameraDisableForAllUserboolean是否开启全员禁画(创建房间可选参数, 默认值为 false)
isMessageDisableForAllUserboolean是否允许所有用户发消息(创建房间可选参数,默认值为 false)
maxSeatCountnumber最大麦位数量,默认为 6
roomOwnerstring房间主持人ID,只读,v2.4.1 以上建议使用 ownerId
ownerIdstring房间主持人ID,只读,该属性 2.4.1 版本以后支持
ownerNamestring房间主持人昵称,只读,该属性 2.4.1 版本以后支持
ownerAvatarUrlstring房间主持人头像地址,只读,该属性 2.4.1 版本以后支持
createTimenumber房间创建时间,只读,精确到秒
roomMemberCountnumber房间成员数量,只读

TUIEnterRoomOptions

进房可选择参数。

属性列表

属性名类型描述
passwordstring房间密码,默认为空,表示没有密码

TUISeatLockParams

锁定麦位的操作参数

属性列表

属性名类型描述
lockSeatboolean锁定麦位
lockVideoboolean锁定麦位视频
lockAudioboolean锁定麦位音频

TUIMessage

消息结构体

属性列表

属性名类型描述
messageIdstring消息 Id
messagestring消息内容
timestampnumber时间戳信息, 精确到秒
userIdstring用户 Id
userNamestring用户名称
avatarUrlstring用户头像地址

TUINetwork

网络质量结构体

属性列表

属性名类型描述
userIdstring用户 Id
qualityTUINetworkQuality网络质量
upLossnumber上行丢包率,单位 (%) 该数值越小越好,目前仅本地用户有该信息
downLossnumber下行丢包率,单位 (%) 该数值越小越好,目前仅本地用户有该信息
delaynumber网络延迟,单位 ms,目前仅本地用户有该信息

TUIVideoEncoderParams

视频编码参数

属性列表

属性名类型描述
fpsnumber帧率设置
bitratenumber目标编码码率设置
qualityTUIVideoQuality上行视频分辨率
videoResolutionTUIVideoQuality上行视频分辨率(自 v1.6.0 版本开始支持,v1.6.0 之前版本请使用 quality 参数)
resolutionModeTUIResolutionMode横竖屏模式

TUIUserInfo

用户信息结构体

属性列表

属性名类型描述
userIdstring用户 Id
userNamestring用户名称
nameCardstring房间内用户名称,自 v2.5.0 支持
avatarUrlstring用户头像地址
userRoleTUIRole用户角色
hasAudioStreamboolean是否有音频流
hasVideoStreamboolean是否有视频流
hasScreenStreamboolean是否有屏幕分享流
isMessageDisabledboolean是否被禁止发送消息
roomCustomInfoobject用户房间自定义字段

TUISeatInfo

麦位信息结构体(来自 TUIRoomEngine)

属性列表

属性名类型描述
indexnumber麦位序号
userIdstring麦位对应的用户 Id
userNamestring用户名称
nameCardstring房间内用户名称,自 v2.5.0 支持
avatarUrlstring用户头像地址
isLockedboolean当前麦位是否被锁
isVideoLockedboolean当前麦位是否禁止视频
isAudioLockedboolean当前麦位是否禁止音频

SeatInfo

座位信息(UIKit 扩展),包含设备状态等额外信息

属性列表

属性名类型描述
indexnumber座位索引
isLockedboolean座位是否被锁定
isVideoLockedboolean座位视频是否被锁定
isAudioLockedboolean座位音频是否被锁定
userInfoSeatUserInfo | undefined座位上的用户信息,座位为空时为 undefined

SeatUserInfo

座位上的用户信息,包含设备状态和连麦信息

属性列表

属性名类型描述
roomIdstring房间 ID
userIdstring用户 ID
userNamestring用户名称
avatarUrlstring用户头像 URL
microphoneStatusDeviceStatus麦克风状态
cameraStatusDeviceStatus摄像头状态
onSeatTimestampnumber上座时间戳
networkQualityNetworkQuality | undefined网络质量
customInfoRecord<string, any>自定义信息

TUIRequest

请求结构体

属性列表

属性名类型描述
requestActionTUIRequestAction请求类型
timestampnumber请求发起时间
requestIdstring请求 ID
userIdstring发起请求的用户 ID
userNamestring用户名称
nameCardstring房间内用户名称,自 v2.5.0 支持
avatarUrlstring用户头像地址
contentstring其他内容

TUIRequestCallback

请求回调结构体

属性列表

属性名类型描述
requestCallbackTypeTUIRequestCallbackType请求回调类型
requestIdstring请求 ID
userIdstring用户 Id
codenumber请求响应码
messagestring请求补充说明

TUIDeviceInfo

设备信息结构体

属性列表

属性名类型描述
deviceIdstring设备 Id
deviceNamestring设备名称
devicePropertiesRecord<string, any>设备属性对象

NetworkInfo

网络信息详情

属性列表

属性名类型描述
qualityNetworkQuality网络质量等级
upLossnumber上行丢包率,单位 (%)
downLossnumber下行丢包率,单位 (%)
delaynumber网络延迟,单位 ms

TUIConferenceInfo

会议信息结构体

属性列表

属性名类型描述
scheduleStartTimenumber预定会议开始时间。
scheduleEndTimenumber预定会议结束时间。
scheduleAttendeesstring[]邀请参会成员列表。
reminderSecondsBeforeStartnumber会议开始前提醒时间(秒)。
statusTUIConferenceStatus房间状态(只读)。
basicRoomInfoTUIRoomInfo房间信息。

TUIConferenceModifyInfo

会议信息发生修改结构体

属性列表

属性名类型描述
scheduleStartTimenumber预定会议开始时间
scheduleEndTimenumber预定会议结束时间
basicRoomInfoobject房间基本信息
basicRoomInfo.roomIdstring房间 ID
basicRoomInfo.roomNamestring房间名称

TUIInvitation

会中邀请信息结构体

属性列表

属性名类型描述
statusTUIInvitationStatus会中邀请状态
inviteeTUIUserInfo受邀者
inviterTUIUserInfo邀请者

TUILiveInfo

直播间信息

属性列表

属性名类型描述
basicRoomInfoTUIRoomInfo房间信息,只读
isGiftEnabledboolean直播间是否支持礼物
isLikeEnabledboolean直播间是否支持点赞
isPublicVisibleboolean直播间是否公开
activityStatusnumber直播间活跃状态: 用户自定义标记
viewCountnumber累计观看次数,只读
coverUrlstring直播间封面图片 HTTP URL 地址,最大支持 200 个字节
backgroundUrlstring直播间背景图片 HTTP URL 地址,最大支持 200 个字节
categoryListArray<number>直播间分类标签,单个房间最大支持3个标记

TUILiveModifyInfo

直播间信息发生修改结构体

属性列表

属性名类型描述
roomIdstring直播间 ID
isPublicVisibleboolean可选,直播间是否公开
activityStatusnumber可选,直播间活跃状态: 用户自定义标记
coverUrlstring可选,直播间封面图片 HTTP URL 地址,最大支持 200 个字节
backgroundUrlstring可选,直播间背景图片 HTTP URL 地址,最大支持 200 个字节
categoryListArray<number>可选,直播间分类标签,单个房间最大支持3个标记

TUILiveModifyFlag

直播间修改标记位

属性列表

属性名类型描述
kNonenumber不修改
kActivityStatusnumber直播间活跃状态,支持自定义设置
kCoverUrlnumber直播间封面
kCategorynumber直播间分类
kEnableGiftnumber直播间支持发送礼物标记
kEnableLikenumber直播支持点赞标记
kPublicnumber直播间公开标记
kBackgroundUrlnumber直播间背景

AudienceInfo

观众信息

属性列表

属性名类型描述
userIdstring用户 ID
userNamestring用户名称
avatarUrlstring用户头像 URL
customInfoRecord<string, any>自定义信息
userRoleTUIRole用户角色
isMessageDisabledboolean是否禁止发送消息

LiveUserInfo

直播用户简要信息

属性列表

属性名类型描述
userIdstring用户 ID
userNamestring用户名称
avatarUrlstring用户头像 URL

SearchResult

搜索结果结构体,支持泛型

属性列表

属性名类型描述
resultListArray<T>搜索结果列表
hasMoreboolean是否有更多结果
cursorstring分页游标
totalCountnumber总结果数量
paramsRecord<string, any>搜索参数