Conversation
修复了请求详情页面中 duration 显示为数万分钟的问题。 后端 time.Duration 以纳秒为单位存储,但前端 formatDuration 函数错误地将其当作毫秒处理,导致显示值放大了 100 万倍。 更改: - 在 RequestHeader.tsx 和 RequestSidebar.tsx 中添加纳秒到毫秒的转换 - 将 formatDuration 参数从 ms 重命名为 ns 以明确单位 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
将重复的 formatDuration 函数提取到 lib/utils.ts 中,减少代码重复。 更改: - 在 lib/utils.ts 中添加 formatDuration 公共函数 - 更新 RequestHeader.tsx 和 RequestSidebar.tsx 使用公共函数 - 优化 index.tsx 中的 formatDuration,添加注释说明 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary
修复了请求详情页面中 duration 显示为数万分钟的错误问题,并将重复的 formatDuration 函数提取为公共工具函数。
问题修复
问题原因:
time.Duration类型,以纳秒为单位存储formatDuration函数错误地将输入值当作毫秒处理修复方案:
const ms = ns / 1_000_000ms重命名为ns以明确单位代码重构
重构内容:
formatDuration函数提取到lib/utils.ts作为公共工具函数RequestHeader.tsx和RequestSidebar.tsx中的重复代码index.tsx中的实现,保留特殊的 pending 状态处理逻辑改进效果:
修改文件
web/src/lib/utils.ts- 添加公共 formatDuration 函数web/src/pages/requests/detail/RequestHeader.tsx- 使用公共函数web/src/pages/requests/detail/RequestSidebar.tsx- 使用公共函数web/src/pages/requests/index.tsx- 优化并添加注释Test plan
🤖 Generated with Claude Code