Commit 705131e1 authored by erio's avatar erio
Browse files

fix(channel): 前端重复模型校验改为按平台检查

后端 validateNoDuplicateModels 使用 platform:model 复合键,
前端之前跨平台扁平化检查导致不同平台下的同名模型误报重复。
parent 88759407
...@@ -877,12 +877,21 @@ async function handleSubmit() { ...@@ -877,12 +877,21 @@ async function handleSubmit() {
} }
} }
// Check duplicate models across all enabled platform sections // Check duplicate models per platform (same model in different platforms is allowed)
const allModels = form.platforms.filter(s => s.enabled).flatMap(s => s.model_pricing.flatMap(e => e.models.map(m => m.toLowerCase()))) for (const section of form.platforms.filter(s => s.enabled)) {
const duplicates = allModels.filter((m, i) => allModels.indexOf(m) !== i) const seen = new Set()
if (duplicates.length > 0) { for (const entry of section.model_pricing) {
appStore.showError(t('admin.channels.duplicateModels', `模型 "${duplicates[0]}" 在多个定价条目中重复`)) for (const m of entry.models) {
return const key = m.toLowerCase()
if (seen.has(key)) {
const platformLabel = t('admin.groups.platforms.' + section.platform, section.platform)
appStore.showError(t('admin.channels.duplicateModels', `${platformLabel} 平台下模型 "${m}" 在多个定价条目中重复`))
activeTab.value = section.platform
return
}
seen.add(key)
}
}
} }
// 校验 per_request/image 模式必须有价格 (只校验启用的平台) // 校验 per_request/image 模式必须有价格 (只校验启用的平台)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment