feat 新增每日消费限额功能,完善限额日志显示#145
Merged
ding113 merged 24 commits intoding113:feat/daily-limitfrom Nov 21, 2025
Merged
Conversation
*Total -- 1,193.12kb -> 874.91kb (26.67%) /public/readme/排行榜.png -- 158.35kb -> 110.57kb (30.17%) /public/readme/日志.png -- 265.04kb -> 193.59kb (26.96%) /public/readme/首页.png -- 365.05kb -> 269.36kb (26.21%) /public/readme/供应商管理.png -- 404.68kb -> 301.38kb (25.53%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
…time Add daily limit feature for keys and providers with a configurable daily reset time (HH:mm). Extend DB schema with limit_daily_usd and daily_reset_time, update rate-limit service to calculate and enforce daily limits using per-day windows with TTL based on reset time, extend time-utils to include daily period handling and next reset computations, and update transformers, repositories, and API handlers to propagate new fields. Also fix provider UI dialogs width for consistent layout.
…er-page-size-1e1f7f0)
[ImgBot] Optimize images
新增 `dailyResetMode` 配置项,允许用户选择每日限额的重置方式: - `fixed`: 在每天固定时间点重置(默认行为) - `rolling`: 从首次调用开始计算,24小时内滚动重置 该功能影响 Key 和 Provider 的限流逻辑,并更新了相关数据库字段、表单控件及 Redis 脚本。前端界面已添加对应选项和描述说明,确保用户可理解两种模式的区别。 同时扩展了 RateLimitService 中的时间范围和 TTL 计算方法以兼容新模式, 并引入两个新的 Lua 脚本用于处理 Redis 中的滚动窗口数据。
…er-page-size-fc62260)
移除了页面组件中重复声明的 configPath 变量,该变量在代码中已经正确定义, 重复声明可能导致潜在的逻辑错误或维护问题。此修复确保了配置路径的正确性和代码的简洁性。
- 在密钥和提供商表单中添加日重置模式选择器(固定窗口/滚动窗口) - 更新验证模式以包含新的daily_reset_mode字段 - 修复仓储层查询遗漏dailyResetMode字段的问题 - 改进日志记录以避免敏感数据泄露,仅在开发环境输出 - 为所有语言文件添加缺失的配置路径翻译key - 支持Linux系统的配置文件路径并修正JSON代码块语法 - 统一限流服务调用以正确处理不同模式的日限额计算 - 调整返回类型使其支持滚动模式下的可选重置时间 - 更新用户界面文案以统一占位符语法
…er-page-size-59a0326)
…et-time-fix-provider-page-size feat(rate-limit): add daily per-day limit with customizable reset time and fix provider page UI
- 将 `costDaily.resetAt` 字段设为可选,处理可能不存在重置时间的情况 - 在显示重置时间前添加条件检查,避免未定义值导致的渲染错误 - 更新相关组件中的类型定义,确保类型一致性 - 修复 `formatDateDistance` 函数调用,传入当前日期作为参考时间
- 新增统一的错误响应格式文档,详细说明各种错误场景 - 添加限流排查脚本,便于调试和诊断消费限额问题 - 在供应商选择器中增加详细的限流和熔断器过滤信息 - 重构错误响应构建方法,支持错误类型代码和详细上下文信息 - 为前端和CLI客户端提供结构化的错误数据,便于友好显示和问题定位
- 添加对selectionContext中filteredProviders的空值检查 - 通过可选链操作符安全访问可能为空的属性 - 重构条件逻辑以正确处理不同错误场景 - 避免在filteredProviders为undefined时抛出异常
- 在错误详情对话框中增强限流和熔断错误的可视化展示,区分 JSON 错误和纯文本错误 - 新增"被过滤的供应商"显示区域,在成功请求时展示因限流或熔断被排除的供应商 - 改进错误消息解析逻辑,为限流、熔断和混合不可用错误提供专门的UI样式 - 更新错误处理器,在供应商不可用时记录详细的错误信息到数据库 - 优化 ProviderSelector 的错误判断逻辑,更准确地区分不同类型的不可用状态 - 添加多语言支持,为所有语言版本增加 filteredProviders 翻译字段 - 增强错误信息展示的用户体验,提供更清晰的错误原因和供应商状态说明
Contributor
Author
|
还有点问题,我中午再修修 |
Contributor
Author
|
测试通过,审查下 |
Owner
|
这个 PR 的数据库迁移已经和 dev 分支不同步了,请问是否可以重新同步一下 dev 分支,把数据库迁移脚本统一放在 21? |
Contributor
Author
好的,稍等 |
- 重命名 0018_square_ozymandias.sql → 0021_square_ozymandias.sql - 重命名 0019_open_stephen_strange.sql → 0022_open_stephen_strange.sql - 重命名 0020_nosy_synch.sql → 0023_nosy_synch.sql - 更新 drizzle/meta/_journal.json 添加新的迁移条目 - 确保与上游 zsio/claude-code-hub 的迁移文件不冲突
- 合并 0021_square_ozymandias.sql, 0022_open_stephen_strange.sql, 0023_nosy_synch.sql 到 0021_daily_cost_limits.sql - 包含完整的每日成本限额功能:字段添加、约束设置、重置模式 - 更新 drizzle/meta/_journal.json 移除多余条目 - 提升迁移文件可维护性和执行效率
Contributor
Author
|
已合并到21 |
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.
每日消费限额:可为服务商设置每日消费上限
每日重置配置:支持自定义每日限额重置时间(HH:mm)和重置模式(固定/滚动)
配额统计:仪表盘新增每日消费使用情况显示和管理界面
容器日志返回