fix(chat): 来源角标移到消息组顶部;IM deviceId 显示友好平台名
角标挂底部会视觉贴到下一条消息上;微信等 IM 的 deviceId 形如 <平台名>:<配置id>:<uid>,只取平台名显示「来自微信」。
This commit is contained in:
1 parent
63fe9a12a6
commit
01b5f980a5
2 files changed
+12
-10
No files matched your search
@@ -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),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ fun messageSourceLabel(message: HistoryMessageDto): String? {
|
||||
val browser = deviceId.removePrefix("web:").substringBefore(':')
|
||||
return "来自 Web($browser)"
|
||||
}
|
||||
// IM 端 deviceId 形如 <平台名>:<配置id>:<uid>,只取平台名做友好显示
|
||||
platformLabels[deviceId.substringBefore(':')]?.let { return "来自 $it" }
|
||||
return "来自 $deviceId"
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user