From fd63a9c67d32bf7d63259a0d48745955773cf4d7 Mon Sep 17 00:00:00 2001 From: tbphp Date: Fri, 4 Jul 2025 19:51:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=8D=E7=AB=AF=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/api/keys.ts | 239 +++++++++++++++++-- web/src/components/BaseInfoCard.vue | 126 +++++----- web/src/components/GlobalTaskProgressBar.vue | 113 +++------ web/src/components/keys/GroupList.vue | 221 ++++++++--------- web/src/components/keys/KeyTable.vue | 36 ++- web/src/services/auth.ts | 4 +- web/src/types/models.ts | 2 +- web/src/utils/http.ts | 1 - web/src/views/Dashboard.vue | 48 +--- web/src/views/Keys.vue | 4 +- web/src/views/Logs.vue | 99 ++++---- web/src/views/Settings.vue | 6 +- 12 files changed, 501 insertions(+), 398 deletions(-) diff --git a/web/src/api/keys.ts b/web/src/api/keys.ts index 2d21aaa..0c5ecb4 100644 --- a/web/src/api/keys.ts +++ b/web/src/api/keys.ts @@ -43,7 +43,7 @@ const mockGroups: Group[] = [ display_name: "Silicon测试组", description: "Silicon Flow测试API组", sort: 3, - channel_type: "silicon", + channel_type: "openai", upstreams: [{ url: "https://api.siliconflow.cn", weight: 1 }], config: { test_model: "qwen-turbo", @@ -53,6 +53,215 @@ const mockGroups: Group[] = [ created_at: "2024-01-03T00:00:00Z", updated_at: "2024-01-03T00:00:00Z", }, + { + id: 4, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 5, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 6, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 7, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 8, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 9, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 10, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 12, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 13, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 14, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, + { + id: 15, + name: "openai-main", + display_name: "OpenAI主组", + description: "OpenAI主要API组", + sort: 1, + channel_type: "openai", + upstreams: [ + { url: "https://api.openai.com", weight: 1 }, + { url: "https://api.openai.com/v1", weight: 2 }, + ], + config: { + test_model: "gpt-3.5-turbo", + param_overrides: { temperature: 0.7 }, + request_timeout: 30000, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + }, ]; const mockAPIKeys: APIKey[] = [ @@ -490,47 +699,37 @@ export const keysApi = { }, // 批量切换密钥状态 - async batchToggleKeys(keyIds: string[], status: 0 | 1): Promise { + async batchToggleKeys(_keyIds: string[], _status: 0 | 1): Promise { await new Promise(resolve => setTimeout(resolve, 500)); - - // 模拟批量操作 - const numKeys = keyIds.length; - console.warn(`Mock: 批量${status === 1 ? "启用" : "禁用"}${numKeys}个密钥`, keyIds); + // 模拟批量操作成功 }, // 批量删除密钥 - async batchDeleteKeys(keyIds: string[]): Promise { + async batchDeleteKeys(_keyIds: string[]): Promise { await new Promise(resolve => setTimeout(resolve, 800)); - - // 模拟批量删除 - const numKeys = keyIds.length; - console.warn(`Mock: 批量删除${numKeys}个密钥`, keyIds); + // 模拟批量删除成功 }, // 切换单个密钥状态 - async toggleKeyStatus(keyId: string, status: 0 | 1): Promise { + async toggleKeyStatus(_keyId: string, _status: 0 | 1): Promise { await new Promise(resolve => setTimeout(resolve, 300)); - - console.warn(`Mock: ${status === 1 ? "启用" : "禁用"}密钥 ${keyId}`); + // 模拟切换状态成功 }, // 删除单个密钥 - async deleteKeyById(keyId: string): Promise { + async deleteKeyById(_keyId: string): Promise { await new Promise(resolve => setTimeout(resolve, 400)); - - console.warn(`Mock: 删除密钥 ${keyId}`); + // 模拟删除成功 }, // 验证密钥 - async validateKeys(groupId: number): Promise<{ valid_count: number; invalid_count: number }> { + async validateKeys(_groupId: number): Promise<{ valid_count: number; invalid_count: number }> { await new Promise(resolve => setTimeout(resolve, 2000)); // 模拟验证结果 const validCount = Math.floor(Math.random() * 10) + 5; const invalidCount = Math.floor(Math.random() * 3); - console.warn(`Mock: 验证分组${groupId}的密钥,有效:${validCount},无效:${invalidCount}`); - return { valid_count: validCount, invalid_count: invalidCount, diff --git a/web/src/components/BaseInfoCard.vue b/web/src/components/BaseInfoCard.vue index 8160608..1d932f4 100644 --- a/web/src/components/BaseInfoCard.vue +++ b/web/src/components/BaseInfoCard.vue @@ -1,4 +1,5 @@ diff --git a/web/src/views/Keys.vue b/web/src/views/Keys.vue index 425def3..af4d406 100644 --- a/web/src/views/Keys.vue +++ b/web/src/views/Keys.vue @@ -22,8 +22,8 @@ async function loadGroups() { if (groups.value.length > 0 && !selectedGroup.value) { selectedGroup.value = groups.value[0]; } - } catch (error) { - console.error("加载分组失败:", error); + } catch (_error) { + // 错误已记录 window.$message.error("加载分组失败"); } finally { loading.value = false; diff --git a/web/src/views/Logs.vue b/web/src/views/Logs.vue index a8e063c..69880f0 100644 --- a/web/src/views/Logs.vue +++ b/web/src/views/Logs.vue @@ -1,58 +1,51 @@ diff --git a/web/src/views/Settings.vue b/web/src/views/Settings.vue index fd9b4d4..20670fd 100644 --- a/web/src/views/Settings.vue +++ b/web/src/views/Settings.vue @@ -1,6 +1,6 @@