MessageContent 类(macOS IMLib)
类继承图
Object→MessageContent
继承关系:Object → MessageContent。该内容联合体按 type 取值不包含行为方法,字段与 domain.json → schemas.Content 一一对应。
类说明
消息内容联合体:按 type 取不同字段,序列化后不超过 5KB;文本、图片、文件、语音、位置、自定义、撤回占位与系统通知共用该结构。
| 项 | 值 |
|---|---|
| 类型 | 数据结构(值对象) |
| 字段数 | 21 |
| IDL 定义 | domain.json → schemas.Content |
| 程序包 | @ni-paas-im/electron |
| 跨端一致性 | 字段名与取值在 7 个平台绑定中一致;仅语言类型映射不同 |
| 平台状态 | 已交付 |
字段概要
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
type | ContentType | 是 | 类型 |
text | string | 否 | text:非空 |
url | string | 否 | image/file/voice 必填 |
name | string | 否 | file |
size | uint64 | 否 | 字节数 |
mime | string | 否 | MIME 类型 |
width | uint32 | 否 | 图片宽度(px) |
height | uint32 | 否 | 图片高度(px) |
duration | uint32 | 否 | voice 1..300 秒 |
latitude | double | 否 | location [-90,90] |
longitude | double | 否 | location [-180,180] |
address | string | 否 | location,<=200 字 |
data | any | 否 | custom 任意 JSON |
mentionedInfo | MentionedInfo | 否 | 仅群聊/超级群 |
quote | Quote | 否 | 引用消息快照 |
recallMessageId | string | 否 | recall 占位 |
operatorId | string | 否 | recall 操作者 |
systemType | SystemType | 否 | system 消息子类型 |
extra | string | 否 | system 消息扩展 JSON 字符串 |
title | string | 否 | combine:合并转发标题,必填、非空、<=64 字(IDL rev19) |
items | CombineItem[] | 否 | combine:合并转发条目,必填、1..=100 条、顺序即展示顺序;全部条目 text 合计 <=16KB(IDL rev19) |
详细字段说明
ContentType type类型
string texttext:非空
string urlimage/file/voice 必填
string namefile
uint64 size字节数
string mimeMIME 类型
uint32 width图片宽度(px)
uint32 height图片高度(px)
uint32 durationvoice 1..300 秒
double latitudelocation [-90,90]
double longitudelocation [-180,180]
string addresslocation,<=200 字
any datacustom 任意 JSON
MentionedInfo mentionedInfo仅群聊/超级群
Quote quote引用消息快照
string recallMessageIdrecall 占位
string operatorIdrecall 操作者
SystemType systemTypesystem 消息子类型
string extrasystem 消息扩展 JSON 字符串
string titlecombine:合并转发标题,必填、非空、<=64 字(IDL rev19)
CombineItem[] itemscombine:合并转发条目,必填、1..=100 条、顺序即展示顺序;全部条目 text 合计 <=16KB(IDL rev19)
相关链接
- 关联类型:Message、IMClient
- 关联枚举:ContentType、MentionType、SystemType
- 关联方法:sendMessage、startStreamMessage、combineMessages
- 返回索引:类 / 枚举