This commit is contained in:
parent
99c691378e
commit
74788fd22e
|
|
@ -70,7 +70,10 @@ dependencies {
|
||||||
implementation("com.squareup.okhttp3:okhttp-sse:4.12.0")
|
implementation("com.squareup.okhttp3:okhttp-sse:4.12.0")
|
||||||
implementation("io.noties.markwon:core:4.6.2")
|
implementation("io.noties.markwon:core:4.6.2")
|
||||||
implementation("io.noties.markwon:ext-tables: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("com.github.getActivity:XXPermissions:18.2")
|
||||||
implementation(libs.androidx.appcompat)
|
implementation(libs.androidx.appcompat)
|
||||||
implementation(libs.androidx.core.ktx)
|
implementation(libs.androidx.core.ktx)
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,10 @@ fun MarkwonRenderer(markdown: String, modifier: Modifier) {
|
||||||
val markwon = io.noties.markwon.Markwon.builder(ctx)
|
val markwon = io.noties.markwon.Markwon.builder(ctx)
|
||||||
.usePlugin(io.noties.markwon.core.CorePlugin.create())
|
.usePlugin(io.noties.markwon.core.CorePlugin.create())
|
||||||
.usePlugin(io.noties.markwon.ext.tables.TablePlugin.create(ctx))
|
.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()
|
.build()
|
||||||
|
|
||||||
textView.tag = markwon
|
textView.tag = markwon
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,13 @@ class AiChatRepository {
|
||||||
while (reader.readLine().also { line = it } != null) {
|
while (reader.readLine().also { line = it } != null) {
|
||||||
val curLine = line ?: continue
|
val curLine = line ?: continue
|
||||||
if (curLine.startsWith("data:")) {
|
if (curLine.startsWith("data:")) {
|
||||||
val chunk = curLine.substring(5).trim()
|
val content = curLine.substring(5)
|
||||||
trySend(chunk)
|
// 👈 空data行表示换行,非空行发送内容
|
||||||
|
if (content.isBlank()) {
|
||||||
|
trySend("\n")
|
||||||
|
} else {
|
||||||
|
trySend(content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue