tencent cloud

Tencent Real-Time Communication

소식 및 공지 사항
제품 업데이트
Tencent Cloud 오디오/비디오 단말 SDK 재생 업그레이드 및 권한 부여 인증 추가
TRTC 월간 구독 패키지 출시 관련 안내
제품 소개
제품 개요
기본 개념
제품 기능
제품 장점
응용 시나리오
성능 데이터
구매 가이드
Billing Overview
무료 시간 안내
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
과금 FAQ
Refund Instructions
신규 사용자 가이드
Demo 체험
Call
개요(TUICallKit)
Activate the Service
Run Demo
빠른 통합(TUICallKit)
오프라인 푸시
Conversational Chat
온클라우드 녹화(TUICallKit)
AI Noise Reduction
UI 사용자 정의
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
릴리스 노트
FAQs
라이브 스트리밍
Billing of Video Live Component
Overview
Activating the Service (TUILiveKit)
Demo 실행
No UI Integration
UI Customization
Live Broadcast Monitoring
Video Live Streaming
Voice Chat Room
Advanced Features
Client APIs
Server APIs
Error Codes
Release Notes
FAQs
RTC Engine
Activate Service
SDK 다운로드
API 코드 예시
Usage Guidelines
API 클라이언트 API
고급 기능
RTC RESTFUL API
History
Introduction
API Category
Room Management APIs
Stream mixing and relay APIs
On-cloud recording APIs
Data Monitoring APIs
Pull stream Relay Related interface
Web Record APIs
AI Service APIs
Cloud Slicing APIs
Cloud Moderation APIs
Making API Requests
Call Quality Monitoring APIs
Usage Statistics APIs
Data Types
Appendix
Error Codes
콘솔 가이드
애플리케이션 관리
사용량 통계
모니터링 대시보드
개발 보조
Solution
Real-Time Chorus
FAQs
과금 개요
기능 관련
UserSig 관련
방화벽 제한 처리
설치 패키지 용량 축소 관련 질문
Andriod 및 iOS 관련
Web 관련
Flutter 관련
Electron 관련
TRTCCalling Web 관련
멀티미디어 품질 관련
기타 질문
Protocols and Policies
컴플라이언스 인증
보안 백서
정보 보안에 관한 참고 사항
Service Level Agreement
Apple Privacy Policy: PrivacyInfo.xcprivacy
TRTC 정책
개인 정보 보호 정책
데이터 처리 및 보안 계약
용어집

Barrage Component(Web Desktop Browser)

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-10-20 11:20:44
This document provides a detailed introduction to the barrage component, including the barrage message component (BarrageList) and the message sending component (BarrageInput). You can refer to the sample code in this document for seamless integration of our pre-developed components into your existing project, or customize the style and layout according to your needs by following the component customization section in the document.


Component Composition

Component Name
Detailed Description
Barrage Message Component (BarrageList)
A component responsible for real-time display and management of barrage message streams, providing a complete message display solution including message list rendering, time aggregation, user interaction, and responsive adaptation.
Message Sending Component (BarrageInput)
An input component that provides rich text editing and message sending features, with seamless integration of emoji selector, character limit, status management, and cross-platform adaptation, offering users a smooth input experience.

Component Integration

Step 1: Configuring the Environment and Activating the Service

Before performing quick integration, you need to refer to preparations, meet the related environment configuration and activate the corresponding service.

Step 2: Installing Dependencies

npm
pnpm
yarn
npm install tuikit-atomicx-vue3 @tencentcloud/uikit-base-component-vue3 --save
pnpm add tuikit-atomicx-vue3 @tencentcloud/uikit-base-component-vue3
yarn add tuikit-atomicx-vue3 @tencentcloud/uikit-base-component-vue3

Step 3: Integrating the Barrage Component

Introduce and use the barrage component in your project. You can copy the following example directly to show a complete live streaming room barrage message component and message send component in your project.
<template>
<UIKitProvider theme="dark" language="en-US">
<div class="app">
<div class="chat-container">
<div class="chat-content">
<BarrageList class="barrage-list" />
</div>
<div class="chat-input">
<BarrageInput class="barrage-input" />
</div>
</div>
</div>
</UIKitProvider>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { UIKitProvider } from '@tencentcloud/uikit-base-component-vue3';
import { BarrageList, BarrageInput, useLoginState, useLiveState } from 'tuikit-atomicx-vue3';

const { login, loginUserInfo } = useLoginState();
const { joinLive } = useLiveState();

async function initLogin() {
try {
await login({
sdkAppId: 0, // SDKAppID, see Step 1 to get
userId: '', // UserID, see Step 1 to get
userSig: '', // userSig, see Step 1 to get
});
} catch (error) {
console.error('login error:', error);
}
}

onMounted(async () => {
await initLogin();
await joinLive({
liveId: 'input corresponding live streaming room LiveId', // enter live room by inputting corresponding liveId
});
});
</script>

<style scoped>.app{width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;padding:20px;box-sizing:border-box}.chat-container{width:100%;max-width:500px;height:600px;border-radius:16px;display:flex;flex-direction:column;overflow:hidden}.chat-content{flex:1;overflow:hidden}.barrage-list{width:100%;height:100%}.chat-input{background-color:var(--bg-color-dialog);padding:16px}.barrage-input{width:100%}</style>

Customize Component

Barrage Message Component provides users with various and dimensional Props APIs for custom requirements, allowing users to customize features or UI. Parameter content is as shown in the table below.
Note:
Note: To directly learn about the custom details of the Barrage Message Component (BarrageList), quickly jump to the following link: Barrage Message Component Customization;
Note: To directly learn about the custom details of the Message Sending Component (BarrageInput), quickly jump to the following link: Message Sending Component Customization;

Barrage Message Component (BarrageList) Customization

Props

Parameter Name
Parameter Type
Default Value
Description
messageAggregationTime
Number
300
Maximum time interval for message grouping (seconds).
filter
(message: IMessageModel) => boolean
-
Functions for filtering messages.
Message
Component
Message
Custom Message Component
MessageTimeDivider
Component
MessageTimeDivider
Custom Message Time Segmentation Component.
LocalNoticeMessage
Component
LocalNoticeMessage
Custom Local Notification Component.
containerStyle
CSSProperties
-
Custom message list container style.
itemStyle
CSSProperties
-
Custom single message item style.
height
String
-
Component height, supports CSS units.
style
CSSProperties
-
Specify the root element's custom style.
As indicated in the table above, the Props custom part of the Barrage Message Component consists of three sections: component properties, replaceable subcomponents, and custom styles. Specific content is as shown in the table below.
Content
Parameter
Component Property
filter,messageAggregationTime
Replaceable subcomponent
Message,MessageTimeDivider,LocalNoticeMessage
Custom style
ContainerStyle,ItemStyle,height,style

Filter Message

By setting the filter parameter, you can flexibly control the message content displayed in the barrage message component.
<BarrageList :filter="(message) => message.type === 'TIMTextElem'" />

Message Aggregation Time

By setting the messageAggregationTime parameter, you can control the grouping time interval.
<BarrageList :messageAggregationTime="300" />

Custom Style

Barrage Message Component provides containerStyle, itemStyle, custom child component, etc., for customizing component styles.
1. To customize the message list container style, you can pass a style object to the containerStyle attribute.
Example: Custom container padding
<BarrageList :containerStyle="{ padding: '0px' }" />
2. To customize a single message style, you can pass a style object to the itemStyle attribute.
Example: Custom message item spacing, border, and message bubble color
<BarrageList :itemStyle="{ borderRadius: '10px', background: '#1C66e5', padding: '10px', boxSizing: 'border-box'}" />
3. The barrage message component supports custom message display components, and you can fully control the rendering method.
Example: Custom Message Component
// MyCustomMessage.vue
<template>
<div class="custom-message">
<div class="message-header">
<span class="user-name">{{ getUserName(message) }}</span>
<span class="message-time">{{ formatTime(message.time) }}</span>
</div>
<div class="message-content">
{{ getMessageText(message) }}
</div>
</div>
</template>

<script setup lang="ts">
interface SimpleMessage {
id: string;
from: string;
nick?: string;
nameCard?: string;
time: number;
type: string;
content: string;
avatar?: string;
}

interface Props {
message: SimpleMessage;
isLastInChunk?: boolean;
}

const props = defineProps<Props>();

const formatTime = (timestamp: number) => {
return new Date(timestamp * 1000).toLocaleTimeString('zh-CN', {
hour: '2-digit',
minute: '2-digit'
});
};

const getUserName = (message: SimpleMessage) => {
return message.nameCard || message.nick || message.from || 'anonymous user';
};

const getMessageText = (message: SimpleMessage) => {
if (message.type === 'text') {
return message.content || '';
} else if (message.type === 'image') {
return '[image message]';
} else if (message.type === 'emoji') {
return '[emoji message]';
}
return '[other types of messages]';
};
</script>

<style scoped>.custom-message{background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:white;padding:12px;border-radius:12px;margin:4px 0;box-shadow:0 2px 8px rgba(0,0,0,0.1);transition:transform 0.2s ease}.custom-message:hover{transform:translateY(-2px)}.message-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;font-size:12px;opacity:0.9}.user-name{font-weight:500;max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.message-time{font-size:11px;opacity:0.7}.message-content{font-size:14px;line-height:1.4;word-break:break-word}</style>

// Use the barrage message component for use in
<template>
<BarrageList :Message="MyCustomMessage" />
</template>

<script setup lang="ts">
import MyCustomMessage from "./MyCustomMessage.vue";
</script>
Before modification
After modification
Custom container padding
Custom message item spacing and border
Custom Message Component









Message Sending Component (BarrageInput) Customization

Props

Parameter Name
Type
Default Value
Description
containerClass
String
''
Custom container CSS class name.
containerStyle
Record

{}
Inline style of custom container.
width
String
-
Component width, supports CSS units.
height
String
-
Component height, supports CSS units.
minHeight
String
'40px'
Minimum component height, supports CSS units.
maxHeight
String
'140px'
Max component height, supports CSS units.
placeholder
String
-
Placeholder text in the input box.
disabled
Boolean
false
Whether to disable the input box.
autoFocus
Boolean
true
Whether to auto-focus into the input box.
maxLength
Number
80
Maximum character limit for input content.

Events

Event Name
Parameter
Description
focus
-
Trigger when the input box gets focus.
blur
-
Trigger when the input box loses focus.
As indicated in the table above, the Props custom part of the Message Sending Component consists of three sections: size control, input restriction, and custom styles. Specific content is as shown in the table below.
Content
Parameter
Size control
width,height,minHeight,minWidth
Input restriction
maxLength
Custom style
ContainerStyle,ContainerClass

Size Control

By setting width, height, minHeight, maxHeight parameters, you can flexibly control the size of BarrageInput.
<BarrageInput width="400px" height="60px" minHeight="40px" maxHeight="120px" />

Input Restriction

By setting the maxLength parameter, you can control the maximum number of characters for input content.
<BarrageInput :maxLength="100" />

Custom Style

The message send component provides containerStyle and containerClass attributes for customizing component style.
1. To customize the input box container style, you can pass a style object to the containerStyle attribute.
Example: Custom container background and border rounded corners
<BarrageInput :containerStyle="{ backgroundColor: '#a8abb2', borderRadius: '0 0', boxShadow: '0 2px 8px rgba(0,0,0,0.1)'}" />
2. To customize the input box container class name, you can pass a class name string to the containerClass attribute.
Example: Custom container class name
<template>
<BarrageInput containerClass="my-custom-input-container" />
</template>

<style>.my-custom-input-container {background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);border: none;border-radius: 20px;padding: 8px 20px;}.my-custom-input-container:focus-within {box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);}</style>
Before modification
After modification
Custom container background and border rounded corners
Custom message item spacing and border





도움말 및 지원

문제 해결에 도움이 되었나요?

피드백