ChatBubble (消息气泡)
Telegram 式消息气泡:自己的靠右用主色阶,别人的靠左;回复与部分引用预览、照片与相册拼图(点击进灯箱)、跨站上下文卡片、回应条,右下角时间 / 已编辑 / 发送状态,失败可重试;服务消息是居中的小胶囊。
通常由 KunChatMessageList 渲染并排好位置;单独使用时自己决定左右对齐。
基础用法与连续消息
雪之下小春:
在吗在吗
雪之下小春:
你之前说的那个补丁我装上了
雪之下小春:
但是一进游戏就乱码,是不是要转区?
你:已编辑
对,用 Locale Emulator 转区再开就好了
Basic.vue
回复与引用
雪之下小春:
最后那个反转你猜到了吗?原来列车长就是白本人
你:
猜到一半,第三章那封信就有暗示了
你:
这句我也没想到
雪之下小春:
那条我删了哈哈
Reply.vue
照片与相册
雪之下小春:
雪之下小春:
片头曲好好听,这张是开场动画的截图
雪之下小春:
通关了!最喜欢的五张 CG
Media.vue
发送状态
你:
正在发送的消息
你:
已送达,对方还没看
你:
对方已读
你:
网络断了,没发出去
Status.vue
回应
樱小路露娜:
第三章校对完成,辛苦大家!
Reactions.vue
服务消息与上下文卡片
你 创建了群组「Galgame 汉化交流」
你 邀请了 雪之下小春、Ayase和樱小路露娜
樱小路露娜 将群名改为「汉化交流 · 校对组」
已注销用户 退出了群组
Service.vue
属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| message * | KunChatMessage | — | The message. For an album, the one it acts as (reactions, replies). |
| album | KunChatMessage[] | null | null | Every photo of an album, in order; omitted for anything else. |
| currentUserId | string | — | The viewer's id, so a service message can say "you". |
| disabled | boolean | false | Swallow clicks on the sender, reply and reactions, e.g. under a selection mode. |
| lightbox | boolean | true | Open photos in a built-in KunLightbox on click. The message list turns this off and shows every loaded photo in one lightbox instead. |
| own | boolean | false | Sent by the viewer: right-aligned, in the primary tint. |
| position | KunChatBubblePosition | "single" | Where the bubble sits in its sender's run: it rounds the corners on the sender's side, and `single` / `last` draw the tail. |
| reactionOptions | KunChatReactionOption[] | [] | The reaction vocabulary, to draw each reaction key. |
| resolveMediaUrl | KunChatMediaUrlResolver | — | Required to show photos. |
| resolveMessage | ((seq: number) => KunChatMessage) | — | Finds a loaded message by seq — the text a "pinned a message" service line quotes. |
| showSender | boolean | false | Show the sender's name on top: group chats, first of a run. |
| status | KunChatSendStatus | — | Delivery state of an own message. The clock / tick / double tick at the bottom corner; `failed` is a button that emits `retry`. |
| timeZone | string | — | IANA zone for the timestamp. Pass it when server-rendering, or the server's zone and the reader's disagree and hydration mismatches. |
| users | KunChatUser[] | [] | Users the message refers to — its sender, a reply's sender, a service message's actors. A missing or `deleted` user shows as deleted. |
事件
| 事件 | 回调参数 | 说明 |
|---|---|---|
| link | url: string, event: MouseEvent | A link in the text or the context card was clicked. |
| mention | userId: string, event: MouseEvent | A mention in the text was clicked. |
| photo-click | index: number | A photo was clicked (index into the album). Fires with `lightbox` on as well. |
| react | reaction: string | null | A reaction chip was clicked: the key to set, or null to remove the viewer's own. One reaction per person, so setting replaces. |
| reply-click | seq: number | The reply preview was clicked: jump to the replied-to message. |
| retry | — | The failed-status button was clicked. |
| user-click | userId: string, event: MouseEvent | The sender's name was clicked. It links to the profile unless you call `event.preventDefault()`. |