fix(frontend): 修复 Provider Key 列表只显示 100 条的问题

- 在 getProviderKeys 中增加 skip/limit 自动分页拉取
  - 默认每页 1000,循环获取直到无更多数据
  - 避免后端默认 limit=100 导致账号展示被截断
This commit is contained in:
AAEE86
2026-02-27 15:07:44 +08:00
parent 8c2928c39d
commit bfee1019ed

View File

@@ -91,8 +91,24 @@ export async function deleteEndpointKey(keyId: string): Promise<{ message: strin
* 获取 Provider 的所有 Keys * 获取 Provider 的所有 Keys
*/ */
export async function getProviderKeys(providerId: string): Promise<EndpointAPIKey[]> { export async function getProviderKeys(providerId: string): Promise<EndpointAPIKey[]> {
const response = await client.get(`/api/admin/endpoints/providers/${providerId}/keys`) // 后端默认 limit=100这里主动分页拉取避免账号数 >100 时前端被截断
return response.data const pageSize = 1000
let skip = 0
const allKeys: EndpointAPIKey[] = []
while (true) {
const response = await client.get(`/api/admin/endpoints/providers/${providerId}/keys`, {
params: { skip, limit: pageSize },
})
const batch = Array.isArray(response.data) ? (response.data as EndpointAPIKey[]) : []
allKeys.push(...batch)
if (batch.length < pageSize) break
skip += pageSize
}
return allKeys
} }
/** /**