From e1428ef28d9cc2bcf73fd2014d7a70a9ff95b9a6 Mon Sep 17 00:00:00 2001 From: ddCat <2695092045@qq.com> Date: Sat, 15 Aug 2026 14:00:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(features):=20=E5=8A=9F=E8=83=BD=E5=BC=80?= =?UTF-8?q?=E6=94=BE=20-=20=E5=85=BC=E5=AE=B9=E5=8E=86=E5=8F=B2=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=BB=A3=E7=90=86=E4=BB=BB=E5=8A=A1=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E5=89=8D=E7=AB=AF=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/service/feature_availability_test.go | 7 +++++++ backend/internal/service/service.go | 5 ++++- web/src/stores/use-config-store.ts | 5 +---- web/test/local-dreamina-model-catalog.test.ts | 10 +++++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/backend/internal/service/feature_availability_test.go b/backend/internal/service/feature_availability_test.go index ac2645347..6178ae71f 100644 --- a/backend/internal/service/feature_availability_test.go +++ b/backend/internal/service/feature_availability_test.go @@ -89,6 +89,13 @@ func TestCustomChannelTaskInputRequiresFeature(t *testing.T) { if err := svc.requireCustomChannelsForTaskInput(systemInput); err != nil { t.Fatalf("system channel task error = %v", err) } + legacySystemInput, err := normalizeTaskInput(map[string]any{"config": providerConfig{BaseURL: "/api/ai/system/system-1", APIKey: "system", Model: "text-model"}}) + if err != nil { + t.Fatal(err) + } + if err := svc.requireCustomChannelsForTaskInput(legacySystemInput); err != nil { + t.Fatalf("legacy system proxy task error = %v", err) + } } func TestTaskBillingOrderSkipsPricingWhenCreditsDisabled(t *testing.T) { diff --git a/backend/internal/service/service.go b/backend/internal/service/service.go index c29e98db5..075a3b4df 100644 --- a/backend/internal/service/service.go +++ b/backend/internal/service/service.go @@ -416,7 +416,10 @@ func taskInputUsesCustomChannel(input map[string]any) bool { channelID, _ := config["channelId"].(string) baseURL, _ := config["baseUrl"].(string) apiKey, _ := config["apiKey"].(string) - return strings.TrimSpace(channelID) == "" && strings.TrimSpace(baseURL) != "" && strings.TrimSpace(apiKey) != "" + if strings.TrimSpace(channelID) != "" || systemChannelIDFromBaseURL(baseURL) != "" { + return false + } + return strings.TrimSpace(baseURL) != "" && strings.TrimSpace(apiKey) != "" } func compactPersistedValue(value interface{}) interface{} { diff --git a/web/src/stores/use-config-store.ts b/web/src/stores/use-config-store.ts index 666056732..2a3d511e1 100644 --- a/web/src/stores/use-config-store.ts +++ b/web/src/stores/use-config-store.ts @@ -349,10 +349,7 @@ export function useEffectiveConfig() { const customChannelsEnabled = useUserStore((state) => state.features.customChannelsEnabled); const catalogState = useLocalDreaminaModelStore((state) => state.state); const dreaminaModels = useLocalDreaminaModelStore((state) => state.models); - return useMemo( - () => effectiveConfigWithDreamina(effectiveConfigForCustomChannels(config, customChannelsEnabled), catalogState, dreaminaModels), - [catalogState, config, customChannelsEnabled, dreaminaModels], - ); + return useMemo(() => effectiveConfigWithDreamina(effectiveConfigForCustomChannels(config, customChannelsEnabled), catalogState, dreaminaModels), [catalogState, config, customChannelsEnabled, dreaminaModels]); } export function effectiveConfigForCustomChannels(config: AiConfig, customChannelsEnabled: boolean): AiConfig { diff --git a/web/test/local-dreamina-model-catalog.test.ts b/web/test/local-dreamina-model-catalog.test.ts index 932c99e70..dcc29dce9 100644 --- a/web/test/local-dreamina-model-catalog.test.ts +++ b/web/test/local-dreamina-model-catalog.test.ts @@ -218,7 +218,15 @@ test("effective config removes custom channels when administrators disable them" const config = normalizeConfigSnapshot({ config: { channels: [ - createModelChannel({ id: "system-1", scope: "system", name: "系统渠道", baseUrl: "/api/ai/system/system-1", apiKey: "system", models: ["system-model"], modelCosts: [{ model: "system-model", capability: "text", billingMode: "fixed_request", unitPriceMicrocredits: 0 }] }), + createModelChannel({ + id: "system-1", + scope: "system", + name: "系统渠道", + baseUrl: "/api/ai/system/system-1", + apiKey: "system", + models: ["system-model"], + modelCosts: [{ model: "system-model", capability: "text", billingMode: "fixed_request", unitPriceMicrocredits: 0 }], + }), createModelChannel({ id: "custom-1", scope: "user", name: "自定义渠道", baseUrl: "https://example.com", apiKey: "private-key", models: ["custom-model"] }), ], },