Skip to content

Commit bee6285

Browse files
committed
完全重写YAML处理逻辑,保持原始格式和注释,只替换值
1 parent bb8d939 commit bee6285

File tree

2 files changed

+285
-382
lines changed

2 files changed

+285
-382
lines changed

src/components/ChallengeContributePage/handleImportYaml.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,16 @@ export function updateChallengeInCollection(
188188
currentField = fieldName;
189189
} else {
190190
// 不是字段开始,可能是复杂字段的一部分
191-
// 我们不处理这些嵌套字段内的注释
192-
commentBuffer = [];
191+
// 我们保留这些注释,可能是块级注释或值的一部分
192+
if (commentBuffer.length > 0 && currentField) {
193+
// 如果已经有这个字段的注释,添加到现有注释中
194+
if (challengeWithComments[currentField]) {
195+
challengeWithComments[currentField].push(...commentBuffer);
196+
} else {
197+
challengeWithComments[currentField] = [...commentBuffer];
198+
}
199+
commentBuffer = [];
200+
}
193201
}
194202
}
195203
}

0 commit comments

Comments
 (0)