Conversation
* fix: 供应商管理列表增加类型筛选和图标显示, close #22 新功能: 1. 增加供应商类型筛选功能 - 支持按 Claude、Claude Auth、Codex、Gemini CLI、OpenAI Compatible 筛选 - 显示当前筛选结果数量 2. 供应商卡片名称增加类型图标和标签 - 类型图标(5 种不同颜色和图标) - 类型标签(文字说明) - 鼠标悬停显示类型描述 实现细节: - 新增 provider-type-utils.tsx:统一管理供应商类型配置 - 新增 provider-type-filter.tsx:类型筛选组件 - 修改 provider-manager.tsx:集成筛选功能和计数显示 - 修改 provider-list-item.tsx:添加类型图标和标签 Close #22 * feat: 添加 @lobehub/icons 依赖并更新供应商类型图标 - 新增 @lobehub/icons 依赖,支持更丰富的图标展示。 - 更新供应商类型配置,使用新的图标组件替代原有图标。 - 为 Anthropic 类型添加专用的橙色包装组件,提升视觉一致性。 影响范围: - 供应商管理界面图标展示更为美观,增强用户体验。 --------- Co-authored-by: Claude Code Bot <noreply@anthropic.com> Co-authored-by: ding113 <h.ding.262@gmail.com>
- 修复 sumUserCostToday 中 SQL JOIN 条件错误(message_request.key 应与 keys.key 关联,而非 keys.id) - 修复日志字符串插值未生效问题(单引号改为反引号) - 移除不必要的类型断言,利用 TypeScript 类型收窄 - 优化 Redis TTL 计算,使用配置时区而非服务器本地时区 - 添加 date-fns-tz 依赖用于时区处理 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Modified `claude-assistant.yml` to reduce pull request event types and limit issue event types to only labeled events. - Updated `claude-ci-autofix.yml` to remove the requirement for associated pull requests, allowing CI fixes on any branch.
- 修复 src/repository/statistics.ts 中的 TypeScript any 类型错误(第 579 行) - 移除 src/app/dashboard/_components/user/key-limit-usage.tsx 中未使用的 err 变量 - 移除 src/app/settings/providers/_components/provider-list-item.tsx 中未使用的导入(ServerCog, AddProviderDialog) - 移除 src/app/usage-doc/page.tsx 中未使用的导入和变量(cn, lang, configDir) - 移除 src/lib/rate-limit/service.ts 中未使用的 now 变量 所有修复均为 ESLint 相关的代码质量改进,不影响功能逻辑。 相关 CI Run: https://github.com/ding113/claude-code-hub/actions/runs/18933737607
- Removed the requirement for the commit message in scenario B to include [skip ci], ensuring it triggers CI again. - Adjusted instructions for auto-fixing CI failures to reflect the new commit message policy. This change aims to streamline the CI process and improve clarity in the workflow documentation.
- Introduced a new environment variable ENABLE_CODEX_INSTRUCTIONS_INJECTION to control the injection of official Codex instructions into requests. - Updated .env.example and CLAUDE.md to document the new feature and its usage scenarios. - Modified request-sanitizer.ts to implement the logic for conditionally replacing instructions based on the new feature flag. This enhancement allows for better compatibility with certain Codex providers that require official instructions.
- Implemented a check to ensure that the provider belongs to the user's specified group, enhancing security and user experience. - Added debug logging for session provider group mismatches to aid in troubleshooting. This change ensures that only appropriate providers are selected based on user group settings.
- Modified the SQL query in getProviderStatistics to calculate today's cost and call count using JavaScript Date for local timezone handling. - This change ensures accurate statistics based on the user's local time, improving the reliability of provider data reporting.
- Implemented `getProviderLimitUsage` and `getUserLimitUsage` functions to retrieve usage statistics for providers and users, respectively. - These functions include permission checks and dynamic imports to avoid circular dependencies. - Updated the dashboard header to include a link for quota management, enhancing user navigation. - Refactored the `RateLimitService` to utilize new utility functions for time range and TTL calculations, improving code maintainability.
将三个配额统计页面(users/providers/keys)的 UI 逻辑重构为独立组件,提升代码复用性和可维护性。 **主要改动**: - 提取用户配额组件到 `_components/users-quota-client.tsx` - 提取服务商配额组件到 `_components/providers-quota-manager.tsx` - 提取密钥配额组件到 `_components/keys-quota-manager.tsx` - 新增公共配额工具栏组件 `components/quota/quota-toolbar.tsx` - 新增前端设计文档 `FRONTEND_DESIGN.md` **技术改进**: - 统一配额卡片展示逻辑 - 支持排序和过滤功能 - 改善代码组织结构 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
新增功能: - 创建密钥限额编辑 Dialog,支持设置/修改/清除所有类型限额 - 重构密钥限额页面布局,分离已设置和未设置限额的密钥 - 未设置限额的密钥收纳到底部可折叠区域,使用紧凑的横向分栏布局 改进细节: - EditKeyQuotaDialog: 支持编辑 5小时/周/月消费限额和并发 Session 限额 - 显示当前用量对比,帮助用户合理设置限额 - 提供"清除所有限额"按钮,快速重置配置 - 已设置限额的密钥保持卡片布局,展示详细的进度条和重置时间 - 未设置限额的密钥使用列表布局(一行一个),节省空间不占用主视觉区域 - 所有密钥卡片/列表项都添加"设置限额"按钮,操作统一便捷 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fetch system currency settings in all quota pages (users, keys, providers) - Pass currencyCode prop through component hierarchy: Page → Manager → Client → Dialog - Update all formatCurrency() calls to use system-configured currency code - Update EditKeyQuotaDialog to dynamically display currency symbol from configuration - Ensure consistent currency display (USD, CNY, etc.) across entire quota management feature 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Owner
Author
|
此 PR 是从 dev 分支合并到 main 分支,因此请无视目标分支规则正常审核 |
Contributor
代码审查报告 🔍感谢提交这个全面的限额管理功能!这是一个设计良好、实现细致的大型 PR。以下是我的审查意见: ✅ 亮点与优秀设计1. 时间算法修正 (src/lib/rate-limit/time-utils.ts)
2. 降级策略完善 (src/lib/rate-limit/service.ts)
3. 前端架构清晰 (src/app/dashboard/quotas/)
4. 文档完善 (FRONTEND_DESIGN.md)
|
| * - weekly: 到下周一 00:00 的秒数 | ||
| * - monthly: 到下月 1 号 00:00 的秒数 | ||
| */ | ||
| export function getTTLForPeriod(period: TimePeriod): number { |
Contributor
There was a problem hiding this comment.
✅ 优秀设计:动态 TTL 避免数据泄漏
这个设计很棒!通过动态计算 TTL 到下一个重置点,确保:
- Redis key 在正确的时间自动过期
- 不会出现"跨周/跨月"的脏数据
- 节省 Redis 内存
建议:考虑添加单元测试验证边界情况:
// 测试用例
test("weekly TTL at Sunday 23:59", () => {
// 周日 23:59 的 TTL 应该约为 60 秒(1分钟后是周一)
});
test("monthly TTL on last day", () => {
// 月末最后一天的 TTL 应该正确计算到次月 1 号
});| <p className="text-muted-foreground">查看和管理所有层级的限额使用情况</p> | ||
| </div> | ||
|
|
||
| <Tabs defaultValue="users" className="space-y-4"> |
Contributor
There was a problem hiding this comment.
📝 UI 小建议:Tabs 选中状态未根据当前路由高亮
当前问题:无论在哪个子页面,defaultValue="users" 都会高亮"用户限额"。
建议修复:根据当前路由动态设置 value:
"use client";
import { usePathname } from "next/navigation";
export default function QuotasLayout({ children }: { children: React.ReactNode }) {
const pathname = usePathname();
const currentTab = pathname.split("/").pop() || "users";
return (
<div className="space-y-6">
{/* ...省略... */}
<Tabs value={currentTab} className="space-y-4">
{/* ...省略... */}
</Tabs>
</div>
);
}或者使用 Shadcn 的导航组件(更语义化):
<nav className="flex space-x-2">
<Link href="/dashboard/quotas/users">
<Button variant={isActive ? "default" : "ghost"}>用户限额</Button>
</Link>
{/* ... */}
</nav>
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.
No description provided.