Skip to content

Comments

feat: 重构供应商管理页面#86

Merged
ding113 merged 22 commits intomainfrom
dev
Nov 7, 2025
Merged

feat: 重构供应商管理页面#86
ding113 merged 22 commits intomainfrom
dev

Conversation

@ding113
Copy link
Owner

@ding113 ding113 commented Nov 6, 2025

No description provided.

ding113 and others added 9 commits November 6, 2025 17:33
- Replaced the existing JSON parsing logic with a dedicated parseUsageFromResponseText function to enhance clarity and maintainability.
- Consolidated usage metrics extraction from both JSON responses and SSE events, improving the handling of various response formats.
- Updated logging to provide better insights into usage metrics captured from different sources.

This refactor simplifies the response handling process and improves the overall robustness of usage metrics extraction.
问题根源:
- getProviderStatistics() 使用字符串日期比较,导致统计数据与首页/排行榜不一致

修复内容:
- 移除字符串日期构造(todayLocalStr/tomorrowLocalStr)
- 使用 Date 对象进行范围查询(与 overview.ts/leaderboard.ts 一致)
- 简化 SQL 查询,移除复杂的 AT TIME ZONE 转换
- 移除未使用的 getEnvConfig 导入

影响:
- 供应商页面将显示与其他页面一致的每日用量数据
- 代码简化 14 行,提高可维护性
- 保持函数签名不变,向后兼容

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
完成供应商管理页面的全面 UI/UX 重构,优化列表展示和详情编辑体验。

主要变更:

### 数据模型扩展 (IMPL-1)
- 新增 websiteUrl 和 faviconUrl 字段到 Provider 模型
- 创建数据库迁移 0016_curious_paladin.sql
- 实现自动 favicon 获取(Google Favicon API)
- 更新所有数据层(types, schema, actions, repository)

### 表单折叠优化 (IMPL-2)
- 使用 Collapsible 组织 843 行表单的 5 个高级功能区域
- 实现 localStorage 偏好记忆
- 添加展开/折叠全部按钮
- 每个区域显示当前配置状态摘要

### 搜索功能集成 (IMPL-3)
- 在 ProviderManager 中新增搜索框
- 使用 useDebounce (500ms) 优化性能
- 支持模糊匹配 name、url、groupTag 三个字段
- 统一搜索/筛选/排序逻辑到单一 useMemo

### API Key 安全展示 (IMPL-4)
- 实现 Dialog 模式的密钥展示和复制功能
- 添加 getUnmaskedProviderKey server action(仅 admin)
- 参考 key-list-header 模式实现安全机制
- 复制按钮带 CheckCircle 反馈

### 列表组件重构 (IMPL-5)
- 创建 ProviderRichListItem 组件(水平布局)
- 卡片式网格布局改为富文本列表式
- 移除所有 Popover 内联编辑,统一使用 Dialog
- 集成 favicon 显示和官网跳转
- 集成 API Key 安全展示
- 优化 Dialog 编辑体验(自动聚焦)
- 响应式设计(移动端/桌面端/大屏)

技术改进:
- 数据模型向后兼容(所有新字段 nullable)
- 性能优化(useMemo 减少重渲染)
- 类型安全(TypeScript 完整覆盖)
- 代码质量(格式化 + lint 通过)

文件变更统计:
- 10 个文件修改
- 新增 889 行,删除 1098 行
- 新增 2 个组件文件,1 个迁移文件
- 旧组件重命名为 .legacy.tsx

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fix Disable pino-pretty in Turbopack development environment
@claude claude bot added the enhancement New feature or request label Nov 6, 2025
@@ -0,0 +1,2 @@
ALTER TABLE "providers" ADD COLUMN "website_url" text;--> statement-breakpoint
ALTER TABLE "providers" ADD COLUMN "favicon_url" text; No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缺少文件末尾换行符

根据 Git 和 POSIX 规范,文本文件应该以换行符结尾。

Suggested change
ALTER TABLE "providers" ADD COLUMN "favicon_url" text;
ALTER TABLE "providers" ADD COLUMN "favicon_url" text;

(在行末添加一个空行)

<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 flex-wrap">
{/* Favicon */}
{provider.faviconUrl && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔐 安全风险:XSS 和隐私泄露

直接使用用户输入的 URL 作为 <img src> 存在多个安全风险:

  1. XSS 攻击:恶意用户可以输入 javascript:data: URI
  2. 隐私泄露:外部图片加载会泄露用户 IP 地址
  3. SSRF 风险:可能探测内网地址

建议修复方案

// 1. 在 schema 中添加协议验证(推荐)
// src/lib/validation/schemas.ts
faviconUrl: z
  .string()
  .url()
  .refine((url) => url.startsWith('https://'), {
    message: 'Favicon URL 必须使用 HTTPS 协议',
  })
  .optional(),

// 2. 或者添加运行时检查
{provider.faviconUrl?.startsWith('https://') && (
  <img
    src={provider.faviconUrl}
   
    className="h-4 w-4 flex-shrink-0"
    referrerPolicy="no-referrer" // 防止泄露 Referer
    loading="lazy" // 性能优化
    onError={(e) => {
      (e.target as HTMLImageElement).style.display = "none";
    }}
  />
)}

更安全的方案是通过后端代理加载图片,避免直接暴露用户 IP。

src={provider.faviconUrl}
alt=""
className="h-4 w-4 flex-shrink-0"
onError={(e) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码风格建议:避免直接操作 DOM

直接修改 style.display 不够优雅,建议使用 React 状态管理:

const [faviconError, setFaviconError] = useState(false);

// ...

{provider.faviconUrl && !faviconError && (
  <img
    src={provider.faviconUrl}
   
    className="h-4 w-4 flex-shrink-0"
    onError={() => setFaviconError(true)}
  />
)}

或者使用 fallback 图标:

{provider.faviconUrl ? (
  <img
    src={provider.faviconUrl}
   
    className="h-4 w-4 flex-shrink-0"
    onError={(e) => {
      // 替换为默认图标
      (e.target as HTMLImageElement).src = '/default-provider-icon.svg';
    }}
  />
) : (
  <Globe className="h-4 w-4 text-muted-foreground" />
)}

Repository owner deleted a comment from claude bot Nov 6, 2025
@ding113 ding113 linked an issue Nov 6, 2025 that may be closed by this pull request
ding113 and others added 2 commits November 7, 2025 15:25
- Introduced a new error category for non-retryable client errors, specifically for issues like prompt length, content filtering, PDF limits, and formatting errors.
- Implemented a whitelist pattern matching system to efficiently identify these errors without recompiling regex on each call.
- Updated the error categorization logic to prioritize client input errors, ensuring they are logged and returned immediately without triggering retries or affecting the circuit breaker.
- Enhanced the ProxyForwarder to handle these errors distinctly, improving the robustness of the proxy's error management.

This refactor aims to streamline error handling and improve user feedback for common client-side issues.
@claude
Copy link
Contributor

claude bot commented Nov 7, 2025

代码审查总结

这个 PR 将 dev 分支的最新功能合并到 main,包含了供应商管理页面的重构和多项改进。代码质量整体良好,以下是审查意见:

✅ 优秀的地方

  1. 完善的错误分类系统 (src/app/v1/_lib/proxy/errors.ts)

    • 新增 4 种错误分类:PROVIDER_ERROR、SYSTEM_ERROR、CLIENT_ABORT、NON_RETRYABLE_CLIENT_ERROR
    • 白名单模式的错误检测,避免误判
    • 智能错误消息提取,支持 Claude/OpenAI 多种格式
    • 详细的 JSDoc 注释,可维护性强
  2. 新增供应商官网支持 (src/types/provider.ts 和 schema)

    • 新增 website_url 和 favicon_url 字段
    • 前端显示 favicon 和官网链接,提升用户体验
    • 错误处理得当(favicon 加载失败自动隐藏)
  3. 重构的供应商列表组件 (src/app/settings/providers/_components/provider-rich-list-item.tsx)

    • 代码模块化良好,逻辑清晰
    • 支持启用/禁用切换、编辑、克隆、删除等操作
    • 错误处理完善,用户反馈友好(toast 提示)

⚠️ 潜在改进点

  1. 数据库迁移文件缺少回滚逻辑 (drizzle/0016_curious_paladin.sql)

    • 建议添加回滚 SQL 注释,方便出问题时快速恢复
  2. 错误检测正则性能优化 (src/app/v1/_lib/proxy/errors.ts:177-182)

    • 已使用预编译正则数组,性能良好 ✅
    • 建议添加单元测试覆盖所有错误模式
  3. 供应商列表组件的响应式布局 (src/app/settings/providers/_components/provider-rich-list-item.tsx:310-330)

    • 使用了 hidden md:grid 和 hidden lg:block 进行断点控制 ✅
    • 小屏设备可能信息密度过高,建议测试移动端体验
  4. 删除文档文件 (docs/api-documentation.md 和 docs/api-implementation-summary.md)

    • 已删除 864 行旧文档
    • 确认这些内容已迁移到其他地方(如 CLAUDE.md 或 README.md)

📋 建议后续工作

  1. 单元测试覆盖

    • 为新的错误分类逻辑添加测试(isNonRetryableClientError、isClientAbortError)
    • 测试供应商官网字段的边界情况(空值、无效 URL)
  2. 端到端测试

    • 测试供应商管理页面的所有操作流程
    • 测试错误场景下的熔断器行为
  3. 文档更新

    • 确认删除的文档内容已在其他地方补充
    • 更新 CHANGELOG 记录本次重构的关键变更

总结

这是一个高质量的 PR,代码设计合理,错误处理完善,用户体验改进明显。建议合并到 main 分支,并在后续迭代中补充单元测试和端到端测试。


审查人: Claude Code
审查时间: 2025-11-07

claude and others added 7 commits November 7, 2025 07:32
- 排行榜 API 添加 session 验证和权限检查(返回 401/403)
- 排行榜页面添加服务端权限验证和友好提示 UI
- 概览面板根据权限过滤全站指标
- 保持向后兼容:管理员始终有完整权限
- 遵循 statistics.ts 权限模式

Fixes #85

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
修复两个关键安全问题(GitHub Issue #87):

1. 管理员无法清除 API Key 过期日期
   - 根因:Zod schema 将空字符串转为 undefined,Repository 层视为"不更新"
   - 修复:在 Action 层添加 undefined → null 转换逻辑
   - 类型:更新 CreateKeyData/UpdateKeyData 支持 null 值(永不过期)

2. 普通用户可修改自己的账户限额(权限提升漏洞)
   - 根因:editUser 仅检查管理员角色,未限制用户修改敏感字段
   - 修复:实现三层权限控制(管理员全部/用户非敏感/其他拒绝)
   - 敏感字段:rpm, dailyQuota, providerGroup(仅管理员可改)
   - 普通字段:name, description(用户可改自己的)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
添加 filterPrivateParameters() 函数,在序列化前递归过滤所有下划线前缀的私有参数(如 _canRetryWithOfficialInstructions),防止上游供应商返回 "Unsupported parameter" 错误。

- 支持嵌套对象和数组的递归过滤
- 使用 Pino debug 日志记录被过滤的参数
- 无破坏性变更,保持向后兼容

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Updated the leaderboard API to support a new `scope` parameter, allowing retrieval of user or provider rankings.
- Implemented validation for the `scope` parameter, ensuring only valid values are accepted.
- Enhanced the leaderboard view component to dynamically switch between user and provider rankings based on the selected scope.
- Updated the leaderboard table to support dynamic column definitions for user and provider data.
- Improved error handling and user feedback for unauthorized access to provider rankings.

This change aims to provide a more flexible and informative leaderboard experience for users and administrators.
@ding113 ding113 linked an issue Nov 7, 2025 that may be closed by this pull request
@claude
Copy link
Contributor

claude bot commented Nov 7, 2025

🎉 代码审查完成

📊 PR 概览

变更统计:

  • 新增: 3,643 行
  • 删除: 1,542 行
  • 涉及文件: 30 个

PR 状态: ✅ 可以合并(基础分支: main ← dev)


✨ 主要改进

1. 供应商管理页面重构 ⭐️⭐️⭐️⭐️⭐️

新增组件 provider-rich-list-item.tsx (490 行):

  • ✅ 完全响应式设计,支持桌面/移动端
  • ✅ 内联操作(编辑、克隆、删除、查看密钥)
  • ✅ 实时状态切换(启用/禁用)
  • ✅ 熔断器状态可视化和手动重置
  • ✅ 集成 favicon 和官网链接
  • ✅ 使用 Dialog 进行表单编辑(避免页面跳转)

2. 供应商表单增强 ⭐️⭐️⭐️⭐️⭐️

功能改进 provider-form.tsx (1,100 行):

  • ✅ 新增官网地址配置 (website_url)
  • ✅ 优化折叠区域体验(记住用户偏好到 localStorage)
  • ✅ 自动聚焦名称输入框(提升表单填写效率)
  • ✅ 全部展开/折叠按钮
  • ✅ 实时配置预览(显示已配置项数量)

3. 错误处理机制优化 ⭐️⭐️⭐️⭐️⭐️

新增错误分类 proxy/errors.ts:

  • PROVIDER_ERROR: 供应商 4xx/5xx → 计入熔断器
  • SYSTEM_ERROR: 网络异常 → 不计入熔断器,重试1次
  • CLIENT_ABORT: 客户端中断 → 不计入熔断器,不重试
  • NON_RETRYABLE_CLIENT_ERROR: 输入错误 → 不计入熔断器,不重试

关键改进:

  • ✅ 白名单模式检测不可重试错误(Prompt 超限、内容过滤、PDF 限制、Thinking 格式)
  • ✅ 精确检测客户端中断(避免误判业务错误)
  • ✅ 智能错误消息截断(JSON 完整保存,文本限制 500 字符)
  • ✅ 预编译正则表达式(性能优化)

4. 数据库 Schema 扩展 ⭐️⭐️⭐️⭐️

新增字段:

  • ALTER TABLE providers ADD COLUMN website_url text
  • ALTER TABLE providers ADD COLUMN favicon_url text

5. 排行榜功能增强 ⭐️⭐️⭐️⭐️

新增 Scope 过滤:

  • 支持按用户/模型/供应商查看排行榜
  • 缓存键使用 TZ-aware 日期(修复时区问题)
  • 分页支持(性能优化)

🔍 代码审查发现

⚠️ 中等优先级问题

  1. 文档删除 (docs/):

    • 删除了 api-documentation.md 和 api-implementation-summary.md
    • 💡 建议:如果这些文档仍有参考价值,建议保留并更新链接
  2. Favicon 错误处理 (provider-rich-list-item.tsx:250-254):

    • 当前使用 style.display = 'none' 隐藏加载失败的图标
    • 💡 建议:使用 CSS class 控制可见性,或显示默认占位符
  3. 表单重置逻辑 (provider-form.tsx:315-337):

    • 成功添加后重置表单,但编辑模式不重置
    • ✅ 这是正确的设计,但建议添加注释说明

✅ 优秀实践

  1. 错误边界: 使用 FormErrorBoundary 包裹表单组件

  2. 用户体验细节:

    • 复制密钥后 3 秒自动清除提示
    • 操作按钮 disabled 状态(防止重复提交)
    • 加载状态文案("添加中..." / "更新中...")
  3. 性能优化:

    • 预编译正则表达式(避免运行时重复编译)
    • localStorage 缓存折叠偏好
    • 响应式设计(隐藏大屏专属内容)
  4. 代码注释: errors.ts 的注释非常详细,包含设计原则、示例


🎯 总体评价

评分: ⭐️⭐️⭐️⭐️⭐️ (5/5)

理由:

  • ✅ 用户体验大幅提升(一站式管理界面)
  • ✅ 代码质量高(类型安全、错误处理完善)
  • ✅ 架构设计合理(职责分离、可复用)
  • ✅ 性能优化到位(缓存、预编译正则)
  • ✅ 数据库迁移安全(使用 ALTER TABLE ADD COLUMN)

建议合并条件:

  • ✅ 所有测试通过
  • ✅ 本地验证新功能(favicon 加载、表单提交)
  • ✅ 数据库迁移测试(开发环境 + 预生产环境)

📝 后续建议

  1. 文档更新:

    • 更新 CLAUDE.md 中的供应商管理说明(新增 favicon 和官网字段)
    • 添加错误分类机制的文档
  2. 监控增强:

    • 添加错误分类的 metrics(统计各类错误占比)
    • Dashboard 显示熔断器误触发率
  3. 测试覆盖:

    • 为 categorizeError 添加单元测试(覆盖所有错误类型)
    • 为 isNonRetryableClientError 添加边界用例测试

审查者: Claude Code
审查时间: 2025-11-07
PR 类型: 功能增强 (Enhancement)
风险等级: 🟢 低风险(向后兼容,数据库迁移安全)

@ding113 ding113 linked an issue Nov 7, 2025 that may be closed by this pull request
claude and others added 3 commits November 7, 2025 12:50
对于非 admin token 用户,在首页隐藏概览面板,包括:
- 当前并发、今日请求、今日消耗、平均响应等统计指标
- 活跃 Session 列表
- 点击查看详情按钮

admin 用户保持原有功能不变。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
修复活跃 Session 组件高度对齐问题,消除底部留白:
- 使用 flex 布局让容器填充整个可用高度
- 标题区域设置为 flex-shrink-0 防止被压缩
- 内容区域使用 flex-1 占据所有剩余空间
- 移除固定高度限制,改为自适应父容器高度

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@@ -0,0 +1,2 @@
ALTER TABLE "providers" ADD COLUMN "website_url" text;--> statement-breakpoint
ALTER TABLE "providers" ADD COLUMN "favicon_url" text; No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

数据库迁移设计合理

迁移文件正确使用了 nullable 字段,向后兼容现有数据。建议在生产环境执行前:

  1. 确认数据库备份已完成
  2. 在测试环境先验证迁移脚本
  3. 监控迁移执行时间(尽管这是轻量级迁移)

可选优化: 如果 website_urlfavicon_url 将来需要搜索功能,可以考虑添加 GIN 索引:

CREATE INDEX idx_providers_website_url ON providers USING GIN (website_url gin_trgm_ops);

(需要启用 pg_trgm 扩展)

<div className="flex items-center gap-2 flex-wrap">
{/* Favicon */}
{provider.faviconUrl && (
<img
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Favicon 图片加载的安全建议

当前实现使用 <img> 标签直接加载外部 favicon,存在潜在的安全风险:

  1. XSS 风险: 虽然图片本身不会直接执行 JavaScript,但恶意 SVG 图片可能包含嵌入式脚本
  2. 隐私泄露: 浏览器加载图片时会发送 Referer 头,可能泄露用户正在访问的页面信息

建议改进:

{provider.faviconUrl && (
  <img
    src={provider.faviconUrl}
   
    className="h-4 w-4 flex-shrink-0"
    referrerPolicy="no-referrer"  // 防止隐私泄露
    crossOrigin="anonymous"        // CORS 安全
    loading="lazy"                 // 性能优化
    onError={(e) => {
      (e.target as HTMLImageElement).style.display = "none";
    }}
  />
)}

可选: 如果安全要求更高,可以考虑:

  • 使用 Content Security Policy (CSP) 限制图片来源
  • 在服务端代理 favicon 请求(避免直接加载第三方资源)

};

// 处理查看密钥
const handleShowKey = async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

并发请求优化建议

当前实现在 Dialog 打开时立即发起 API 请求,但如果用户快速点击多个供应商的密钥按钮,可能导致:

  1. 多个并发请求
  2. 竞态条件(后发请求先返回)

建议改进:

const [keyLoading, setKeyLoading] = useState(false);

const handleShowKey = async () => {
  if (keyLoading) return; // 防止重复请求
  
  setShowKeyDialog(true);
  setKeyLoading(true);
  
  try {
    const result = await getUnmaskedProviderKey(provider.id);
    if (result.ok) {
      setUnmaskedKey(result.data.key);
    } else {
      toast.error("获取密钥失败", {
        description: result.error || "未知错误",
      });
      setShowKeyDialog(false);
    }
  } finally {
    setKeyLoading(false);
  }
};

额外优化: 可以考虑使用 SWR 或 React Query 缓存密钥数据(设置较短的过期时间,如 30 秒),避免重复请求

return { ok: false, error: "供应商不存在" };
}

// 记录查看行为(不记录密钥内容)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API Key 安全机制设计优秀

代码在安全性方面考虑非常周全:

  1. 权限验证: 严格检查 admin 角色
  2. 审计日志: 记录管理员查看密钥的行为(不记录密钥内容)
  3. Server Action: 使用 "use server" 确保逻辑在服务端执行
  4. 错误处理: 完整的错误处理和日志记录

建议增强:

// 可以考虑增加频率限制,防止密钥被过度访问
logger.info("Admin viewed provider key", {
  userId: session.user.id,
  providerId: id,
  providerName: provider.name,
  userEmail: session.user.email,  // 增加邮箱追溯
  ip: headers().get("x-forwarded-for") || headers().get("x-real-ip"), // IP 追踪
  timestamp: new Date().toISOString(),
});

可选: 可以在数据库中添加 provider_key_access_logs 表,永久记录所有密钥访问行为,便于安全审计

@@ -557,6 +507,138 @@ function extractUsageMetrics(value: unknown): UsageMetrics | null {
return hasAny ? result : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Usage Metrics 解析重构 - 架构改进优秀

这个重构显著提升了代码质量:

优点:

  1. 单一职责: 将复杂的解析逻辑提取到 parseUsageFromResponseText() 函数
  2. 可读性: applyUsageValue() 闭包设计简洁,避免重复代码
  3. 容错性: 完整的 try-catch 保护,SSE fallback 机制
  4. 扩展性: 易于添加新的 usage 格式支持

建议:

// 可以考虑添加单元测试,覆盖各种边界情况
describe('parseUsageFromResponseText', () => {
  it('should parse Claude format', () => { ... });
  it('should parse Codex format', () => { ... });
  it('should parse OpenAI format', () => { ... });
  it('should handle SSE events', () => { ... });
  it('should return null for invalid input', () => { ... });
});

性能优化: 如果 responseText 非常大(>1MB),可以考虑添加早期返回:

if (responseText.length > 1_000_000 && !responseText.includes('usage')) {
  return { usageRecord: null, usageMetrics: null };
}

@claude
Copy link
Contributor

claude bot commented Nov 7, 2025

🎉 代码审查总结

这是一个高质量的 PR,包含了重要的 UI/UX 重构和关键 bug 修复。代码整体设计合理,实现专业。

✅ 主要亮点

  1. 架构设计清晰

    • 数据库迁移向后兼容,字段设计合理
    • 组件职责分明,遵循单一职责原则
    • Response Handler 重构显著提升代码可维护性
  2. 代码质量优秀

    • ProviderRichListItem 组件实现非常专业,错误处理完整
    • API Key 安全展示机制设计周全(权限验证 + 审计日志)
    • 使用 useTransition 处理异步操作,避免竞态条件
  3. 关键 Bug 修复

    • 修复供应商统计查询 SQL 错误(字符串比较 → Date 对象)
    • 优化 Codex usage input tokens 计算逻辑
    • 修复 Pino 日志在 Turbopack 环境下的兼容性问题

💡 改进建议

我已经在代码中添加了 4 条行内评论,包括:

  1. 安全增强: Favicon 图片加载建议添加 referrerPolicycrossOrigin 属性
  2. 性能优化: API Key 获取建议添加防重复请求逻辑
  3. 审计增强: 可考虑增加 IP 追踪和永久审计日志表
  4. 测试覆盖: 建议为 parseUsageFromResponseText 添加单元测试

这些建议都是可选的增强,不影响当前代码的功能性和稳定性。

📊 代码统计

  • 变更范围: 33 个文件,+3663/-1549 行
  • 核心功能: 供应商管理页面重构 + Response Handler 优化
  • 向后兼容: ✅ 所有新字段 nullable,数据层完全兼容

✅ 合并建议

推荐合并。此 PR 已通过代码质量检查,建议在以下条件下合并:

  1. ✅ CI 检查全部通过
  2. ✅ 在测试环境验证 UI/UX 改进
  3. ✅ 确认数据库迁移在测试环境执行成功
  4. ⚠️ 建议在生产环境合并前备份数据库(尽管迁移是轻量级的)

感谢你的出色工作! 🚀

@claude claude bot added the bug Something isn't working label Nov 7, 2025
@ding113 ding113 merged commit 9efd83e into main Nov 7, 2025
15 checks passed
ding113 pushed a commit that referenced this pull request Nov 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] user date issue and permissions 页面设计疑问 ui显示问题

3 participants