修自定义配置

null、导入、mixin ignore
This commit is contained in:
2026-10-30 23:40:05 +08:00
parent 2582f9ba3e
commit 544a68bbd4
9 changed files with 429 additions and 79 deletions
@@ -16,6 +16,7 @@ data class CaptureProfileStep(
val fileName: String,
var postAction: suspend (CaptureResult) -> Unit = {},
val uploadType: String? = null,
val explicitUploadIds: Set<String> = emptySet(),
)
data class CaptureResult(
@@ -45,9 +45,24 @@ object MixinProfiles {
}
}
}
val upload = mixin.upload
if (upload != null && !upload.ignoreAll) {
for ((region, steps) in upload.ignore) {
if (region.lowercase() !in REGION_IDS) {
return "\"$region\" 不是内置配置"
}
val invalidStep = steps.firstOrNull { it.lowercase() !in PredefinedProfiles.stepTargets }
if (invalidStep != null) {
return "\"$invalidStep\" 不是内置类型"
}
}
}
return null
}
private val REGION_IDS = setOf("cn", "jp", "en", "tw", "kr")
private fun collect(): LinkedHashMap<String, ProfileAcc> {
val profiles = linkedMapOf<String, ProfileAcc>()
@@ -84,7 +99,10 @@ object MixinProfiles {
val steps = base.steps.map { step ->
val extra = acc.steps[step.name.trim().lowercase()] ?: return@map step
step.copy(hosts = (step.hosts + extra.hosts).distinctBy { it.lowercase() })
step.copy(
hosts = (step.hosts + extra.hosts).distinctBy { it.lowercase() },
explicitUploadIds = step.explicitUploadIds + extra.uploadProfileIds,
)
} + acc.steps.values
.filter { it.name.trim().lowercase() !in builtInStepKeys }
.mapNotNull { buildStep(it, usedFileNames, usedIds) }