From 1f2a87adb0ac37fe6c3203bfc4ccd59453d74388 Mon Sep 17 00:00:00 2001 From: hansnow Date: Thu, 20 Aug 2026 10:00:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20=E8=A1=A5=E5=85=A8=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E7=AD=9B=E9=80=89=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/model/error_passthrough_rule.go | 30 ++++++++++++---- .../model/error_passthrough_rule_test.go | 20 +++++++++++ .../admin/ErrorPassthroughRulesModal.vue | 9 ++--- .../admin/account/AccountTableFilters.vue | 3 +- .../src/constants/__tests__/platforms.spec.ts | 26 ++++++++++++++ frontend/src/constants/platforms.ts | 28 +++++++++++++++ frontend/src/views/admin/GroupsView.vue | 35 ++++--------------- .../src/views/admin/SubscriptionsView.vue | 6 ++-- .../GroupsView.compositePlatforms.spec.ts | 13 ++----- .../platformFilterCatalogUsage.spec.ts | 33 +++++++++++++++++ .../ops/components/OpsDashboardHeader.vue | 7 ++-- 11 files changed, 148 insertions(+), 62 deletions(-) create mode 100644 backend/internal/model/error_passthrough_rule_test.go create mode 100644 frontend/src/constants/__tests__/platforms.spec.ts create mode 100644 frontend/src/constants/platforms.ts create mode 100644 frontend/src/views/admin/__tests__/platformFilterCatalogUsage.spec.ts diff --git a/backend/internal/model/error_passthrough_rule.go b/backend/internal/model/error_passthrough_rule.go index aa202069bd..bb3a315771 100644 --- a/backend/internal/model/error_passthrough_rule.go +++ b/backend/internal/model/error_passthrough_rule.go @@ -1,7 +1,11 @@ // Package model 定义服务层使用的数据模型。 package model -import "time" +import ( + "time" + + "github.com/Wei-Shaw/sub2api/internal/domain" +) // ErrorPassthroughRule 全局错误透传规则 // 用于控制上游错误如何返回给客户端 @@ -32,16 +36,28 @@ const MatchModeAll = "all" // 支持的平台常量 const ( - PlatformAnthropic = "anthropic" - PlatformOpenAI = "openai" - PlatformGemini = "gemini" - PlatformAntigravity = "antigravity" - PlatformGrok = "grok" + PlatformAnthropic = domain.PlatformAnthropic + PlatformOpenAI = domain.PlatformOpenAI + PlatformGemini = domain.PlatformGemini + PlatformAntigravity = domain.PlatformAntigravity + PlatformGrok = domain.PlatformGrok + PlatformKimi = domain.PlatformKimi + PlatformZhipu = domain.PlatformZhipu + PlatformDeepseek = domain.PlatformDeepseek ) // AllPlatforms 返回所有支持的平台列表 func AllPlatforms() []string { - return []string{PlatformAnthropic, PlatformOpenAI, PlatformGemini, PlatformAntigravity, PlatformGrok} + return []string{ + PlatformAnthropic, + PlatformOpenAI, + PlatformGemini, + PlatformAntigravity, + PlatformGrok, + PlatformKimi, + PlatformZhipu, + PlatformDeepseek, + } } // Validate 验证规则配置的有效性 diff --git a/backend/internal/model/error_passthrough_rule_test.go b/backend/internal/model/error_passthrough_rule_test.go new file mode 100644 index 0000000000..fc9ff5b385 --- /dev/null +++ b/backend/internal/model/error_passthrough_rule_test.go @@ -0,0 +1,20 @@ +package model + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestAllPlatformsIncludesEveryConcretePlatform(t *testing.T) { + require.ElementsMatch(t, []string{ + "anthropic", + "openai", + "gemini", + "antigravity", + "grok", + "kimi", + "zhipu", + "deepseek", + }, AllPlatforms()) +} diff --git a/frontend/src/components/admin/ErrorPassthroughRulesModal.vue b/frontend/src/components/admin/ErrorPassthroughRulesModal.vue index 7d0058b759..ce8d14424d 100644 --- a/frontend/src/components/admin/ErrorPassthroughRulesModal.vue +++ b/frontend/src/components/admin/ErrorPassthroughRulesModal.vue @@ -433,6 +433,7 @@ import { ref, reactive, computed, watch } from 'vue' import { useI18n } from 'vue-i18n' import { useAppStore } from '@/stores/app' +import { CONCRETE_PLATFORM_OPTIONS } from '@/constants/platforms' import { adminAPI } from '@/api/admin' import type { ErrorPassthroughRule } from '@/api/admin/errorPassthrough' import BaseDialog from '@/components/common/BaseDialog.vue' @@ -485,13 +486,7 @@ const matchModeOptions = computed(() => [ { value: 'all', label: t('admin.errorPassthrough.matchMode.all'), description: t('admin.errorPassthrough.matchMode.allHint') } ]) -const platformOptions = [ - { value: 'anthropic', label: 'Anthropic' }, - { value: 'openai', label: 'OpenAI' }, - { value: 'gemini', label: 'Gemini' }, - { value: 'antigravity', label: 'Antigravity' }, - { value: 'grok', label: 'Grok' } -] +const platformOptions = CONCRETE_PLATFORM_OPTIONS // Load rules when dialog opens watch(() => props.show, (newVal) => { diff --git a/frontend/src/components/admin/account/AccountTableFilters.vue b/frontend/src/components/admin/account/AccountTableFilters.vue index a0587f27f8..9e48be822b 100644 --- a/frontend/src/components/admin/account/AccountTableFilters.vue +++ b/frontend/src/components/admin/account/AccountTableFilters.vue @@ -18,6 +18,7 @@