fix(android): 知识正文支持表格与删除线,加载提示挪到标题行
CI / backend (push) Canceled after 0s

- 加 markwon ext-tables / ext-strikethrough:同一个 markdown 在 Web 里是表格,
  在 app 里原来会把 | 管道符原样铺出来,现在按 Web 的纸面色画(1dp 浅线、表头浅底)
- 「载入中…」原来挂在分类 chip 行末尾,chip 横向滚动时被挤出屏幕,等于没提示;
  挪到「知识」标题右侧,任何滚动位置都看得见
This commit is contained in:
2026-11-05 17:54:53 +08:00
parent 29805bd61e
commit 2a9d72a974
2 changed files with 34 additions and 6 deletions
+3
View File
@@ -109,6 +109,9 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp:4.12.0")
// Markdown 预览用成熟库渲染,不自己写解析器
implementation("io.noties.markwon:core:4.6.2")
// 表格与删除线:Web 端正文支持,安卓不能把 | 管道符原样吐给读者
implementation("io.noties.markwon:ext-tables:4.6.2")
implementation("io.noties.markwon:ext-strikethrough:4.6.2")
implementation("io.coil-kt:coil-compose:2.7.0")
debugImplementation("androidx.compose.ui:ui-tooling")
}
@@ -63,6 +63,9 @@ import com.dadao.task.data.KnowledgeCategory
import com.dadao.task.data.KnowledgeDoc
import com.dadao.task.data.Workspace
import io.noties.markwon.Markwon
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin
import io.noties.markwon.ext.tables.TablePlugin
import io.noties.markwon.ext.tables.TableTheme
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -239,7 +242,15 @@ fun KnowledgeScreen(
) {
item {
Column(Modifier.padding(top = 4.dp)) {
Text("知识", style = MaterialTheme.typography.headlineSmall)
// 加载指示放在标题这一行:分类 chip 是横向滚动的,写在 chip 行末尾时
// 大概率被挤出屏幕,反而让人以为"点了没反应"。
Row(verticalAlignment = Alignment.CenterVertically) {
Text("知识", style = MaterialTheme.typography.headlineSmall)
if (loading) {
Spacer(Modifier.width(10.dp))
LoadingInline()
}
}
Text(
"工单验收通过会自动整理一份草稿;核对无误再发布,发布后才会进入团队检索。",
style = MaterialTheme.typography.bodySmall,
@@ -265,10 +276,6 @@ fun KnowledgeScreen(
catFilter = cat.id
}
}
if (loading) {
Spacer(Modifier.width(4.dp))
LoadingInline()
}
}
Spacer(Modifier.height(10.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
@@ -784,7 +791,25 @@ private fun KnowledgeBody(text: String) {
return
}
val context = LocalContext.current
val markwon = remember { Markwon.create(context) }
// 表格/删除线插件:Web 正文支持表格,安卓照抄同一份 markdown 时要能画出来,
// 否则 | 管道符会原样铺在正文里,像没解析。
val markwon = remember {
// 表格主题按 Web 的纸面来:1dp 浅线、表头浅底、偶数行淡一档。
// 用默认主题的话边框是 1px 纯黑,一格一格的,像 Excel 截图。
val density = context.resources.displayMetrics.density
val tableTheme = TableTheme.Builder()
.tableBorderWidth((1 * density).toInt())
.tableBorderColor(android.graphics.Color.parseColor("#E3E7EF"))
.tableCellPadding((8 * density).toInt())
.tableHeaderRowBackgroundColor(android.graphics.Color.parseColor("#F4F5F9"))
.tableOddRowBackgroundColor(android.graphics.Color.WHITE)
.tableEvenRowBackgroundColor(android.graphics.Color.parseColor("#FAFAFC"))
.build()
Markwon.builder(context)
.usePlugin(TablePlugin.create(tableTheme))
.usePlugin(StrikethroughPlugin.create())
.build()
}
AndroidView(
factory = { ctx ->
android.widget.TextView(ctx).apply {