feat: 所有页面支持1到4层级的嵌套结构

This commit is contained in:
coolzr
2025-10-24 00:40:43 +08:00
parent 8d4d76184d
commit ad3cba549b
9 changed files with 846 additions and 43 deletions

View File

@@ -196,7 +196,21 @@ function safeLoadYamlConfig(filePath) {
try {
const fileContent = fs.readFileSync(filePath, 'utf8');
return yaml.load(fileContent);
// 使用 loadAll 而不是 load 来支持多文档 YAML 文件
const docs = yaml.loadAll(fileContent);
// 如果只有一个文档,直接返回
if (docs.length === 1) {
return docs[0];
}
// 如果有多个文档,返回第一个文档(忽略后面的文档)
if (docs.length > 1) {
console.warn(`Warning: Multiple documents found in ${filePath}. Using the first document only.`);
return docs[0];
}
return null;
} catch (error) {
handleConfigLoadError(filePath, error);
return null;