From 01b5f980a5ff9845399b3e1dbfd9d4030513470e Mon Sep 17 00:00:00 2001 From: AskaEth Date: Tue, 8 Sep 2026 21:03:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E6=9D=A5=E6=BA=90=E8=A7=92?= =?UTF-8?q?=E6=A0=87=E7=A7=BB=E5=88=B0=E6=B6=88=E6=81=AF=E7=BB=84=E9=A1=B6?= =?UTF-8?q?=E9=83=A8=EF=BC=9BIM=20deviceId=20=E6=98=BE=E7=A4=BA=E5=8F=8B?= =?UTF-8?q?=E5=A5=BD=E5=B9=B3=E5=8F=B0=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 角标挂底部会视觉贴到下一条消息上;微信等 IM 的 deviceId 形如 <平台名>:<配置id>:,只取平台名显示「来自微信」。 --- .../top/yeij/cyrene/ui/chat/MessageBubble.kt | 20 +++++++++---------- .../top/yeij/cyrene/ui/chat/MessageSource.kt | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/top/yeij/cyrene/ui/chat/MessageBubble.kt b/app/src/main/kotlin/top/yeij/cyrene/ui/chat/MessageBubble.kt index 38fafce..3359a57 100644 --- a/app/src/main/kotlin/top/yeij/cyrene/ui/chat/MessageBubble.kt +++ b/app/src/main/kotlin/top/yeij/cyrene/ui/chat/MessageBubble.kt @@ -52,19 +52,19 @@ fun MessageBubble(message: HistoryMessageDto) { .padding(horizontal = 14.dp), horizontalAlignment = if (isUser) Alignment.End else Alignment.Start, ) { - bubbles.forEachIndexed { index, bubble -> + // 来源角标放在消息组顶部,明确标注下面这一组气泡来自哪里 + if (source != null) { + Text( + text = source, + style = MiuixTheme.textStyles.footnote2, + color = MiuixTheme.colorScheme.onSurfaceVariantSummary, + modifier = Modifier.padding(start = 6.dp, end = 6.dp), + ) + } + bubbles.forEach { bubble -> AnnotationLine(bubble.head) if (bubble.body.isNotEmpty()) BubbleBody(bubble.body, isUser) AnnotationLine(bubble.tail) - // 来源角标只在最后一条气泡下方显示一次,避免多气泡消息重复刷屏 - if (index == bubbles.lastIndex && source != null) { - Text( - text = source, - style = MiuixTheme.textStyles.footnote2, - color = MiuixTheme.colorScheme.onSurfaceVariantSummary, - modifier = Modifier.padding(top = 3.dp, start = 6.dp, end = 6.dp), - ) - } } } } diff --git a/app/src/main/kotlin/top/yeij/cyrene/ui/chat/MessageSource.kt b/app/src/main/kotlin/top/yeij/cyrene/ui/chat/MessageSource.kt index 6a1c6fd..1a391e7 100644 --- a/app/src/main/kotlin/top/yeij/cyrene/ui/chat/MessageSource.kt +++ b/app/src/main/kotlin/top/yeij/cyrene/ui/chat/MessageSource.kt @@ -23,6 +23,8 @@ fun messageSourceLabel(message: HistoryMessageDto): String? { val browser = deviceId.removePrefix("web:").substringBefore(':') return "来自 Web($browser)" } + // IM 端 deviceId 形如 <平台名>:<配置id>:,只取平台名做友好显示 + platformLabels[deviceId.substringBefore(':')]?.let { return "来自 $it" } return "来自 $deviceId" }