feat: 添加下拉菜单和批量操作功能

- 新增 /api/keys/all 端点获取所有密钥
- 添加下拉菜单界面,提供复制全部密钥和验证所有密钥选项
- 重构批量重置逻辑,改为逐个处理以提供更好的进度反馈
- 新增批量操作进度模态框,实时显示操作状态和日志
- 在验证模态框中添加批次大小配置选项
- 优化用户体验,提供更直观的批量操作界面
This commit is contained in:
snaily
2025-07-25 00:35:56 +08:00
parent 2270f6d998
commit 7af53de782
3 changed files with 536 additions and 111 deletions
+20
View File
@@ -61,3 +61,23 @@ async def get_keys_paginated(
"total_pages": (total_items + limit - 1) // limit,
"current_page": page,
}
@router.get("/api/keys/all")
async def get_all_keys(
request: Request,
key_manager: KeyManager = Depends(get_key_manager_instance),
):
"""
Get all keys (both valid and invalid) for bulk operations.
"""
auth_token = request.cookies.get("auth_token")
if not auth_token or not verify_auth_token(auth_token):
return JSONResponse(status_code=401, content={"detail": "Unauthorized"})
all_keys_with_status = await key_manager.get_all_keys_with_fail_count()
return {
"valid_keys": list(all_keys_with_status["valid_keys"].keys()),
"invalid_keys": list(all_keys_with_status["invalid_keys"].keys()),
"total_count": len(all_keys_with_status["valid_keys"]) + len(all_keys_with_status["invalid_keys"])
}