diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index c79b56c..3a9552f 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -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") } diff --git a/android/app/src/main/java/com/dadao/task/ui/KnowledgeScreen.kt b/android/app/src/main/java/com/dadao/task/ui/KnowledgeScreen.kt index e32e511..c54d752 100644 --- a/android/app/src/main/java/com/dadao/task/ui/KnowledgeScreen.kt +++ b/android/app/src/main/java/com/dadao/task/ui/KnowledgeScreen.kt @@ -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 {