From 705131e172e7559ea2d6ae33546c10a03f524a87 Mon Sep 17 00:00:00 2001 From: erio Date: Tue, 31 Mar 2026 19:40:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(channel):=20=E5=89=8D=E7=AB=AF=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=A8=A1=E5=9E=8B=E6=A0=A1=E9=AA=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=8C=89=E5=B9=B3=E5=8F=B0=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端 validateNoDuplicateModels 使用 platform:model 复合键, 前端之前跨平台扁平化检查导致不同平台下的同名模型误报重复。 --- frontend/src/views/admin/ChannelsView.vue | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/src/views/admin/ChannelsView.vue b/frontend/src/views/admin/ChannelsView.vue index bcf5a745..6fcb1aeb 100644 --- a/frontend/src/views/admin/ChannelsView.vue +++ b/frontend/src/views/admin/ChannelsView.vue @@ -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 模式必须有价格 (只校验启用的平台)