fix(channel): 前端重复模型校验改为按平台检查
后端 validateNoDuplicateModels 使用 platform:model 复合键, 前端之前跨平台扁平化检查导致不同平台下的同名模型误报重复。
This commit is contained in:
@@ -877,12 +877,21 @@ async function handleSubmit() {
|
||||
}
|
||||
}
|
||||
|
||||
// Check duplicate models across all enabled platform sections
|
||||
const allModels = form.platforms.filter(s => s.enabled).flatMap(s => s.model_pricing.flatMap(e => e.models.map(m => m.toLowerCase())))
|
||||
const duplicates = allModels.filter((m, i) => allModels.indexOf(m) !== i)
|
||||
if (duplicates.length > 0) {
|
||||
appStore.showError(t('admin.channels.duplicateModels', `模型 "${duplicates[0]}" 在多个定价条目中重复`))
|
||||
return
|
||||
// Check duplicate models per platform (same model in different platforms is allowed)
|
||||
for (const section of form.platforms.filter(s => s.enabled)) {
|
||||
const seen = new Set()
|
||||
for (const entry of section.model_pricing) {
|
||||
for (const m of entry.models) {
|
||||
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 模式必须有价格 (只校验启用的平台)
|
||||
|
||||
Reference in New Issue
Block a user