fix: guard model selector search against null values (#654)

Co-authored-by: xisoul <xisoul@local>
This commit is contained in:
xisoul
2026-05-12 18:42:53 +08:00
committed by GitHub
parent 96866f36e5
commit 66111db7f1
@@ -39,18 +39,22 @@ async function removeCustomModel(model: string, provider: string) {
await appStore.removeCustomModel(model, provider)
}
function safeLower(value: unknown) {
return typeof value === 'string' ? value.toLowerCase() : ''
}
const filteredGroups = computed(() => {
const q = searchQuery.value.toLowerCase().trim()
const q = safeLower(searchQuery.value).trim()
if (!q) return modelGroupsWithCustom.value
return modelGroupsWithCustom.value
.map(g => ({
...g,
models: g.models.filter(m => {
const displayName = appStore.displayModelName(m, g.provider)
return m.toLowerCase().includes(q) || displayName.toLowerCase().includes(q)
return safeLower(m).includes(q) || safeLower(displayName).includes(q)
}),
}))
.filter(g => g.models.length > 0 || g.label.toLowerCase().includes(q))
.filter(g => g.models.length > 0 || safeLower(g.label).includes(q))
})
function toggleGroup(provider: string) {