feat(dashboard): 新增实时 Web Dashboard 页面,聚合展示流量与用量统计#159
Merged
Conversation
- 新增 src/coding/proxy/server/dashboard.py,包含: - GET /dashboard:嵌入式 HTML Dashboard 页面(深色主题,Chart.js 可视化) - GET /api/dashboard/summary:汇总今日/本周/本月请求数、Token 量、费用、故障转移、平均延迟 - GET /api/dashboard/timeline:按天分组的时序数据,支持 days 参数(1~90) - 在 routes.py register_all_routes() 末尾追加 register_dashboard_routes(app) 注册调用 - Dashboard 布局:KPI 卡片 × 6、供应商状态面板(熔断器 + 配额进度条)、 7 天请求趋势折线图、供应商分布环形图、Token 类型堆叠柱图、故障转移明细表 - 前端每 30 秒自动刷新,支持手动刷新;数据层复用 TokenLogger.query_usage() 与 PricingTable - 不修改任何现有路由逻辑,1181 个测试全部通过 🤖 Generated with [Claude Code](https://github.com/claude) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
coding-proxy 已具备完整的 token 使用记录(SQLite)与 CLI 统计工具(
coding-proxy usage、coding-proxy status),但缺少 Web 可视化界面。用户需要一个实时、体系完整、聚焦重点的 Dashboard 页面,将流量与用量统计系统化、优雅地呈现出来。变更内容
新增文件
src/coding/proxy/server/dashboard.pyGET /dashboard:嵌入式 HTML Dashboard 页面(深色主题,无外部构建依赖)GET /api/dashboard/summary:汇总今日 / 本周 / 本月的请求数、Token 量、费用估算、故障转移次数、平均延迟GET /api/dashboard/timeline:按天分组的时序数据,支持days参数(1~90 天),用于前端图表绘制修改文件
src/coding/proxy/server/routes.py在
register_all_routes()末尾追加register_dashboard_routes(app)调用(+4 行,不修改任何现有路由逻辑)Dashboard 页面版块
技术栈: Vanilla JS + Chart.js(jsDelivr CDN) + CSS Variables 深色主题;前端每 30 秒自动刷新,支持手动刷新
设计原则
TokenLogger.query_usage()/query_failover_stats()/PricingTable验证
uv run coding-proxy start # 浏览器访问 http://localhost:8046/dashboard🤖 Generated with Claude Code
Co-Authored-By: Aurelius Huangthreefish.ai@gmail.com