mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-09-05 07:26:39 +08:00
feat: 实现代理健康检查功能
添加完整的代理检测系统,包括: 后端功能: - 新增代理检测服务模块 (app/service/proxy/) * ProxyCheckService: 核心检测逻辑,支持HTTP/HTTPS/SOCKS5代理 * 内置缓存机制,避免重复检测 (10秒缓存期) * 支持并发检测,可配置最大并发数 - 新增4个API端点 (app/router/config_routes.py): * POST /api/config/proxy/check - 单个代理检测 * POST /api/config/proxy/check-all - 批量代理检测 * GET /api/config/proxy/cache-stats - 缓存统计 * POST /api/config/proxy/clear-cache - 清空缓存 前端功能: - 代理列表中每项添加状态图标和检测按钮 - 支持单个代理实时检测 - 新增检测所有代理功能按钮 - 代理检测结果模态框,显示: * 检测进度条和状态 * 可用/不可用代理统计 * 详细的检测结果列表(响应时间、错误信息) * 重试失败代理功能 技术特性: - 10秒超时机制,避免长时间等待 - 异步并发检测,提升批量检测效率 - 缓存机制减少重复请求 - 完整的错误处理和用户友好提示 - 响应式UI设计,支持实时状态更新
This commit is contained in:
@@ -1232,6 +1232,13 @@ endblock %} {% block head_extra_styles %}
|
||||
>
|
||||
<i class="fas fa-trash-alt"></i> 删除代理
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg font-medium transition-all duration-200 flex items-center gap-2"
|
||||
id="checkAllProxiesBtn"
|
||||
>
|
||||
<i class="fas fa-globe"></i> 检测所有代理
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg font-medium transition-all duration-200 flex items-center gap-2"
|
||||
@@ -2614,6 +2621,84 @@ endblock %} {% block head_extra_styles %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Proxy Check Results Modal -->
|
||||
<div id="proxyCheckModal" class="modal">
|
||||
<div
|
||||
class="w-full max-w-4xl mx-auto rounded-2xl shadow-2xl overflow-hidden animate-fade-in"
|
||||
style="
|
||||
background-color: rgba(255, 255, 255, 0.98);
|
||||
color: #374151;
|
||||
border: 1px solid rgba(0, 0, 0, 0.12);
|
||||
"
|
||||
>
|
||||
<div class="p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h2 class="text-xl font-bold text-gray-800">代理检测结果</h2>
|
||||
<button
|
||||
id="closeProxyCheckModalBtn"
|
||||
class="text-gray-300 hover:text-gray-800 text-xl"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 检测状态和进度 -->
|
||||
<div id="proxyCheckProgress" class="mb-4 hidden">
|
||||
<div class="flex items-center gap-2 mb-2">
|
||||
<div class="w-4 h-4 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"></div>
|
||||
<span class="text-sm text-gray-600">检测中...</span>
|
||||
</div>
|
||||
<div class="w-full bg-gray-200 rounded-full h-2">
|
||||
<div id="progressBar" class="bg-blue-500 h-2 rounded-full transition-all duration-300" style="width: 0%"></div>
|
||||
</div>
|
||||
<div class="text-xs text-gray-500 mt-1">
|
||||
<span id="progressText">准备开始检测...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 检测结果概览 -->
|
||||
<div id="proxyCheckSummary" class="mb-4 hidden">
|
||||
<div class="grid grid-cols-3 gap-4 text-center">
|
||||
<div class="bg-green-50 border border-green-200 rounded-lg p-3">
|
||||
<div class="text-2xl font-bold text-green-600" id="availableCount">0</div>
|
||||
<div class="text-sm text-green-700">可用</div>
|
||||
</div>
|
||||
<div class="bg-red-50 border border-red-200 rounded-lg p-3">
|
||||
<div class="text-2xl font-bold text-red-600" id="unavailableCount">0</div>
|
||||
<div class="text-sm text-red-700">不可用</div>
|
||||
</div>
|
||||
<div class="bg-blue-50 border border-blue-200 rounded-lg p-3">
|
||||
<div class="text-2xl font-bold text-blue-600" id="totalCount">0</div>
|
||||
<div class="text-sm text-blue-700">总数</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 检测结果列表 -->
|
||||
<div id="proxyCheckResults" class="space-y-2" style="max-height: 400px; overflow-y: auto;">
|
||||
<!-- 检测结果将在这里动态添加 -->
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-3 mt-6">
|
||||
<button
|
||||
type="button"
|
||||
id="retryFailedProxiesBtn"
|
||||
class="bg-orange-600 hover:bg-orange-700 text-white px-6 py-2 rounded-lg font-medium transition hidden"
|
||||
>
|
||||
重试失败的代理
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
id="closeProxyCheckBtn"
|
||||
class="bg-gray-500 bg-opacity-50 hover:bg-opacity-70 text-gray-200 px-6 py-2 rounded-lg font-medium transition"
|
||||
>
|
||||
关闭
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Model Helper Modal -->
|
||||
<div id="modelHelperModal" class="modal">
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user