various fixes

This commit is contained in:
Kevin
2026-03-23 13:21:07 +08:00
parent 9c2e0329ca
commit b9ecfd02a4
18 changed files with 393 additions and 277 deletions

View File

@@ -35,3 +35,17 @@ export function buildFrameworkChapterPlaceholders(
wordCount: 0,
}));
}
/**
* 列表页始终展示 8 个框架槽位:已有章节用接口数据,其余槽位仍用框架占位(与「零章节」时一致)。
*/
export function mergeFrameworkChaptersWithFetched(
placeholders: ChapterViewModel[],
fetched: ChapterViewModel[],
): ChapterViewModel[] {
const byOrder = new Map<number, ChapterViewModel>();
for (const vm of fetched) {
byOrder.set(vm.orderIndex, vm);
}
return placeholders.map((p) => byOrder.get(p.orderIndex) ?? p);
}