feat: 实现API请求重试并改进UI/UX

主要变更:

1.  **API 请求重试机制:**
    *   在配置 (`.env.example`, `config.py`, `constants.py`) 中添加 `MAX_RETRIES` 设置,用于控制 API 请求失败后的最大重试次数 (默认为 3)。
    *   更新 `RetryHandler` (`retry_handler.py`) 以使用此配置。
    *   将 `RetryHandler` 应用于 Gemini 和 OpenAI 的内容生成路由 (`gemini_routes.py`, `openai_routes.py`),使其能够根据配置进行重试。
    *   在配置编辑器页面 (`config_editor.html`) 添加 `MAX_RETRIES` 的输入字段。

2.  **密钥状态页面 (Keys Status) UI/UX 改进:**
    *   默认隐藏 API 密钥的完整内容,仅显示部分字符 (`keys_status.html`),提高安全性。
    *   添加了切换按钮和相应的 JavaScript (`keys_status.js`) 及 CSS (`keys_status.css`),允许用户点击查看或隐藏完整的密钥。
    *   更新了“复制密钥”功能 (`keys_status.js`),确保复制的是完整的密钥而非掩码后的部分。

3.  **错误日志页面 (Error Logs) 重构与改进:**
    *   重构了 HTML 结构 (`error_logs.html`),使用更一致和语义化的 class(如 `config-section`, `controls-container`, `styled-table`, `status-indicator`),并移除了 Bootstrap 依赖。
    *   更新了 CSS (`error_logs.css`) 以匹配新的 HTML 结构,改进了页面布局和视觉样式。
    *   改进了 JavaScript (`error_logs.js`),优化了加载、无数据、错误状态的显示逻辑,改进了分页功能,并添加了通用的通知显示函数 (`showNotification`)。
    *   在错误日志表格和详情弹窗中添加了“错误类型”列/字段。

4.  **其他:**
    *   对聊天服务 (`gemini_chat_service.py`, `openai_chat_service.py`) 和密钥管理器 (`key_manager.py`) 进行了相关更新
This commit is contained in:
snaily
2025-04-10 18:32:21 +08:00
parent d94d24f96c
commit f05d67939f
16 changed files with 791 additions and 534 deletions

View File

@@ -186,12 +186,16 @@ li:hover {
display: flex;
align-items: center;
gap: 15px;
flex: 1;
flex: 1; /* Allow key-info to take up available space */
min-width: 0; /* Prevent flex item from overflowing */
}
.key-text {
font-family: 'Roboto Mono', monospace;
color: #2c3e50;
word-break: break-all; /* Ensure long keys wrap */
flex-shrink: 1; /* Allow key text to shrink if needed */
margin-right: 10px; /* Add space between key text and toggle button */
}
.fail-count {
@@ -443,6 +447,27 @@ li:hover {
to { transform: rotate(360deg); }
}
/* Toggle Visibility Button Styles */
.toggle-vis-btn {
background: none;
border: none;
color: #7f8c8d; /* Subtle color */
cursor: pointer;
padding: 5px;
font-size: 16px;
transition: color 0.3s ease;
margin-left: 5px; /* Space from key text */
flex-shrink: 0; /* Prevent button from shrinking */
}
.toggle-vis-btn:hover {
color: #34495e; /* Darker color on hover */
}
.toggle-vis-btn i {
vertical-align: middle;
}
@media (max-width: 768px) {
.container {
width: 100%;
@@ -478,6 +503,7 @@ li:hover {
flex-direction: column;
align-items: flex-start;
gap: 8px;
width: 100%; /* Ensure key-info takes full width */
}
li {
flex-direction: column;
@@ -493,7 +519,8 @@ li:hover {
justify-content: center;
}
.key-text {
word-break: break-all;
/* word-break: break-all; */ /* Already applied above */
margin-right: 0; /* Remove right margin on smaller screens */
}
.scroll-buttons {
right: 10px;