TUIKit implements the sending and display for basic message types such as text, image, audio, video, and file messages by default. If these message types do not meet your needs, you can add custom message types.
Basic Message Types
Message Type
Renderings
Text message
Image message
Audio message
Video message
File message
Custom message
If the basic message types do not meet your needs, you can customize the messages based on actual business needs.
There are several custom message styles built into TUIKit, as shown in the following figure:
Custom message preset styles
Renderings
Hypertext message
Evaluation Message
Order Message
The following uses sending a custom hypertext message that can redirect to the browser as an example, assisting you to promptly understand the implementation process.
Displaying a Custom Message
The hypertext custom message cell Element (XML) built into TUIKit is depicted in the figure below:
Custom messages and other common types of messages are received in the same way; all types of messages are monitored for access via TUIStore.watch(StoreName.CHAT, { messageList: onMessageListUpdated }).
The received custom messages are presented in the message list in different forms according to their respective specific type fields.
The following will explain how to display custom messages.
Creating the display structure for the custom message
The display of custom messages is primarily accomplished by rendering messageCustom in the content area of the custom message type messageBubble.
You can add the display structure style you need for custom messages in the file at src/TUIKit/components/TUIChat/message-list/message-elements/message-custom.vue.
For instance, the following code demonstrates the display structure for a hypertext message:
You can send a custom message by calling the TUIChatService.sendCustomMessage method in the logical layer engine of TUIKit. For details, please refer to: SendCustomMessage.
Here are a few examples of sending built-in custom style messages in TUIKit: