diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 80146b8..ce0c053 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -70,7 +70,10 @@ dependencies { implementation("com.squareup.okhttp3:okhttp-sse:4.12.0") implementation("io.noties.markwon:core:4.6.2") implementation("io.noties.markwon:ext-tables:4.6.2") - implementation("io.noties.markwon:html:4.6.2") // 👈 HTML标签支持 + implementation("io.noties.markwon:html:4.6.2") + implementation("io.noties.markwon:linkify:4.6.2") // 👈 链接自动识别 + implementation("io.noties.markwon:ext-strikethrough:4.6.2") // 👈 删除线支持 + implementation("io.noties.markwon:ext-tasklist:4.6.2") // 👈 任务列表支持 implementation("com.github.getActivity:XXPermissions:18.2") implementation(libs.androidx.appcompat) implementation(libs.androidx.core.ktx) diff --git a/app/src/main/java/com/stand/standapp/ui/chat/components/ChatArea.kt b/app/src/main/java/com/stand/standapp/ui/chat/components/ChatArea.kt index 6445272..26ed2e4 100644 --- a/app/src/main/java/com/stand/standapp/ui/chat/components/ChatArea.kt +++ b/app/src/main/java/com/stand/standapp/ui/chat/components/ChatArea.kt @@ -191,6 +191,10 @@ fun MarkwonRenderer(markdown: String, modifier: Modifier) { val markwon = io.noties.markwon.Markwon.builder(ctx) .usePlugin(io.noties.markwon.core.CorePlugin.create()) .usePlugin(io.noties.markwon.ext.tables.TablePlugin.create(ctx)) + .usePlugin(io.noties.markwon.html.HtmlPlugin.create()) + .usePlugin(io.noties.markwon.linkify.LinkifyPlugin.create()) + .usePlugin(io.noties.markwon.ext.strikethrough.StrikethroughPlugin.create()) + .usePlugin(io.noties.markwon.ext.tasklist.TaskListPlugin.create(ctx)) .build() textView.tag = markwon diff --git a/app/src/main/java/com/stand/standapp/ui/chat/repo/AiChatRepository.kt b/app/src/main/java/com/stand/standapp/ui/chat/repo/AiChatRepository.kt index 5ec8509..d64b35b 100644 --- a/app/src/main/java/com/stand/standapp/ui/chat/repo/AiChatRepository.kt +++ b/app/src/main/java/com/stand/standapp/ui/chat/repo/AiChatRepository.kt @@ -65,8 +65,13 @@ class AiChatRepository { while (reader.readLine().also { line = it } != null) { val curLine = line ?: continue if (curLine.startsWith("data:")) { - val chunk = curLine.substring(5).trim() - trySend(chunk) + val content = curLine.substring(5) + // 👈 空data行表示换行,非空行发送内容 + if (content.isBlank()) { + trySend("\n") + } else { + trySend(content) + } } } }