mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-05-11 10:00:37 +08:00
- 在后端 (`services.py`, `log_routes.py`) 实现按 Gemini 密钥(模糊匹配)、错误类型/内容(模糊匹配)和日期范围(开始/结束日期)过滤错误日志的逻辑。
- 添加新函数 `get_error_logs_count` 以高效获取符合过滤条件的总日志数,用于分页。
- 更新 `/api/logs/errors` API 端点以接受 `key_search`, `error_search`, `start_date`, `end_date` 查询参数。端点现在返回包含过滤后日志和总数的对象。
- 增强前端 (`error_logs.html`, `error_logs.js`, `error_logs.css`):
- 添加用于密钥搜索、错误/日志搜索和日期范围选择的输入字段。
- 实现 JavaScript 逻辑以捕获搜索参数,使用过滤器触发 API 调用,并在新搜索时重置到第一页。
- 更新表格渲染以显示顺序行号而非数据库 ID。
- 在表格视图中遮罩 Gemini 密钥(显示前/后 4 个字符)以提高可读性,同时仍在详细信息模态框中显示完整密钥。
- 优化新搜索控件、表格外观(内边距、边框、悬停效果、斑马条纹)和按钮样式的 CSS,以提供更清晰的用户界面。
- 通过使用 `logger.exception` 包含堆栈跟踪来改进后端服务中的错误日志记录。
166 lines
7.2 KiB
HTML
166 lines
7.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>错误日志管理</title>
|
|
<link rel="manifest" href="/static/manifest.json">
|
|
<meta name="theme-color" content="#764ba2">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
<meta name="apple-mobile-web-app-title" content="GBalance">
|
|
<link rel="icon" href="/static/icons/icon-192x192.png">
|
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
|
<!-- Use config_editor.css for base styles -->
|
|
<link rel="stylesheet" href="{{ url_for('static', path='/css/config_editor.css') }}">
|
|
<!-- Keep error_logs.css for specific styles -->
|
|
<link rel="stylesheet" href="{{ url_for('static', path='/css/error_logs.css') }}">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<button class="refresh-btn" onclick="refreshPage(this)">
|
|
<i class="fas fa-sync-alt"></i>
|
|
</button>
|
|
<h1>Gemini Balance</h1>
|
|
<div class="nav-tabs">
|
|
<a href="/config" class="tab-link">
|
|
<i class="fas fa-cog"></i> 配置编辑
|
|
</a>
|
|
<a href="/keys" class="tab-link">
|
|
<i class="fas fa-key"></i> 密钥管理
|
|
</a>
|
|
<a href="/logs" class="tab-link active">
|
|
<i class="fas fa-exclamation-triangle"></i> 错误日志
|
|
</a>
|
|
</div>
|
|
|
|
<div class="config-section active"> <!-- Use config-section for consistent layout -->
|
|
<h2><i class="fas fa-bug"></i> 错误日志列表</h2>
|
|
|
|
<div class="controls-container"> <!-- New container for controls -->
|
|
<div class="page-size-selector">
|
|
<label for="pageSize">每页显示:</label>
|
|
<select id="pageSize">
|
|
<option value="10">10</option>
|
|
<option value="20" selected>20</option>
|
|
<option value="50">50</option>
|
|
<option value="100">100</option>
|
|
</select>
|
|
<span>条</span>
|
|
</div>
|
|
<button id="refreshBtn" class="action-btn"> <!-- Use a consistent button class -->
|
|
<i class="fas fa-sync-alt"></i> 刷新
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Search Controls -->
|
|
<div class="search-container">
|
|
<input type="text" id="keySearch" placeholder="搜索密钥 (部分)">
|
|
<input type="text" id="errorSearch" placeholder="搜索错误类型/日志"> <!-- Changed ID -->
|
|
<input type="date" id="startDate">
|
|
<span>至</span>
|
|
<input type="date" id="endDate">
|
|
<button id="searchBtn" class="action-btn">
|
|
<i class="fas fa-search"></i> 搜索
|
|
</button>
|
|
</div>
|
|
|
|
<div class="table-container"> <!-- New container for table -->
|
|
<table class="styled-table"> <!-- Use a custom table class -->
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Gemini密钥</th>
|
|
<th>错误类型</th>
|
|
<th>错误日志</th>
|
|
<th>模型名称</th>
|
|
<th>请求时间</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="errorLogsTable">
|
|
<!-- 错误日志数据将通过JavaScript动态加载 -->
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div id="loadingIndicator" class="status-indicator loading"> <!-- Custom loading indicator -->
|
|
<div class="spinner"></div>
|
|
<p>加载中,请稍候...</p>
|
|
</div>
|
|
|
|
<div id="noDataMessage" class="status-indicator no-data"> <!-- Custom no-data message -->
|
|
<p>暂无错误日志数据</p>
|
|
</div>
|
|
|
|
<div id="errorMessage" class="status-indicator error"> <!-- Custom error message -->
|
|
<p>加载错误日志失败,请稍后重试。</p>
|
|
</div>
|
|
|
|
<div class="pagination-container"> <!-- Custom pagination container -->
|
|
<ul class="pagination" id="pagination">
|
|
<!-- 分页控件将通过JavaScript动态加载 -->
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="scroll-buttons">
|
|
<button class="scroll-btn" onclick="scrollToTop()" title="回到顶部">
|
|
<i class="fas fa-chevron-up"></i>
|
|
</button>
|
|
<button class="scroll-btn" onclick="scrollToBottom()" title="滚动到底部">
|
|
<i class="fas fa-chevron-down"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<div id="copyStatus" class="notification"></div> <!-- Use notification class -->
|
|
|
|
<div class="copyright">
|
|
© <script>document.write(new Date().getFullYear())</script> by <a href="https://linux.do/u/snaily" target="_blank"><img src="https://linux.do/user_avatar/linux.do/snaily/288/306510_2.gif" alt="snaily">snaily</a> |
|
|
<a href="https://github.com/snailyp/gemini-balance" target="_blank"><i class="fab fa-github"></i> GitHub</a>
|
|
</div>
|
|
|
|
<!-- Custom Modal for Log Details -->
|
|
<div id="logDetailModal" class="modal">
|
|
<div class="modal-content">
|
|
<span class="close-btn" id="closeLogDetailModalBtn">×</span>
|
|
<h2>错误日志详情</h2>
|
|
<div class="modal-body-content"> <!-- Added wrapper for consistent padding/styling -->
|
|
<div class="detail-item">
|
|
<h6>Gemini密钥:</h6>
|
|
<pre id="modalGeminiKey"></pre>
|
|
</div>
|
|
<div class="detail-item">
|
|
<h6>错误类型:</h6>
|
|
<p id="modalErrorType"></p>
|
|
</div>
|
|
<div class="detail-item">
|
|
<h6>错误日志:</h6>
|
|
<pre id="modalErrorLog"></pre>
|
|
</div>
|
|
<div class="detail-item">
|
|
<h6>请求消息:</h6>
|
|
<pre id="modalRequestMsg"></pre>
|
|
</div>
|
|
<div class="detail-item">
|
|
<h6>模型名称:</h6>
|
|
<p id="modalModelName"></p>
|
|
</div>
|
|
<div class="detail-item">
|
|
<h6>请求时间:</h6>
|
|
<p id="modalRequestTime"></p>
|
|
</div>
|
|
</div>
|
|
<div class="modal-actions">
|
|
<button type="button" id="closeModalFooterBtn" class="reset-btn">关闭</button> <!-- Use consistent button style -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Keep custom JS, remove Bootstrap JS -->
|
|
<script src="{{ url_for('static', path='/js/error_logs.js') }}"></script>
|
|
</body>
|
|
</html>
|