This commit is contained in:
SunSeekerX
2025-12-31 02:17:10 +08:00
parent 584fa8c9c1
commit b4233033a6
9 changed files with 50 additions and 42 deletions

View File

@@ -289,17 +289,13 @@ router.get('/api-keys', authenticateAdmin, async (req, res) => {
}
// 为每个API Key添加owner的displayName批量获取优化
const userIdsToFetch = [
...new Set(result.items.filter((k) => k.userId).map((k) => k.userId))
]
const userIdsToFetch = [...new Set(result.items.filter((k) => k.userId).map((k) => k.userId))]
const userMap = new Map()
if (userIdsToFetch.length > 0) {
// 批量获取用户信息
const users = await Promise.all(
userIdsToFetch.map((id) =>
userService.getUserById(id, false).catch(() => null)
)
userIdsToFetch.map((id) => userService.getUserById(id, false).catch(() => null))
)
userIdsToFetch.forEach((id, i) => {
if (users[i]) userMap.set(id, users[i])