fix(channels): 修复初始模型选择逻辑以处理空模型情况

This commit is contained in:
Jeff Gu committed 2026-04-14 18:47:02 +08:00
1 parent 4da5cba8fa
commit ddae84e2b1
1 file changed
+5 -3
+5 -3
View File
@@ -336,12 +336,14 @@ const buildInitialFetchedModelSelection = (
candidates: FetchedModelCandidate[],
currentModels: ChannelModelMapping[],
): string[] => {
if (currentModels.length === 0) {
return candidates.map((candidate) => candidate.id);
}
const currentModelIds = new Set(currentModels.map((model) => model.id));
const matchedIds = candidates
return candidates
.filter((candidate) => currentModelIds.has(candidate.id))
.map((candidate) => candidate.id);
return matchedIds.length > 0 ? matchedIds : candidates.map((candidate) => candidate.id);
};
const trimSlashes = (value: string): string => value.replace(/^\/+|\/+$/g, "");