From e26ed02c2e937e7e76fd686d086bdd2256072df4 Mon Sep 17 00:00:00 2001 From: ddCat <2695092045@qq.com> Date: Sat, 15 Aug 2026 22:11:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20=E6=B8=A0=E9=81=93=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=20-=20=E8=A1=A5=E5=85=85=201440P=20=E5=88=86=E8=BE=A8?= =?UTF-8?q?=E7=8E=87=E5=B9=B6=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=A1=A3=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/service/model_capability.go | 3 +++ backend/internal/service/model_capability_test.go | 15 +++++++++++++++ web/src/components/model-capability-editor.tsx | 5 +++-- web/src/lib/video-generation-options.ts | 1 + web/test/video-generation-options.test.ts | 3 ++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/backend/internal/service/model_capability.go b/backend/internal/service/model_capability.go index 7bf4ff3d6..f48976315 100644 --- a/backend/internal/service/model_capability.go +++ b/backend/internal/service/model_capability.go @@ -540,6 +540,9 @@ func ratioValue(value string) float64 { func normalizeResolution(value string) string { value = strings.ToLower(strings.TrimSpace(value)) value = strings.TrimSuffix(value, "p") + if value == "2k" { + return "1440p" + } if value == "4k" { return "2160p" } diff --git a/backend/internal/service/model_capability_test.go b/backend/internal/service/model_capability_test.go index 296620569..51057c318 100644 --- a/backend/internal/service/model_capability_test.go +++ b/backend/internal/service/model_capability_test.go @@ -82,3 +82,18 @@ func TestDefaultVideoCapabilityUsesProtocolSpecificResolutionTiers(t *testing.T) }) } } + +func TestNormalizeResolutionSupportsCommonAliases(t *testing.T) { + tests := map[string]string{ + "1440": "1440p", + "1440p": "1440p", + "2K": "1440p", + "4K": "2160p", + "768P": "768p", + } + for input, want := range tests { + if got := normalizeResolution(input); got != want { + t.Fatalf("normalizeResolution(%q) = %q, want %q", input, got, want) + } + } +} diff --git a/web/src/components/model-capability-editor.tsx b/web/src/components/model-capability-editor.tsx index ba1757fa8..8186a2963 100644 --- a/web/src/components/model-capability-editor.tsx +++ b/web/src/components/model-capability-editor.tsx @@ -3,9 +3,9 @@ import type { ReactNode } from "react"; import { defaultImageCapabilityConfig, defaultModelCapabilityConfig, type ImageCapabilityConfig, type ModelCapabilityConfig, type VideoCapabilityConfig } from "@/lib/model-capabilities"; import type { ModelProtocol } from "@/lib/model-protocols"; +import { VIDEO_RESOLUTION_CAPABILITY_OPTIONS } from "@/lib/video-generation-options"; const ratioOptions = ["16:9", "9:16", "1:1", "4:3", "3:4", "21:9"]; -const resolutionOptions = ["480p", "720p", "1080p", "2160p"]; const operationOptions = [ { label: "文生视频", value: "text_to_video" }, { label: "图生视频", value: "image_to_video" }, @@ -35,6 +35,7 @@ export function ModelCapabilityEditor({ value, onChange, protocol, capability = const updateReferences = (patch: Partial) => update({ references: { ...profile.references, ...patch } }); const updateDuration = (patch: Partial) => update({ duration: { ...profile.duration, ...patch } }); const durationValues = (profile.duration.values || []).join(","); + const resolutionOptions = Array.from(new Set([...VIDEO_RESOLUTION_CAPABILITY_OPTIONS, ...profile.resolutions])); return (
@@ -75,7 +76,7 @@ export function ModelCapabilityEditor({ value, onChange, protocol, capability =
({ label: item, value: item }))} onChange={(defaultRatio) => update({ defaultRatio })} /> - ({ label: item.toUpperCase(), value: item }))} onChange={(resolutions) => update({ resolutions, defaultResolution: resolutions.includes(profile.defaultResolution) ? profile.defaultResolution : resolutions[0] || "720p" })} />