Commit Graph

142 Commits

Author SHA1 Message Date
fawney19
8053cbd854 feat: 分页组件支持 pageSize 浏览器缓存
- 为 Pagination 组件添加 cacheKey 属性,支持将 pageSize 缓存到 localStorage
- 组件挂载时自动恢复缓存的 pageSize 设置
- 为各页面的分页组件配置独立的缓存键
- 仅在显示 pageSize 选择器时启用缓存恢复

Closes #105

Co-Authored-By: AAEE86 <33052466+AAEE86@users.noreply.github.com>
2026-01-17 20:21:03 +08:00
fawney19
b807c16395 fix: 修复对话轮次分组器的类型安全问题
- 移除 grouper.ts 中的 as any 类型断言,使用正确的类型守卫
- 导入具体的 RenderBlock 类型替代 import() 语法
- 合并 ConversationView.vue 中的两个 watch 避免竞争条件
- 使用 lastRenderResultId 追踪变化防止重复初始化
2026-01-16 19:53:54 +08:00
LewisPen
ed1d828f85 feat: 实现对话轮次折叠视图
- 新增轮次分组逻辑,将消息按 user/assistant 配对分组
- 新增 TurnCard 组件,支持折叠/展开单个轮次
- 新增 TurnBadges 组件,显示思考/工具/图片/错误图标
- 历史轮次默认折叠,最新轮次默认展开
- 折叠时显示用户和助手消息摘要
- 统一 UI 设计规范:边距、字体、图标、圆角
2026-01-16 15:54:21 +08:00
LewisPen
691a71ac05 refactor: 将 BlockRenderer 和 ConversationView 样式改为 Tailwind
移除手写 CSS,统一使用 Tailwind 原子类,符合项目设计规范:
- BlockRenderer: 删除 260 行 scoped CSS,改用 Tailwind 类
- ConversationView: 删除 38 行 scoped CSS,改用 Tailwind 类
- 使用样式映射对象管理消息块的角色样式
2026-01-16 11:22:11 +08:00
fawney19
adc82532eb refactor: 将对话解析器拆分为独立模块
将 lib/conversationParser 重构为 conversation/ 目录:
- 按 API 格式拆分解析器 (claude.ts, openai.ts, gemini.ts)
- 提取公共渲染逻辑到 render.ts
- 添加解析器注册表支持自动格式检测
- 更新组件导入路径
2026-01-16 03:11:41 +08:00
fawney19
02770d56df refactor: 重构请求详情对话视图的渲染架构
- 新增 BlockRenderer 组件,支持递归渲染多种内容块类型
- 将 ConversationView 改为使用 RenderResult 和 BlockRenderer
- 删除旧的 messageExtractor 工具,改用 conversationParser 库
- 更新 RequestDetailDrawer 中的对话解析和复制逻辑
2026-01-16 02:53:47 +08:00
fawney19
1366c0b973 fix: 优化请求详情抽屉在窄屏的响应式布局
- 窄屏时抽屉占满全宽,宽屏时保持 800px
- 减小窄屏时的内边距 (px-3/py-3 vs px-6/py-4)
- 阶梯定价标题行在窄屏时改为垂直布局
- Tab 按钮内边距响应式调整,工具栏不被压缩
2026-01-16 01:53:59 +08:00
fawney19
8bd3a894f1 fix: 修复请求链路追踪宽度不足时节点被遮挡的问题
使用 justify-content: safe center 替代 center,
当内容溢出时自动回退到靠左对齐,确保左侧节点可滚动访问
2026-01-16 01:43:52 +08:00
fawney19
6cc66e404b fix: 将请求详情抽屉的请求头默认数据源改为提供商 2026-01-16 01:38:59 +08:00
fawney19
80887dd2cc fix: 修复请求详情抽屉的默认状态问题
- viewMode 默认改为 formatted,避免按钮被禁用
- currentExpandDepth 默认改为 0,与收缩状态一致
2026-01-15 19:23:01 +08:00
fawney19
b2731eddf3 fix: 修复对话视图合并后的问题
- 移除未使用的变量 index
- 修复展开/收缩按钮在非请求体Tab被禁用的问题
- 删除未使用的 copyJsonToClipboard 函数

Co-Authored-By: LewisPen <LewisPen@nyadoo.com>
2026-01-15 19:18:32 +08:00
LewisPen
38607332b9 feat(usage): 请求详情页面添加对话视图功能 2026-01-15 18:37:59 +08:00
fawney19
bc16c0eec8 style(usage): 调整使用记录表格类型列宽度 2026-01-15 13:44:22 +08:00
fawney19
bc2b430ec3 style(usage): 请求链路节点改回居中布局并修复 TypeScript 兼容性
- 将节点布局从两端对齐改回居中展示
- 将 findLastIndex 替换为向后兼容的 for 循环实现
2026-01-15 13:29:22 +08:00
fawney19
514bf7e3ed feat(usage): 改进请求追踪与缓存预热
- 区分请求重试与故障转移:新增 has_retry 标识亲和缓存重试
- 修正候选 TTFB 计算:记录候选自身的首字节时间而非全局时间
- Streaming 状态同步 rate_multiplier,支持按 API 格式配置
- 新增缓存预热服务:启动时预热仪表盘统计、热力图、每日统计
- 优化缓存 TTL 配置:仪表盘统计 2 分钟、热力图和每日统计 10 分钟
- 自动刷新间隔从 10 秒调整为 5 秒
2026-01-15 11:45:46 +08:00
fawney19
c51f94ee87 style(ui): 将请求链路轨道布局从居中改为两端对齐
fix #94

Co-Authored-By: AAEE86 <AAEE86@users.noreply.github.com>
2026-01-15 02:44:06 +08:00
fawney19
97d66a8d0c feat(trace): 在请求链路追踪中记录并展示首字时间(TTFB)
将 first_byte_time_ms 添加到候选记录的 extra_data 中,
并在前端时间线组件中展示该指标。
2026-01-14 16:41:58 +08:00
fawney19
1f6e384d2b fix(ui): 居中对齐时间线轨道内容 2026-01-14 15:43:01 +08:00
fawney19
6fdb944b1e fix(ui): correct node-line positioning for horizontal scroll
Add proper absolute positioning (right: -64px, top: 50%) to ensure
connection lines correctly span the gap between timeline nodes.
2026-01-13 19:17:53 +08:00
AAEE86
d488f809d5 feat(ui): add horizontal scrolling to request timeline 2026-01-13 19:16:08 +08:00
fawney19
09e0f594ff refactor: 重构限流系统和健康监控,支持按 API 格式区分
- 将 adaptive_concurrency 重命名为 adaptive_rpm,从并发控制改为 RPM 控制
- 健康监控器支持按 API 格式独立管理健康度和熔断器状态
- 新增 model_permissions 模块,支持按格式配置允许的模型
- 重构前端提供商相关表单组件,新增 Collapsible UI 组件
- 新增数据库迁移脚本支持新的数据结构
2026-01-10 18:48:35 +08:00
fawney19
431c6de8d2 feat: 用户用量页面支持分页、搜索和密钥信息展示
- 用户用量API增加search参数支持密钥名、模型名搜索
- 用户用量API返回api_key信息(id、name、display)
- 用户页面记录表格增加密钥列显示
- 前端统一管理员和用户页面的分页/搜索逻辑
- 后端LIKE查询增加特殊字符转义防止SQL注入
- 添加escape_like_pattern和safe_truncate_escaped工具函数
2026-01-05 19:35:14 +08:00
AoaoMH
93ab9b6a5e feat: add usage statistics and records feature with new API routes, frontend types, services, and UI components 2026-01-05 17:03:05 +08:00
fawney19
a2f33a6c35 perf: 拆分热力图为独立接口并添加 Redis 缓存
- 新增独立热力图 API 端点 (/api/admin/usage/heatmap, /api/users/me/usage/heatmap)
- 添加 Redis 缓存层 (5分钟 TTL),减少数据库查询
- 用户角色变更时清除热力图缓存
- 前端并行加载统计数据和热力图,添加加载/错误状态显示
- 修复 cache_decorator 缺少 JSON 解析错误处理的问题
- 更新 docker-compose 启动命令提示
2026-01-04 22:42:58 +08:00
fawney19
b5c0f85dca refactor: 统一剪贴板复制功能到 useClipboard 组合式函数
将各个组件和视图中重复的剪贴板复制逻辑提取到 useClipboard 组合式函数。
增加 showToast 参数支持静默复制,减少代码重复,提高维护性。
2025-12-28 20:41:52 +08:00
fawney19
1d5c378343 feat: add TTFB timeout detection and improve stream handling
- Add stream first byte timeout (TTFB) detection to trigger failover
  when provider responds too slowly (configurable via STREAM_FIRST_BYTE_TIMEOUT)
- Add rate limit fail-open/fail-close strategy configuration
- Improve exception handling in stream prefetch with proper error classification
- Refactor UsageService with shared _prepare_usage_record method
- Add batch deletion for old usage records to avoid long transaction locks
- Update CLI adapters to use proper User-Agent headers for each CLI client
- Add composite indexes migration for usage table query optimization
- Fix streaming status display in frontend to show TTFB during streaming
- Remove sensitive JWT secret logging in auth service
2025-12-22 23:44:42 +08:00
fawney19
7553b0da80 fix: 优化自动刷新交互和ESC关闭样式
- 自动刷新改为按钮切换模式,移除独立Switch开关
- 自动刷新间隔从30s改为10s
- ESC关闭弹窗后blur焦点,避免样式残留
2025-12-19 18:47:14 +08:00
hoping
8c12174521 个性化处理
1. 为所有抽屉和对话框添加 ESC 键关闭功能;
2. 为`使用记录`表格添加自动刷新开关;
3. 为后端 API 请求增加 User-Agent 头部;
4. 修改启动命令支持从.env中读取数据库和Redis配置。
2025-12-19 17:31:15 +08:00
fawney19
7b932d7afb refactor: optimize middleware with pure ASGI implementation and enhance security measures
- Replace BaseHTTPMiddleware with pure ASGI implementation in plugin middleware for better streaming response handling
- Add trusted proxy count configuration for client IP extraction in reverse proxy environments
- Implement audit log cleanup scheduler with configurable retention period
- Replace plaintext token logging with SHA256 hash fingerprints for security
- Fix database session lifecycle management in middleware
- Improve request tracing and error logging throughout the system
- Add comprehensive tests for pipeline architecture
2025-12-18 19:07:20 +08:00
fawney19
f1e3c2ab11 feat(frontend-usage): enhance usage UI with first byte latency metrics
- Update usage records table to display first_byte_time_ms metrics
- Improve request timeline visualization for latency tracking
- Extend usage types for new timing information
2025-12-16 02:39:54 +08:00
fawney19
3296d026e3 fix(frontend): only show model mapping when actual model differs from requested model 2025-12-15 15:05:30 +08:00
fawney19
9ca845f9d0 refactor(frontend): optimize feature components (models, providers, usage) 2025-12-14 00:16:02 +08:00
fawney19
a75b983419 refactor(frontend): 优化 Usage 功能模块可组合函数
- 改进 useUsageData 和 useUsageFilters composables
2025-12-14 00:16:02 +08:00
fawney19
63e1a0d823 refactor(frontend): 优化 Usage 功能模块组件
- 改进 HorizontalRequestTimeline, IntervalTimelineCard, RequestDetailDrawer 等组件
- 优化表格展示组件
2025-12-14 00:16:02 +08:00
fawney19
ca60202636 fix: 修复链路追踪密钥显示和默认选中逻辑
1. 修复密钥脱敏显示问题:先解密再脱敏,避免显示加密后的 base64 数据
2. 优化详情默认选中逻辑:优先显示最后一个有效结果(成功/失败),而非未执行/跳过
2025-12-14 00:16:02 +08:00
fawney19
06c0a47b21 refactor(frontend): 优化功能模块组件
- 更新 api-keys 模块: StandaloneKeyFormDialog
- 改进 auth 模块: LoginDialog
- 优化 models 模块: AliasDialog, GlobalModelFormDialog, ModelDetailDrawer, TieredPricingEditor
- 重构 providers 模块: 多个表单和对话框组件
- 更新 usage 模块: 时间线、表格和详情组件
- 调整 users 模块: UserFormDialog
2025-12-12 16:15:36 +08:00
fawney19
e902595d58 refactor(frontend): 优化工具函数和 mock handler
- 更新 format.ts 工具函数
- 调整 mock handler 和 useDateRange composable
2025-12-12 16:14:49 +08:00
fawney19
93eeedfcfa fix: 限制散点图图例显示数量,防止溢出 2025-12-11 21:36:39 +08:00
fawney19
0e8bf0a23b feat: 请求间隔散点图按模型区分颜色
- 后端 get_interval_timeline 接口返回数据添加 model 字段
- 前端散点图按模型分组显示不同颜色的数据点
- 横线统计信息支持按模型分别显示统计数据
- 管理员视图保持按用户分组,用户视图按模型分组
- 更新 mock 数据支持模型字段
2025-12-11 21:33:39 +08:00
fawney19
6e8107e340 fix: 修复管理员散点图只显示部分用户的问题
- 改为按比例采样,保持各用户数据量比例不变
- 散点图默认时间从7天改为当天(24小时)
- limit 从 2000 提高到 10000
2025-12-11 19:34:56 +08:00
fawney19
cc4e28ad16 feat: 添加使用量统计和数据分析功能 2025-12-11 17:52:32 +08:00
fawney19
f784106826 Initial commit 2025-12-10 20:52:44 +08:00