Add Open Library page#87
Conversation
|
Warning Review limit reached
Next review available in: 39 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough新增开源图书馆页面,展示图书统计、目录、借阅状态与借阅指南,并在主导航的开源项目菜单中增加 Changes开源图书馆
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pages/library.tsx (2)
145-145: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value统计卡片重复调用
filter可提取为变量两处分别对
libraryBooks调用filter计算available和borrowed数量。虽然当前 6 条数据影响可忽略,但提取为变量可提升可读性,也便于未来数据量增长时扩展。♻️ 建议重构
const LibraryPage: FC = observer(() => { const { t } = useContext(I18nContext); + const availableCount = libraryBooks.filter(({ status }) => status === 'available').length; + const borrowedCount = libraryBooks.length - availableCount; return (然后在统计卡片中:
- {libraryBooks.filter(({ status }) => status === 'available').length} + {availableCount}- {libraryBooks.filter(({ status }) => status === 'borrowed').length} + {borrowedCount}Also applies to: 156-156
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pages/library.tsx` at line 145, 在页面组件中为可借阅和已借阅图书数量提取复用的变量,避免统计卡片分别对 libraryBooks 重复调用 filter;使用这些变量替换对应的 available 和 borrowed 数量表达式,保持现有统计结果不变。
232-234: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win站内跳转改为
next/link
这里是站内路由,Button href="/bounty"会按普通<a>处理并触发整页刷新;建议改成next/link包裹Button,保留样式并走客户端导航。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pages/library.tsx` around lines 232 - 234, Update the library submit-books navigation around the Button component to use next/link for the internal “/bounty” route, wrapping Button with Link while preserving its existing styling and label so navigation occurs client-side without a full-page reload.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pages/library.tsx`:
- Line 145: 在页面组件中为可借阅和已借阅图书数量提取复用的变量,避免统计卡片分别对 libraryBooks 重复调用
filter;使用这些变量替换对应的 available 和 borrowed 数量表达式,保持现有统计结果不变。
- Around line 232-234: Update the library submit-books navigation around the
Button component to use next/link for the internal “/bounty” route, wrapping
Button with Link while preserving its existing styling and label so navigation
occurs client-side without a full-page reload.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6c1b367b-7152-4648-8581-1df6b286b66b
⛔ Files ignored due to path filters (3)
translation/en-US.tsis excluded by none and included by nonetranslation/zh-CN.tsis excluded by none and included by nonetranslation/zh-TW.tsis excluded by none and included by none
📒 Files selected for processing (2)
components/Navigator/MainNavigator.tsxpages/library.tsx
|
Addressed CodeRabbit's two nitpicks in the latest commit: extracted reusable available/borrowed counters and switched the internal /bounty navigation to next/link. Re-ran:\n\n- pnpm exec prettier --write pages/library.tsx\n- pnpm exec eslint pages/library.tsx\n- pnpm exec tsc --noEmit |
Summary
/libraryOpen Library landing page with catalog browsing, detail cards, availability badges, shelf codes, and borrowing information.Closes #15
Validation
pnpm exec tsc --noEmitpnpm exec eslint pages/library.tsxpnpm buildreaches production compilation, then stops while collecting page data because the local environment does not have Lark App Id/Secret for existing NGO/wiki pages.Reward
This PR is for the 270 TQT reward on #15. Please let me know what account or payout information is needed after review.
Summary by CodeRabbit