refactor: 优化API Key状态更新和日志记录格式

This commit is contained in:
AAEE86
2025-10-14 09:33:17 +08:00
parent e051ade27e
commit 8d84e2fa6e
2 changed files with 16 additions and 11 deletions

View File

@@ -1124,9 +1124,7 @@ class DroidAccountService {
updatedHashes.add(hash)
// 查找现有条目
const existingIndex = mergedApiKeys.findIndex(
(entry) => entry && entry.hash === hash
)
const existingIndex = mergedApiKeys.findIndex((entry) => entry && entry.hash === hash)
if (existingIndex !== -1) {
// 更新现有条目的状态信息
@@ -1134,9 +1132,18 @@ class DroidAccountService {
mergedApiKeys[existingIndex] = {
...existingEntry,
status: updateItem.status || existingEntry.status || 'active',
errorMessage: updateItem.errorMessage !== undefined ? updateItem.errorMessage : existingEntry.errorMessage || '',
lastUsedAt: updateItem.lastUsedAt !== undefined ? updateItem.lastUsedAt : existingEntry.lastUsedAt || '',
usageCount: updateItem.usageCount !== undefined ? String(updateItem.usageCount) : existingEntry.usageCount || '0'
errorMessage:
updateItem.errorMessage !== undefined
? updateItem.errorMessage
: existingEntry.errorMessage || '',
lastUsedAt:
updateItem.lastUsedAt !== undefined
? updateItem.lastUsedAt
: existingEntry.lastUsedAt || '',
usageCount:
updateItem.usageCount !== undefined
? String(updateItem.usageCount)
: existingEntry.usageCount || '0'
}
apiKeysUpdated = true
}