refactor: 优化API Key状态过滤逻辑,增强代码可读性

This commit is contained in:
AAEE86
2025-10-14 09:37:46 +08:00
parent 8d84e2fa6e
commit 38c61e1018
2 changed files with 40 additions and 23 deletions

View File

@@ -3111,7 +3111,7 @@ const getDroidApiKeyCount = (account) => {
// 优先使用 apiKeys 数组来计算正常状态的 API Keys
if (Array.isArray(account.apiKeys)) {
// 只计算状态不是 'error' 的 API Keys
return account.apiKeys.filter(apiKey => apiKey.status !== 'error').length
return account.apiKeys.filter((apiKey) => apiKey.status !== 'error').length
}
// 如果是字符串格式的 apiKeys尝试解析
@@ -3120,7 +3120,7 @@ const getDroidApiKeyCount = (account) => {
const parsed = JSON.parse(account.apiKeys)
if (Array.isArray(parsed)) {
// 只计算状态不是 'error' 的 API Keys
return parsed.filter(apiKey => apiKey.status !== 'error').length
return parsed.filter((apiKey) => apiKey.status !== 'error').length
}
} catch (error) {
// 忽略解析错误,继续使用其他字段