尝试修复KPM信息解析
This commit is contained in:
@@ -70,16 +70,21 @@ class KpmViewModel : ViewModel() {
|
|||||||
val info = getKpmModuleInfo(name)
|
val info = getKpmModuleInfo(name)
|
||||||
if (info.isBlank()) return null
|
if (info.isBlank()) return null
|
||||||
|
|
||||||
val properties = info.lines()
|
val properties = info.lineSequence() // 使用序列提升大文本性能
|
||||||
.filter { it.isNotBlank() && !it.startsWith("#") }
|
.filter { line ->
|
||||||
.associate { line ->
|
val trimmed = line.trim()
|
||||||
val parts = line.split("=", limit = 2)
|
trimmed.isNotEmpty() && !trimmed.startsWith("#")
|
||||||
if (parts.size == 2) {
|
}
|
||||||
parts[0].trim() to parts[1].trim()
|
.mapNotNull { line ->
|
||||||
} else {
|
line.split("=", limit = 2).let { parts ->
|
||||||
parts[0].trim() to ""
|
when (parts.size) {
|
||||||
|
2 -> parts[0].trim() to parts[1].trim()
|
||||||
|
1 -> parts[0].trim() to ""
|
||||||
|
else -> null // 忽略无效行
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.toMap()
|
||||||
|
|
||||||
return ModuleInfo(
|
return ModuleInfo(
|
||||||
id = name,
|
id = name,
|
||||||
@@ -88,8 +93,8 @@ class KpmViewModel : ViewModel() {
|
|||||||
author = properties["author"] ?: "unknown",
|
author = properties["author"] ?: "unknown",
|
||||||
description = properties["description"] ?: "",
|
description = properties["description"] ?: "",
|
||||||
args = properties["args"] ?: "",
|
args = properties["args"] ?: "",
|
||||||
enabled = true, // 默认启用
|
enabled = true,
|
||||||
hasAction = properties["has_action"]?.toBoolean() ?: false
|
hasAction = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user