Skip to content

feat: add open library page#80

Open
jordansilly77-stack wants to merge 2 commits into
Open-Source-Bazaar:mainfrom
jordansilly77-stack:feat/open-library-page
Open

feat: add open library page#80
jordansilly77-stack wants to merge 2 commits into
Open-Source-Bazaar:mainfrom
jordansilly77-stack:feat/open-library-page

Conversation

@jordansilly77-stack

@jordansilly77-stack jordansilly77-stack commented Jun 21, 2026

Copy link
Copy Markdown

PR-80 PR-80 PR-80 Powered by Pull Request Badge

Summary

  • add a new /library Open Library page with book browsing, search, category/status filters, catalog table, detail panel, and borrowing guide
  • add the Open Library navigation entry under Open Source Projects
  • add Simplified Chinese, Traditional Chinese, and English text for the new module

Checks

  • pnpm exec tsc --noEmit
  • pnpm exec eslint components/Navigator/MainNavigator.tsx pages/library/index.tsx translation/zh-CN.ts translation/zh-TW.ts translation/en-US.ts
  • git diff --check
  • previewed http://localhost:3000/library locally

Note: pnpm build currently stops while collecting existing Lark-backed pages because local Lark app id/secret env vars are unavailable.

Closes #15

Summary by CodeRabbit

发布说明

  • 新功能
    • 在主导航菜单中新增“Library”菜单项,入口指向 /library
    • 新增 Library 页面:
      • Hero 区展示图书统计与快速跳转
      • 支持按关键词、分类、状态筛选并以卡片列表浏览
      • 支持表格查看完整图书目录
      • 详情面板展示图书信息与借阅操作(文案随状态切换)
      • 步骤引导界面(左侧步骤 + 右侧内容联动)
  • 样式
    • 新增 Library 页面样式模块,完善布局、卡片交互与响应式表格/面板展示

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9234e041-9ac5-48d6-8674-33247f01329e

📥 Commits

Reviewing files that changed from the base of the PR and between a6ae3e2 and 686b1f4.

📒 Files selected for processing (2)
  • pages/library/index.module.less
  • pages/library/index.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • pages/library/index.module.less
  • pages/library/index.tsx

📝 Walkthrough

Walkthrough

新增 Library 页面(pages/library/index.tsx)及配套 Less 样式模块(pages/library/index.module.less),实现图书浏览、目录、借阅指南与详情展示功能;同时在 MainNavigator.tsx 的子菜单中注册 /library 导航入口。

Changes

图书馆页面新增

Layer / File(s) Summary
数据结构与类型定义
pages/library/index.tsx
定义 BookStatus 枚举、CategoryFilter 分类过滤枚举、LibraryBook 接口,内置 books 数据数组与 guideKeys i18n 键对映射。
组件状态与派生数据
pages/library/index.tsx
维护 keyword/category/status/selectedCode 四个响应式状态,计算 filteredBooksactiveBookstatusText/statusClass 映射函数。
Hero 与 Browse 区实现
pages/library/index.tsx, pages/library/index.module.less
Hero 区展示图书统计与跳转按钮;Browse 区提供关键字与下拉筛选,渲染卡片列表(含"查看详情"按钮),无结果时显示空状态;样式覆盖容器布局、hero 渐变背景、卡片悬停/激活态、状态徽标。
Catalog 表格实现
pages/library/index.tsx, pages/library/index.module.less
渲染全量图书表格(编码、书名、状态、位置、到期日期),样式含响应式重排(移动端隐藏表头、td::before 伪标签)。
Guide + Detail 区实现
pages/library/index.tsx, pages/library/index.module.less
左侧步骤引导列表(编号徽标通过 CSS 计数器自动生成),右侧 activeBook 详情面板与借阅按钮(根据状态禁用);样式含竖线、圆形编号、面板外观。
组件导出与导航注册
pages/library/index.tsx, components/Navigator/MainNavigator.tsx
默认导出 observer 包装的 LibraryPage 组件,在导航菜单中追加 /library 条目。

Sequence Diagram(s)

sequenceDiagram
  participant User as 用户
  participant Filter as 筛选输入
  participant State as 状态管理
  participant Render as 页面渲染
  User->>Filter: 输入关键字/分类/状态
  Filter->>State: 更新 keyword/category/status
  State->>State: 计算 filteredBooks 与 activeBook
  State->>Render: 触发 observer 重新渲染
  Render->>User: 更新卡片列表与详情面板
  User->>Render: 点击卡片或选择下拉项
  Render->>State: 更新 selectedCode
  State->>Render: activeBook 转换,重新渲染详情
  Render->>User: 展示新的 activeBook 详情与按钮文案
Loading

预估代码审查难度

🎯 3 (Moderate) | ⏱️ ~28 minutes

Poem

📚 新增 Library 页面引航,
Hero 统计尽展望,
Browse 搜寻分类彰,
Catalog 目录逐行陈,
Guide 步骤借阅顺畅,
Detail 详情细说详,
Less 样式响应端庄,
开源图书馆,门第就开放!🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add open library page' accurately and concisely describes the main change—adding a new library page feature with comprehensive functionality.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #15: new Library module with book browsing [#15], catalog viewing with status marking [#15], detail display [#15], and borrowing guide [#15].
Out of Scope Changes check ✅ Passed All changes are within scope—MainNavigator addition to expose the library page [#15], comprehensive styles for the library UI [#15], and the complete LibraryPage component implementation [#15].
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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.

Inline comments:
In `@pages/library/index.tsx`:
- Line 13: The category field uses hardcoded English text that bypasses i18n,
violating the requirement that all user-facing text must use the t() function
for internationalization. Change the category property type from string to
I18nKey, update the hardcoded English category values at the data definition
points to appropriate i18n keys, and modify all rendering locations where
category is displayed to wrap the value with the t() translation function. This
applies to the category property declaration, the hardcoded values in the data
objects, and the rendering logic in the template where categoryKey is output
directly.
- Line 116: The component violates list semantics and styling conventions in two
places. First, the ul element with className={styles.heroMeta} at line 116 is
missing the list-unstyled class to properly style the first-level list. Add the
list-unstyled class to this ul element's className. Second, the steps section
around lines 249-255 is incorrectly implemented using div elements with manual
numbering instead of semantic HTML. Replace this div-based structure with proper
ordered list elements (ol wrapping li items) to represent the countable steps
correctly, removing any manual numbering from the content.
- Around line 104-106: Replace all native HTML tags in the
pages/library/index.tsx file with React Bootstrap components to comply with the
coding guidelines. Starting with the diff shown (the h1, p, and flex div
elements around lines 104-106), replace heading tags (h1, h2, h3) with React
Bootstrap typography utilities or Card.Header, replace p tags with Card.Text or
typography utilities, replace container divs with Stack or Container components,
replace ul/li lists with ListGroup/ListGroup.Item, and replace
section/article/aside tags with Card or appropriate layout components. Apply
these replacements consistently across all 40+ native HTML tag instances
throughout the file, including the sections around lines 116-129 and 191-195 and
any other native elements found.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ccbfe341-040a-4109-8b7e-ea37ce02e5c5

📥 Commits

Reviewing files that changed from the base of the PR and between 58126ca and 2fe18ef.

⛔ Files ignored due to path filters (3)
  • translation/en-US.ts is excluded by none and included by none
  • translation/zh-CN.ts is excluded by none and included by none
  • translation/zh-TW.ts is excluded by none and included by none
📒 Files selected for processing (3)
  • components/Navigator/MainNavigator.tsx
  • pages/library/index.module.less
  • pages/library/index.tsx

Comment thread pages/library/index.tsx Outdated
Comment thread pages/library/index.tsx
Comment on lines +104 to +106
<h1 className="display-5 fw-bold mb-3">{t('library_hero_title')}</h1>
<p className="fs-5 text-muted mb-4">{t('library_hero_intro')}</p>
<div className="d-flex flex-wrap gap-3">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 只读核查:快速定位 library 页面中的常见原生 UI 标签,评估是否需要批量替换为 RB 组件
rg -nP '<(h1|h2|h3|p|ul|li|strong|small|article|aside|section|header)\b' pages/library/index.tsx

Repository: Open-Source-Bazaar/Open-Source-Bazaar.github.io

Length of output: 2800


🏁 Script executed:

# 验证是否有更多原生标签需要关注
rg -c '<(h1|h2|h3|p|ul|li|strong|small|article|aside|section|header|nav)\b' pages/library/index.tsx | tail -5

Repository: Open-Source-Bazaar/Open-Source-Bazaar.github.io

Length of output: 94


统一使用 React Bootstrap 组件替代原生 HTML 标签。

编码指南明确规定该文件路径(pages/**/*.tsx)必须"ALWAYS use React Bootstrap components instead of custom HTML elements"。当前代码中存在 40 多处原生标签(<h1><h2><h3><p><ul><li><strong><small><header><section><article><aside> 等),分布在多个区块(第 104–106 行、116–129 行、191–195 行等),需要统一重构。

建议迁移方案:

  • 标题元素 → React Bootstrap 的 <Container> + 排版 utility,或 <Card.Header>
  • 列表 → ListGroup / ListGroup.Item
  • 分段容器 → Card / Stack 等组件
  • 文本元素 → Card.Text 或组件内原生标签(在 RB 组件上下文中)

这是强制性重构,需要在本页落地,以避免风格漂移。

🤖 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/index.tsx` around lines 104 - 106, Replace all native HTML tags
in the pages/library/index.tsx file with React Bootstrap components to comply
with the coding guidelines. Starting with the diff shown (the h1, p, and flex
div elements around lines 104-106), replace heading tags (h1, h2, h3) with React
Bootstrap typography utilities or Card.Header, replace p tags with Card.Text or
typography utilities, replace container divs with Stack or Container components,
replace ul/li lists with ListGroup/ListGroup.Item, and replace
section/article/aside tags with Card or appropriate layout components. Apply
these replacements consistently across all 40+ native HTML tag instances
throughout the file, including the sections around lines 116-129 and 191-195 and
any other native elements found.

Source: Coding guidelines

Comment thread pages/library/index.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pages/library/index.module.less (2)

118-124: 💤 Low value

可选优化:考虑使用更灵活的标签宽度。

第 119 行将标签宽度固定为 flex: 0 0 5rem。虽然对于当前的中英文标签应该足够,但考虑到国际化场景中某些语言的标签可能更长,建议考虑使用 min-width 替代固定宽度,或增加到 6rem:

&::before {
  flex: 0 0 auto;
  min-width: 5rem;
  // 或者
  // flex: 0 0 6rem;
  content: attr(data-label);
  color: `#6c757d`;
  font-weight: 600;
  text-align: left;
}

这样可以在保持布局整齐的同时,为更长的标签文本提供更好的容错性。

🤖 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/index.module.less` around lines 118 - 124, The `&::before`
pseudo-element has a fixed flex width of 5rem which may not accommodate longer
labels in internationalization scenarios. Replace the fixed flex width
constraint with a more flexible approach by either changing to `flex: 0 0 auto`
and adding `min-width: 5rem`, or increasing the flex width to 6rem. This allows
longer label text to display properly while maintaining layout consistency.

70-78: ⚡ Quick win

考虑移除 !important 声明。

这两个状态类都使用了 !important 来覆盖样式。虽然在与 Bootstrap Badge 组件配合时可能需要提高优先级,但使用 !important 通常是代码异味,会降低样式的可维护性。

建议尝试通过 CSS 模块的 :global 组合或更具体的选择器来达到相同效果,例如:

.statusAvailable {
  background: rgba(25, 135, 84, 0.1);
  color: `#198754`;
  border-color: transparent;
}

如果 Bootstrap 的优先级确实需要覆盖,可以在组件层面使用 className 组合或 style 属性作为替代方案。

🤖 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/index.module.less` around lines 70 - 78, The statusAvailable
and statusBorrowed classes in the LESS file currently use !important
declarations to override Bootstrap Badge styles, which reduces maintainability.
Remove the !important flags from both the background and color properties in
these two classes. If the styles don't apply correctly without !important,
instead handle the style overrides at the component level by using className
combinations to increase CSS specificity, or apply inline styles directly to the
component elements that use these status classes, rather than relying on
!important in the stylesheet.
🤖 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/index.module.less`:
- Around line 118-124: The `&::before` pseudo-element has a fixed flex width of
5rem which may not accommodate longer labels in internationalization scenarios.
Replace the fixed flex width constraint with a more flexible approach by either
changing to `flex: 0 0 auto` and adding `min-width: 5rem`, or increasing the
flex width to 6rem. This allows longer label text to display properly while
maintaining layout consistency.
- Around line 70-78: The statusAvailable and statusBorrowed classes in the LESS
file currently use !important declarations to override Bootstrap Badge styles,
which reduces maintainability. Remove the !important flags from both the
background and color properties in these two classes. If the styles don't apply
correctly without !important, instead handle the style overrides at the
component level by using className combinations to increase CSS specificity, or
apply inline styles directly to the component elements that use these status
classes, rather than relying on !important in the stylesheet.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9a6d120d-9936-4f54-8da5-42664722bf4d

📥 Commits

Reviewing files that changed from the base of the PR and between 2fe18ef and a6ae3e2.

⛔ Files ignored due to path filters (3)
  • translation/en-US.ts is excluded by none and included by none
  • translation/zh-CN.ts is excluded by none and included by none
  • translation/zh-TW.ts is excluded by none and included by none
📒 Files selected for processing (3)
  • components/Navigator/MainNavigator.tsx
  • pages/library/index.module.less
  • pages/library/index.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/Navigator/MainNavigator.tsx
  • pages/library/index.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

开发【开源图书馆】前端页面

1 participant