From 55a95d4c674f0624fad1c31ee4afd0ec03e2a53f Mon Sep 17 00:00:00 2001 From: hezhaoqian1 <115222059+hezhaoqian1@users.noreply.github.com> Date: Tue, 15 Sep 2026 11:16:17 +0800 Subject: [PATCH] feat: filter API key groups by provider --- frontend/src/i18n/locales/en/dashboard.ts | 13 +++ frontend/src/i18n/locales/zh/dashboard.ts | 13 +++ frontend/src/utils/keyGroupProviders.ts | 32 ++++++ frontend/src/views/user/KeysView.vue | 90 +++++++++++++++- .../src/views/user/__tests__/KeysView.spec.ts | 102 +++++++++++++++++- 5 files changed, 245 insertions(+), 5 deletions(-) create mode 100644 frontend/src/utils/keyGroupProviders.ts diff --git a/frontend/src/i18n/locales/en/dashboard.ts b/frontend/src/i18n/locales/en/dashboard.ts index 85b62e99e9..dc8d206fa3 100644 --- a/frontend/src/i18n/locales/en/dashboard.ts +++ b/frontend/src/i18n/locales/en/dashboard.ts @@ -116,6 +116,19 @@ export default { nameLabel: 'Name', namePlaceholder: 'My API Key', groupLabel: 'Group', + providerLabel: 'Provider', + providers: { + anthropic: 'Anthropic', + openai: 'OpenAI', + domestic: 'Chinese AI', + other: 'Other' + }, + providerHints: { + anthropic: 'Choose an available Anthropic / Claude group', + openai: 'Choose an available OpenAI / GPT group', + domestic: 'Includes DeepSeek, Kimi, Zhipu GLM and MiniMax', + other: 'Includes Gemini, Grok, Antigravity, OpenCode and mixed groups' + }, selectGroup: 'Select a group', statusLabel: 'Status', selectStatus: 'Select status', diff --git a/frontend/src/i18n/locales/zh/dashboard.ts b/frontend/src/i18n/locales/zh/dashboard.ts index f4b02e1082..5e1cb30bd6 100644 --- a/frontend/src/i18n/locales/zh/dashboard.ts +++ b/frontend/src/i18n/locales/zh/dashboard.ts @@ -116,6 +116,19 @@ export default { nameLabel: '名称', namePlaceholder: '我的 API 密钥', groupLabel: '分组', + providerLabel: '厂商', + providers: { + anthropic: 'Anthropic', + openai: 'OpenAI', + domestic: '国产模型', + other: '其他' + }, + providerHints: { + anthropic: '选择 Anthropic / Claude 的可用分组', + openai: '选择 OpenAI / GPT 的可用分组', + domestic: '包含 DeepSeek、Kimi、智谱 GLM、MiniMax', + other: '包含 Gemini、Grok、Antigravity、OpenCode 和混合分组' + }, selectGroup: '选择分组', statusLabel: '状态', selectStatus: '选择状态', diff --git a/frontend/src/utils/keyGroupProviders.ts b/frontend/src/utils/keyGroupProviders.ts new file mode 100644 index 0000000000..f2c80c6be1 --- /dev/null +++ b/frontend/src/utils/keyGroupProviders.ts @@ -0,0 +1,32 @@ +import type { GroupPlatform } from '@/types' + +export type KeyGroupProvider = 'anthropic' | 'openai' | 'domestic' | 'other' + +export const KEY_GROUP_PROVIDERS = ['anthropic', 'openai', 'domestic', 'other'] as const + +// Classify by the configured upstream platform, never by a group's display name. +const PROVIDER_BY_PLATFORM: Record = { + anthropic: 'anthropic', + openai: 'openai', + kimi: 'domestic', + zhipu: 'domestic', + deepseek: 'domestic', + minimax: 'domestic', + gemini: 'other', + grok: 'other', + antigravity: 'other', + composite: 'other', + opencode_go: 'other' +} + +export function getKeyGroupProvider(platform: GroupPlatform): KeyGroupProvider { + return PROVIDER_BY_PLATFORM[platform] ?? 'other' +} + +// Collections use representative provider marks rather than an invented brand logo. +export const KEY_GROUP_PROVIDER_ICONS: Record = { + anthropic: ['anthropic'], + openai: ['openai'], + domestic: ['deepseek', 'kimi'], + other: ['gemini', 'grok'] +} diff --git a/frontend/src/views/user/KeysView.vue b/frontend/src/views/user/KeysView.vue index baec34d08b..ed33a4c683 100644 --- a/frontend/src/views/user/KeysView.vue +++ b/frontend/src/views/user/KeysView.vue @@ -485,12 +485,64 @@ /> +
+ {{ t('keys.providerLabel') }} +
+ +
+

+ {{ groups.length === 0 ? t('common.noGroupsAvailable') : t(`keys.providerHints.${createProvider}`) }} +

+
+
- +