Skip to content

Add [Open Library] & Library Work Flow#20

Open
dethan3 wants to merge 16 commits into
Open-Source-Bazaar:mainfrom
dethan3:main
Open

Add [Open Library] & Library Work Flow#20
dethan3 wants to merge 16 commits into
Open-Source-Bazaar:mainfrom
dethan3:main

Conversation

@dethan3

@dethan3 dethan3 commented Feb 24, 2025

Copy link
Copy Markdown
Member

PR-20 PR-20 PR-20 Powered by Pull Request Badge

Checklist(清单):

  • Labels
  • Assignees
  • Reviewers
  1. Add [Open Library],
  2. Use the documentation to quickly start operating Open Library.

Closes #15

Summary by CodeRabbit

  • New Features
    • 新增 Open Library 专区:主页、图书目录页、图书详情页与“如何借阅”指南页。
    • 新增专区组件:精选图书、图书卡片、步骤/规则展示、页头与页脚,并提供“查看详情/查看全部/借阅申请”入口。
    • 新增图书数据模型与 Open Library 图书目录 API,为页面提供静态数据来源。
  • Bug Fixes
    • 图书详情改为按路由服务端加载;不存在会正确返回未找到状态。
  • Refactor
    • 调整站点框架:Open Library 与通用站点布局按路由分流渲染页脚与导航。

@TechQuery TechQuery added the feature New feature or request label Jul 8, 2025
@TechQuery TechQuery self-requested a review July 8, 2025 18:20

@TechQuery TechQuery left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. 很多问题在不同文件都有,不一一列举,但都要改
  2. 软件开发要一个一个模块来,代码量太大对开发者、reviewer、AI 都有巨大上下文负担,很容易跑偏、卡死
  3. 以后要在看板上多拆几个 issue,不要闷头搞很久后发一个差不多做完整个项目的巨大 PR……

Comment thread .husky/pre-commit Outdated
Comment thread components/Navigator/MainNavigator.tsx Outdated
Comment thread package.json Outdated
Comment thread translation/zh-CN.ts Outdated
Comment thread translation/zh-CN.ts Outdated
Comment thread pages/open-library/book/[id].tsx Outdated
Comment thread pages/open-library/book/[id].tsx Outdated
Comment thread pages/open-library/book/[id].tsx Outdated
Comment thread pages/open-library/book/[id].tsx Outdated
Comment thread pages/open-library/book/[id].tsx Outdated
@TechQuery TechQuery added the enhancement Some improvements label Jul 9, 2025
# Conflicts:
#	.husky/pre-commit
#	.husky/pre-push
#	package.json
#	pages/_app.tsx
#	translation/en-US.ts
#	translation/zh-CN.ts
#	translation/zh-TW.ts
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

新增 Open Library 的图书数据、首页、目录页、详情页与借阅说明页,并把这些页面接入专用导航和应用级路由分支;同时整理了部分现有组件的类型声明、JSX 与 Less 排版。

Changes

Open Library 功能新增

Layer / File(s) Summary
图书数据与接口
models/Book.ts, pages/api/open-library/books.ts
定义 BorrowHistoryBookReviewBook 类型,并导出 openLibraryBooks 静态数据与返回该数组的 API handler。
页面壳层与导航
components/open-library/Navbar.tsx, components/open-library/Footer.tsx, components/Navigator/MainNavigator.tsx, pages/_app.tsx
新增 Open Library 顶部导航、页脚和 _app.tsx 路由分支,并给主导航加入 Open Library 入口。
共享卡片与主视觉
components/open-library/BookCard.tsx, components/open-library/FeaturedBooks.tsx, components/open-library/HeroSection.tsx, components/open-library/HowItWorks.tsx, components/open-library/HowItWorks.module.less
新增图书卡片、精选图书、主视觉与步骤区组件,并配套步骤区样式模块。
首页组合
pages/open-library/index.tsx
首页按顺序拼装主视觉、关于我们、精选图书、如何使用和支持我们区块,并基于图书数据与本地化文案生成内容。
目录页
pages/open-library/books/index.tsx
目录页改为从静态图书数据渲染卡片网格,并传入状态标记与 catalog 变体。
书详情页
pages/open-library/book/[id].tsx
详情页通过服务端按路由参数读取图书,并渲染封面、基础信息、评论和借阅历史。
借阅说明页
pages/open-library/how-to-borrow.tsx
新增借阅说明页面,包含流程、规则、FAQ、快速链接和行动号召区,并对内联文本链接做了协议校验解析。

现有代码格式与类型整理

Layer / File(s) Summary
TypeScript / JSX 整理
components/Activity/Hackathon/Hero.tsx, components/Activity/Hackathon/Resources.tsx, components/Activity/Hackathon/Schedule.tsx, components/Layout/CardPage.tsx, components/License/helper.ts, components/Map/ChinaMap.tsx, components/Navigator/SearchBar.tsx, components/Organization/Card.tsx
多个接口声明与 JSX 片段被重排;CardPage 增加了 no-explicit-any 注释,并保持分页属性表达式不变。
Hackathon Less 属性重排
components/Activity/Hackathon/theme.less
Hackathon theme.less 中多个 mixin 的属性顺序被重排,未改变选择器、声明集合或 mixin 调用。

Estimated code review effort: 4 (Complex) | ~60 minutes

Related issue: #15

Suggested reviewers: TechQuery

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning 除 Open Library 外还改动了 Hackathon、Map、Organization 等无关组件,存在明显的范围外格式化修整。 建议将这些无关格式化修改拆分到独立 PR,仅保留 Open Library 相关代码。
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了新增 Open Library 模块与借阅流程,虽不够精炼但与变更一致。
Linked Issues check ✅ Passed 新增 Open Library 主页、目录、详情、借阅指南与状态/借阅信息展示,满足 #15 的主要需求。
✨ 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.

@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: 15

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
components/Activity/Hackathon/theme.less (2)

132-143: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

.button-ghost() 同样缺失 .button-base() 调用

.button-primary() 相同的问题,Line 133 的空语句导致 ghost 按钮丢失所有基础样式(flex 布局、padding、border-radius、字体、hover 动效等)。

🐛 建议恢复 mixin 调用
 .button-ghost() {
-  ;
+  .button-base();
   border-color: rgba(255, 255, 255, 0.14);
🤖 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 `@components/Activity/Hackathon/theme.less` around lines 132 - 143, The
`.button-ghost()` mixin in the theme.less file contains an empty statement (a
standalone semicolon) on the first line inside the mixin definition. Replace
this empty statement with a call to the `.button-base()` mixin to ensure ghost
buttons inherit all the foundational styles including flex layout, padding,
border-radius, fonts, and transition effects. This will restore the missing base
styling that ghost buttons currently lack.

118-130: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

.button-primary() 缺失 .button-base() 调用,按钮将丢失基础样式

.button-base() 提供了按钮的核心样式:display: inline-flexjustify-contentalign-itemsgaptransitionborder-radiuspaddingfont 系列属性以及 &:hovertransform 效果。

当前 Line 119 的 ; 是空语句,导致 Hero.module.lessActionHub.module.less 中调用 .button-primary() 的按钮将缺失这些基础布局与交互样式。

🐛 建议恢复 mixin 调用
 .button-primary() {
-  ;
+  .button-base();
   box-shadow: 0 0 24px rgba(44, 232, 255, 0.18);
🤖 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 `@components/Activity/Hackathon/theme.less` around lines 118 - 130, The
.button-primary() mixin in theme.less is missing a required call to the
.button-base() mixin. Currently, there is only an empty semicolon on line 119,
which means buttons using .button-primary() are losing essential base styles
like display, flexbox properties, transitions, border-radius, padding, and hover
transform effects. Replace the empty semicolon in the .button-primary() mixin
body with a call to .button-base() to restore these foundational styles that are
needed by buttons in Hero.module.less and ActionHub.module.less.
♻️ Duplicate comments (1)
pages/open-library/index.tsx (1)

210-224: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

“支持我们”区块请改为 React Bootstrap 按钮组件而非原生 a/span 伪按钮。

Line 210-224 当前实现破坏了 UI 组件一致性,也影响可维护性与可访问性语义。

As per coding guidelines, “ALWAYS use React Bootstrap components instead of custom HTML elements in UI code”.

🤖 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/open-library/index.tsx` around lines 210 - 224, The "支持我们" (Support Us)
section uses native HTML elements (the `a` tag for GitHub Sponsors and the
`span` within `Link` for book sharing) styled as buttons with className
attributes, which violates the React Bootstrap component guideline. Replace the
`a` element containing "GitHub Sponsors" with a React Bootstrap Button component
using appropriate props for href, variant, and size instead of className.
Similarly, replace the `Link` wrapper and `span` element containing "分享你的图书"
with a React Bootstrap Button component, ensuring the Link functionality is
preserved if needed. Import Button from react-bootstrap at the top of the file
and apply consistent button variants (such as light and outline-light) using the
variant prop instead of className.

Source: Coding guidelines

🧹 Nitpick comments (1)
pages/open-library/index.tsx (1)

104-113: ⚡ Quick win

建议复用 components/open-library/Layout.tsx,避免页面级重复装配导航/页脚/样式 Hook。

当前首页手动拼装 LibraryNavbar + useOpenLibraryLayout + FooterComponent,与共享 Layout 的职责重复,后续容易出现页间不一致。

As per coding guidelines, “Use minimal exports and avoid unnecessary custom implementations”.

Also applies to: 231-231

🤖 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/open-library/index.tsx` around lines 104 - 113, The page is manually
assembling LibraryNavbar, useOpenLibraryLayout hook, and FooterComponent instead
of using the shared Layout component from components/open-library/Layout.tsx.
Remove the individual LibraryNavbar, useOpenLibraryLayout hook usage, and
FooterComponent composition from the page, and instead wrap the page content
with the Layout component to eliminate duplication and ensure consistency across
pages. Apply this same refactoring to all locations where this manual assembly
occurs, including the location at line 231.

Source: Coding guidelines

🤖 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 `@components/Activity/Hackathon/theme.less`:
- Around line 31-51: The `.section-frame()` mixin is missing its internal mixin
calls and only contains empty statements. Replace the empty semicolons in the
nested selectors `.section`, `.sectionHeader`, `.sectionTitle`,
`.sectionSubtitle`, and `.accentLine` with their corresponding mixin calls
(e.g., `.section()` for the `.section` selector, `.sectionHeader()` for the
`.sectionHeader` selector, and so on). This will restore the style generation
for these elements that downstream files like `Overview.module.less` depend on
when calling `.section-frame()`.

In `@components/Layout/CardPage.tsx`:
- Around line 6-10: Replace the overly broad `Record<string, unknown>` type for
the Card property in CardPageProps with a precise union type that accurately
reflects the actual prop signatures of ActivityCard, ProjectCard, and
OrganizationCard. Alternatively, update each card component to properly accept
and handle the className and linkOf props that CardPage.tsx is passing on line
24, rather than ignoring them. Choose the approach that best aligns with your
component design intent: either define Card as a union of the three specific
card component types with their actual prop interfaces, or extend each card
component's prop interface to include className and linkOf parameters.

In `@components/Navigator/MainNavigator.tsx`:
- Around line 84-87: The menu item object for the open-library navigation route
uses the incorrect field name `name` when the MenuItem interface contract
requires the field to be named `title`. Change the property name from `name` to
`title` in the navigation item object that contains href set to '/open-library'.
This will align with the MenuItem type definition and ensure the navigation
title is properly rendered.

In `@components/open-library/BookCard.tsx`:
- Line 47: The hardcoded Chinese strings on line 47 (the conditional rendering
of '可借阅' and '已借出' based on book.status) and the alt text on line 57 are not
using the i18n t() function as required by the coding guidelines. Replace these
hardcoded user-facing strings by wrapping them with the t() function and
providing appropriate i18n keys for each string. This applies to the status
display conditional in the book.status ternary operator and any image alt text
attributes, ensuring all user-visible and accessibility-related text goes
through the translation function to avoid hardcoding and enable proper
localization.

In `@components/open-library/FeaturedBooks.tsx`:
- Around line 19-24: The FeaturedBooks component has hardcoded Chinese strings
as default values for title, subtitle, and viewAllText parameters, which
bypasses internationalization. Replace these hardcoded strings with i18n
translations by either accepting already-translated strings as parameters from
the calling component, or by integrating the I18nContext within the
FeaturedBooks component to call the t() function directly for these default
values. Ensure all user-facing text in the component uses the i18n t() function
to comply with the coding guidelines.

In `@components/open-library/Footer.tsx`:
- Around line 26-29: The Footer component contains multiple hardcoded
user-facing text strings that violate the i18n requirement. Replace all
hardcoded text with t() function calls using appropriate i18n keys: the social
media platform names (GitHub, Twitter, Feishu) around the mentioned lines, the
contact information section (联系信息) in the range specified, and
copyright/placeholder text. Ensure each hardcoded string is replaced with a
corresponding t() call and that i18n keys follow the existing naming convention
used in the component for consistency.
- Around line 31-51: The social media links in the Footer component use
placeholder href values (`#github`, `#twitter`, `#feishu`) that do not navigate to
actual external URLs. Replace the href attributes in the GitHub link, Twitter
link, and Feishu link with the real external URLs to their respective platforms,
or conditionally hide these link elements if the actual URLs are not yet
available in the application configuration.

In `@components/open-library/HeroSection.tsx`:
- Around line 16-22: The HeroSection component contains hardcoded user-facing
text strings that violate the i18n requirement. Replace all hardcoded Chinese
strings with i18n t() function calls: the default parameter values for title,
subtitle, ctaText, and heroImageAlt in the component function signature need to
use t() instead of literal Chinese strings, and the "浏览图书" text on line 59 also
needs to be wrapped with t(). Ensure all user-visible text strings are
internationalized consistently throughout the HeroSection component.

In `@components/open-library/HowItWorks.tsx`:
- Around line 23-57: The HowItWorks component has hardcoded Chinese text strings
that violate the i18n requirement. Replace all hardcoded strings in the
defaultSteps array (the title and description fields for each step object), the
default values for the title and subtitle parameters in the HowItWorksProps
destructuring, and the button text (mentioned as being on line 151) with
appropriate i18n keys wrapped in the t() function. Import and use the i18n
translation function to wrap these hardcoded strings with their corresponding
translation keys for proper internationalization support.

In `@components/open-library/Layout.tsx`:
- Around line 21-33: The default page title in the Layout component is hardcoded
as a string instead of using internationalization. Replace the hardcoded default
title value in the title parameter (currently set to 'Open Library - Open Source
Bazaar') with a call to the i18n t() function, using an appropriate translation
key like t('open_library_page_title'). This will ensure the page title changes
dynamically based on the user's language preference and complies with the coding
guideline that all user-facing text must use the i18n t() function.

In `@components/open-library/Navbar.tsx`:
- Line 31: The ternary expression in Navbar.tsx contains a hardcoded fallback
string 'Open Library' that violates the i18n constraint requiring all
user-facing text to use the t() function. Replace the hardcoded string 'Open
Library' in the false branch of the ternary operator with t('open_library') so
that both branches consistently use the translation function, ensuring proper
hydration-safe i18n handling throughout the component.

In `@pages/open-library/book/`[id].tsx:
- Around line 217-224: All user-facing text strings in the book details page
component must use the i18n t() function instead of being hardcoded. Replace all
hardcoded strings (including "Loading...", "Book Not Found", "Back", "Reviews",
"Borrow History", "Returned/Active" and others at the specified line ranges:
217-224, 234-244, 260, 282-283, 288, 294, 309-323, 335, 339, 350, 382, 389, 397,
402, 408-412, 432, 435, 446) with t() function calls using appropriate i18n
keys. First define all the necessary translation keys in your i18n
configuration, then systematically update each hardcoded string reference to use
t(keyName) instead.

In `@pages/open-library/books/index.tsx`:
- Around line 118-121: Replace all hardcoded Chinese text strings in the book
directory page with i18n t() function calls to enable proper language switching.
Locate the hardcoded strings in the h1 element containing "图书目录", the p element
containing "浏览我们的社区共享图书馆,发现有趣的书籍", and also check lines 143, 164, and 172 for
additional hardcoded text (titles, status messages, hints, or button labels).
For each hardcoded string, wrap it with the t() function using an appropriate
translation key that describes the content, ensuring all user-facing text
follows the i18n guidelines and the page properly reflects language changes when
users switch locales.

In `@pages/open-library/how-to-borrow.tsx`:
- Around line 9-13: The page contains hardcoded user-facing text like "如何借阅"
that should be internationalized. Replace all hardcoded strings throughout the
component (including the h1 title and all content in the mentioned line ranges)
with the t() function calls from the i18n library. Create corresponding
translation keys in the language resource files and ensure each hardcoded string
(titles, descriptions, process steps, rules, FAQs, and CTAs) is replaced with
t('keyName') calls, maintaining consistency with the project's i18n
implementation used in other pages.

In `@pages/open-library/index.tsx`:
- Around line 124-129: Replace all hardcoded Chinese text strings in the
component with the i18n `t()` function to comply with internationalization
standards. In the affected sections (lines 124-129, 135-156, 170-173, 202-208,
and 222-223), wrap every user-facing text string including titles like "📚
关于我们", descriptions like "freeCodeCamp 成都社区「Open Library」开放共享图书馆", list items,
and button labels with the `t()` function. Ensure each string has a
corresponding key defined in your i18n translation files.

---

Outside diff comments:
In `@components/Activity/Hackathon/theme.less`:
- Around line 132-143: The `.button-ghost()` mixin in the theme.less file
contains an empty statement (a standalone semicolon) on the first line inside
the mixin definition. Replace this empty statement with a call to the
`.button-base()` mixin to ensure ghost buttons inherit all the foundational
styles including flex layout, padding, border-radius, fonts, and transition
effects. This will restore the missing base styling that ghost buttons currently
lack.
- Around line 118-130: The .button-primary() mixin in theme.less is missing a
required call to the .button-base() mixin. Currently, there is only an empty
semicolon on line 119, which means buttons using .button-primary() are losing
essential base styles like display, flexbox properties, transitions,
border-radius, padding, and hover transform effects. Replace the empty semicolon
in the .button-primary() mixin body with a call to .button-base() to restore
these foundational styles that are needed by buttons in Hero.module.less and
ActionHub.module.less.

---

Duplicate comments:
In `@pages/open-library/index.tsx`:
- Around line 210-224: The "支持我们" (Support Us) section uses native HTML elements
(the `a` tag for GitHub Sponsors and the `span` within `Link` for book sharing)
styled as buttons with className attributes, which violates the React Bootstrap
component guideline. Replace the `a` element containing "GitHub Sponsors" with a
React Bootstrap Button component using appropriate props for href, variant, and
size instead of className. Similarly, replace the `Link` wrapper and `span`
element containing "分享你的图书" with a React Bootstrap Button component, ensuring
the Link functionality is preserved if needed. Import Button from
react-bootstrap at the top of the file and apply consistent button variants
(such as light and outline-light) using the variant prop instead of className.

---

Nitpick comments:
In `@pages/open-library/index.tsx`:
- Around line 104-113: The page is manually assembling LibraryNavbar,
useOpenLibraryLayout hook, and FooterComponent instead of using the shared
Layout component from components/open-library/Layout.tsx. Remove the individual
LibraryNavbar, useOpenLibraryLayout hook usage, and FooterComponent composition
from the page, and instead wrap the page content with the Layout component to
eliminate duplication and ensure consistency across pages. Apply this same
refactoring to all locations where this manual assembly occurs, including the
location at line 231.
🪄 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: 0b924692-11c8-4d01-b037-fb6acd2a8a56

📥 Commits

Reviewing files that changed from the base of the PR and between 96f3b06 and 5ccc58c.

⛔ Files ignored due to path filters (10)
  • .github/scripts/transform-message.ts is excluded by none and included by none
  • .github/workflows/self-scan.yml is excluded by none and included by none
  • .husky/pre-commit is excluded by none and included by none
  • .husky/pre-push is excluded by none and included by none
  • package.json is excluded by none and included by none
  • pages/open-library/readme.md is excluded by !**/*.md and included by pages/**
  • styles/open-library.css is excluded by none and included by none
  • 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 (23)
  • components/Activity/Hackathon/Hero.tsx
  • components/Activity/Hackathon/Resources.tsx
  • components/Activity/Hackathon/Schedule.tsx
  • components/Activity/Hackathon/theme.less
  • components/Layout/CardPage.tsx
  • components/License/helper.ts
  • components/Map/ChinaMap.tsx
  • components/Navigator/MainNavigator.tsx
  • components/Navigator/SearchBar.tsx
  • components/Organization/Card.tsx
  • components/open-library/BookCard.tsx
  • components/open-library/FeaturedBooks.tsx
  • components/open-library/Footer.tsx
  • components/open-library/HeroSection.tsx
  • components/open-library/HowItWorks.tsx
  • components/open-library/Layout.tsx
  • components/open-library/Navbar.tsx
  • components/open-library/useOpenLibraryLayout.ts
  • pages/_app.tsx
  • pages/open-library/book/[id].tsx
  • pages/open-library/books/index.tsx
  • pages/open-library/how-to-borrow.tsx
  • pages/open-library/index.tsx

Comment thread components/Activity/Hackathon/theme.less
Comment thread components/Layout/CardPage.tsx
Comment thread components/Navigator/MainNavigator.tsx
Comment thread components/open-library/BookCard.tsx Outdated
Comment thread components/open-library/FeaturedBooks.tsx Outdated
Comment thread components/open-library/Navbar.tsx Outdated
Comment thread pages/open-library/book/[id].tsx Outdated
Comment thread pages/open-library/books/index.tsx Outdated
Comment thread pages/open-library/how-to-borrow.tsx Outdated
Comment thread pages/open-library/index.tsx Outdated
…n, types, mixin fixes

i18n / hardcoded strings:
- BookCard: replace hardcoded status text and cover alt with t()
- FeaturedBooks: add observer+useContext, replace hardcoded Chinese defaults with t()
- HowItWorks: add observer+useContext, move defaultSteps inside component, replace all hardcoded strings with t()
- Footer: fully i18n all text, replace placeholder hrefs with real URLs
- HeroSection: make all text props required, eliminate hardcoded defaults
- Navbar: replace hardcoded fallback with t('open_library')
- books/index.tsx: replace hardcoded subtitle with t()
- how-to-borrow.tsx: add observer+useContext, replace all section headings and buttons with t()
- index.tsx: replace all hardcoded strings in About/Support sections with t()
- book/[id].tsx: replace Publisher/Published/Pages/N/A labels with t()

translation keys: add ~20 new keys across zh-CN, en-US, zh-TW
(book_cover, learn_more_details, book_catalog_description, ready_to_borrow,
open_library_community_intro, our_mission_text, core_concepts, knowledge_flow,
knowledge_flow_desc, community_driven, community_driven_desc, open_sharing,
open_sharing_desc, support_us, support_us_description, share_your_book,
book_publisher, book_published_year, book_page_count, not_available)

type / style fixes:
- CardPage.tsx: replace Record<string, unknown> with ComponentType<any> to fix
  pre-existing TS2322 errors where FC<ActivityCardProps|Project|OrganizationCardProps>
  was not assignable to FC<Record<string,unknown>> under strict mode
- theme.less: fill empty semicolons in .section-frame() with correct mixin
  calls; add missing .button-base() to .button-primary() and .button-ghost()
Comment thread styles/open-library.module.scss Outdated
Comment thread translation/zh-TW.ts Outdated
Comment thread pnpm-workspace.yaml
Comment thread pages/open-library/index.tsx Outdated
Comment thread components/Layout/CardPage.tsx Outdated
Comment thread pages/_app.tsx Outdated
Comment thread pages/open-library/book/[id].tsx Outdated
Comment thread pages/open-library/book/[id].tsx Outdated
Comment thread pages/open-library/book/[id].tsx Outdated
Comment thread pages/open-library/how-to-borrow.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.

Actionable comments posted: 4

♻️ Duplicate comments (1)
components/open-library/Footer.tsx (1)

26-35: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

将社交链接文案接入 i18n,避免硬编码。

Line 26 与 Line 34 的 GitHubWeChat 仍是直接文本,建议改为 t() key 输出,保证多语言一致性。
As per coding guidelines, “All user-facing text MUST use the i18n t() function (no hardcoded strings)”。

🤖 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 `@components/open-library/Footer.tsx` around lines 26 - 35, The social link
labels in Footer are still hardcoded user-facing text, so update the Footer
component to source both the GitHub and WeChat link copy through the i18n t()
function instead of inline strings. Use the existing translation keys pattern in
Footer, replace the visible anchor text with translated values, and ensure all
user-facing text in this section follows the same localization approach.

Source: Coding guidelines

🧹 Nitpick comments (1)
pages/open-library/how-to-borrow.tsx (1)

117-145: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

把快捷链接渲染成导航列表。

nav 里直接放按钮不符合项目的导航结构约定;可以继续用 React Bootstrap,但让第一层成为 ul/li

建议调整
-              <nav className="d-grid gap-2" aria-label={t('open_library_quick_links_label')}>
-                <Button
-                  href={catalogURL}
-                  target="_blank"
-                  rel="noopener noreferrer"
-                  variant="outline-primary"
-                >
-                  {t('view_full_catalog')}
-                </Button>
+              <nav aria-label={t('open_library_quick_links_label')}>
+                <ListGroup as="ul" className="list-unstyled d-grid gap-2 mb-0" variant="flush">
+                  <ListGroup.Item as="li" className="border-0 p-0">
+                    <Button
+                      className="w-100"
+                      href={catalogURL}
+                      target="_blank"
+                      rel="noopener noreferrer"
+                      variant="outline-primary"
+                    >
+                      {t('view_full_catalog')}
+                    </Button>
+                  </ListGroup.Item>
+                  {/* 其余链接同样包在 ListGroup.Item as="li" 中 */}
+                </ListGroup>
               </nav>

As per coding guidelines, “Use semantic HTML structure … use <ul> for navigation; apply list-unstyled on first-level lists”.

🤖 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/open-library/how-to-borrow.tsx` around lines 117 - 145, The quick links
in the open-library page are rendered as plain buttons inside the nav, which
does not match the project’s semantic navigation pattern. Update the `nav` in
`HowToBorrow` to use a first-level `ul` with `li` items (apply `list-unstyled`
as needed) and keep the existing React Bootstrap `Button`/`Link` behavior inside
those list items. Ensure the `aria-label` and link destinations stay the same
while the structure follows the navigation list convention.

Source: Coding guidelines

🤖 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 `@components/open-library/HowItWorks.tsx`:
- Around line 73-104: The step flow rendered in HowItWorks should be
semantically marked up as a countable sequence rather than a generic grid.
Update the resolvedSteps mapping in HowItWorks to wrap the items in an <ol> and
render each step as an <li>, keeping the existing layout/styling behavior
through the current Row/Col and stepIcon/stepNumber elements. This preserves the
numbered progression while aligning with the accessibility guideline to use <ol>
for countable items.

In `@pages/_app.tsx`:
- Line 58: The footer text currently hardcodes the visible English string
instead of using i18n. Update the `Powered by` copy in `pages/_app.tsx` to go
through the existing `t()` translation function (for example via a `powered_by`
key) so all user-facing text stays localized, and keep the change scoped to the
footer render block where the string is displayed.

In `@pages/open-library/book/`[id].tsx:
- Around line 37-44: The book cover Image usage in book/[id].tsx may fail
because the fallback source is an SVG and next/image blocks SVG optimization by
default. Verify the Image import is from next/image, then either enable
dangerouslyAllowSVG in next.config.ts or replace /images/placeholder-book.svg
with a bitmap placeholder so the cover renders reliably.

In `@pages/open-library/how-to-borrow.tsx`:
- Around line 21-23: The inlineMarkupOf helper currently passes
marked.parseInline output straight into dangerouslySetInnerHTML, which leaves
XSS risk from untrusted translation content. Update inlineMarkupOf in
how-to-borrow.tsx to sanitize the marked output before returning __html, using a
DOMPurify-based approach (add isomorphic-dompurify to package.json) so the HTML
is filtered through a whitelist before injection.

---

Duplicate comments:
In `@components/open-library/Footer.tsx`:
- Around line 26-35: The social link labels in Footer are still hardcoded
user-facing text, so update the Footer component to source both the GitHub and
WeChat link copy through the i18n t() function instead of inline strings. Use
the existing translation keys pattern in Footer, replace the visible anchor text
with translated values, and ensure all user-facing text in this section follows
the same localization approach.

---

Nitpick comments:
In `@pages/open-library/how-to-borrow.tsx`:
- Around line 117-145: The quick links in the open-library page are rendered as
plain buttons inside the nav, which does not match the project’s semantic
navigation pattern. Update the `nav` in `HowToBorrow` to use a first-level `ul`
with `li` items (apply `list-unstyled` as needed) and keep the existing React
Bootstrap `Button`/`Link` behavior inside those list items. Ensure the
`aria-label` and link destinations stay the same while the structure follows the
navigation list convention.
🪄 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: b1bcbf85-2d19-48bb-b6ed-8bed36282c69

📥 Commits

Reviewing files that changed from the base of the PR and between 5ccc58c and 553fbf6.

⛔ Files ignored due to path filters (10)
  • .husky/pre-commit is excluded by none and included by none
  • .husky/pre-push is excluded by none and included by none
  • package.json is excluded by none and included by none
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml and included by none
  • pnpm-workspace.yaml is excluded by none and included by none
  • public/images/placeholder-book.svg is excluded by !**/*.svg, !public/**/*.{png,jpg,jpeg,gif,webp,svg,ico,mp4,mp3,woff,woff2,ttf,otf} and included by none
  • public/images/placeholder-hero.svg is excluded by !**/*.svg, !public/**/*.{png,jpg,jpeg,gif,webp,svg,ico,mp4,mp3,woff,woff2,ttf,otf} and included by none
  • 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 (17)
  • components/Activity/Hackathon/theme.less
  • components/Layout/CardPage.tsx
  • components/Navigator/MainNavigator.tsx
  • components/open-library/BookCard.tsx
  • components/open-library/FeaturedBooks.tsx
  • components/open-library/Footer.tsx
  • components/open-library/HeroSection.tsx
  • components/open-library/HowItWorks.module.less
  • components/open-library/HowItWorks.tsx
  • components/open-library/Navbar.tsx
  • models/Book.ts
  • pages/_app.tsx
  • pages/api/open-library/books.ts
  • pages/open-library/book/[id].tsx
  • pages/open-library/books/index.tsx
  • pages/open-library/how-to-borrow.tsx
  • pages/open-library/index.tsx
✅ Files skipped from review due to trivial changes (3)
  • components/open-library/HowItWorks.module.less
  • models/Book.ts
  • components/Layout/CardPage.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/open-library/FeaturedBooks.tsx

Comment thread components/open-library/HowItWorks.tsx Outdated
Comment thread pages/_app.tsx
Comment thread pages/open-library/book/[id].tsx Outdated
Comment thread pages/open-library/how-to-borrow.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.

Actionable comments posted: 1

🤖 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/open-library/how-to-borrow.tsx`:
- Around line 20-29: The safeHrefOf helper is incorrectly allowing
protocol-relative URLs like //evil.example because it returns any href starting
with / before validation. Update safeHrefOf to explicitly reject URLs that start
with // while still allowing only intended same-origin paths and http/https
absolute URLs via URL parsing. Make sure the fix preserves the behavior used by
HowToBorrowPage so external links still flow through the target/rel handling and
unsafe protocol-relative links do not bypass it.
🪄 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: 45e78a88-adbc-4df2-b4d8-ed09ed128568

📥 Commits

Reviewing files that changed from the base of the PR and between 553fbf6 and e93ecc2.

📒 Files selected for processing (2)
  • components/open-library/HowItWorks.tsx
  • pages/open-library/how-to-borrow.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/open-library/HowItWorks.tsx

Comment thread pages/open-library/how-to-borrow.tsx Outdated

@TechQuery TechQuery left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

所有类似问题都要全局改

Comment thread components/open-library/FeaturedBooks.tsx Outdated
Comment thread components/open-library/HeroSection.tsx Outdated
Comment thread components/open-library/HowItWorks.tsx Outdated
Comment thread pages/_app.tsx Outdated
Comment thread pages/_app.tsx Outdated
Comment thread pages/open-library/how-to-borrow.tsx Outdated
Comment thread pages/open-library/how-to-borrow.tsx Outdated
Comment thread pages/open-library/how-to-borrow.tsx Outdated
Comment thread pages/open-library/how-to-borrow.tsx Outdated
Comment thread translation/en-US.ts 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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
pages/open-library/how-to-borrow.tsx (1)

112-112: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

把中文冒号也纳入 i18n。

Line 112 仍有硬编码的 ,切到英文等语言时会泄漏中文标点。建议用翻译键,或改成不依赖标点的间距布局。

建议修复
-                    <strong>{term}:</strong>
+                    <strong>
+                      {term}
+                      {t('borrow_rule_separator')}
+                    </strong>

As per coding guidelines, “All user-facing text MUST use the i18n t() function (no hardcoded strings)”.

🤖 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/open-library/how-to-borrow.tsx` at line 112, The title/label rendering
in the `how-to-borrow` page still hardcodes a Chinese colon in the `term`
display, which violates the i18n rule for user-facing text. Update the JSX
around the `term` output to remove the hardcoded `:` and either source the
punctuation through `t()` or refactor the layout so the label/value separation
does not depend on locale-specific punctuation. Use the `how-to-borrow`
component’s existing translation patterns to keep the `term` presentation fully
localized.

Source: Coding guidelines

🧹 Nitpick comments (3)
pages/open-library/how-to-borrow.tsx (1)

153-155: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

站内 quick link 改用 next/link
booksURL 是站内路由,当前直接用 href 会走普通锚点跳转;和底部 CTA 保持一致,包一层 Link 可避免整页刷新。

🤖 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/open-library/how-to-borrow.tsx` around lines 153 - 155, This is an
internal navigation link issue: the `ListGroup.Item` in `how-to-borrow` is using
a plain `href` for `booksURL`, which triggers a full page load. Update the
browse catalog quick link to use `next/link` (as the bottom CTA does) by
wrapping the clickable item with `Link` while keeping the
`t('browse_book_catalog')` content and `booksURL` target unchanged.
components/open-library/Footer.tsx (1)

40-53: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

站内导航建议统一使用 next/link

Nav.Link 直接使用 href="/open-library/books" / href="/open-library/how-to-borrow" 跳转站内路由,会触发整页刷新;而 FeaturedBooksHowItWorks 中均通过 next/link 包裹按钮实现客户端路由跳转。建议这里也接入 Link,保持导航体验一致。

♻️ 修复建议
+import Link from 'next/link';
...
             <Nav className="flex-column">
-              <Nav.Link
-                href="/open-library/books"
-                className="text-light px-0 py-1 text-decoration-none"
-              >
-                📖 {t('catalog_footer')}
-              </Nav.Link>
-              <Nav.Link
-                href="/open-library/how-to-borrow"
-                className="text-light px-0 py-1 text-decoration-none"
-              >
-                ℹ️ {t('how_to_borrow')}
-              </Nav.Link>
+              <Link href="/open-library/books" passHref legacyBehavior>
+                <Nav.Link className="text-light px-0 py-1 text-decoration-none">
+                  📖 {t('catalog_footer')}
+                </Nav.Link>
+              </Link>
+              <Link href="/open-library/how-to-borrow" passHref legacyBehavior>
+                <Nav.Link className="text-light px-0 py-1 text-decoration-none">
+                  ℹ️ {t('how_to_borrow')}
+                </Nav.Link>
+              </Link>
             </Nav>
🤖 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 `@components/open-library/Footer.tsx` around lines 40 - 53, The Footer
navigation links use Nav.Link with direct hrefs for internal routes, which
should be converted to client-side navigation to match the rest of the
open-library flow. Update the Footer component to use next/link for the
/open-library/books and /open-library/how-to-borrow destinations, keeping the
existing Nav.Link styling while routing through Link like the FeaturedBooks and
HowItWorks components do.
components/open-library/HeroSection.tsx (1)

52-59: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

“浏览图书”按钮内部跳转未走 next/link

browseLink 默认指向站内路由 /open-library/books,但 Button 直接用 href,未像 FeaturedBooks/HowItWorks 一样用 next/link 包裹,会导致整页刷新而非客户端路由跳转,体验不一致。

♻️ 修复建议
+import Link from 'next/link';
...
-              <Button
-                variant="outline-light"
-                size="lg"
-                href={browseLink}
-                className="mb-2 rounded-pill px-4"
-              >
-                📖 {browseText}
-              </Button>
+              <Link href={browseLink} passHref legacyBehavior>
+                <Button
+                  variant="outline-light"
+                  size="lg"
+                  as="a"
+                  className="mb-2 rounded-pill px-4"
+                >
+                  📖 {browseText}
+                </Button>
+              </Link>
🤖 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 `@components/open-library/HeroSection.tsx` around lines 52 - 59, The “browse
books” action in HeroSection uses Button with a raw href for browseLink, which
triggers a full page load instead of client-side navigation. Update the
HeroSection component so the Button for browseText is wrapped or rendered
through next/link the same way as FeaturedBooks and HowItWorks, keeping the
browseLink navigation as a client-side route transition while preserving the
existing Button styling and props.
🤖 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/open-library/book/`[id].tsx:
- Around line 172-178: The Image in book detail rendering is missing the
required height prop when using next/image with a dynamic src and no fill
layout. Update the Image usage in the open-library book page component to either
provide a valid height alongside the existing width, or switch the same Image
instance to fill-based layout with an appropriate container so the cover image
renders without runtime errors.

---

Duplicate comments:
In `@pages/open-library/how-to-borrow.tsx`:
- Line 112: The title/label rendering in the `how-to-borrow` page still
hardcodes a Chinese colon in the `term` display, which violates the i18n rule
for user-facing text. Update the JSX around the `term` output to remove the
hardcoded `:` and either source the punctuation through `t()` or refactor the
layout so the label/value separation does not depend on locale-specific
punctuation. Use the `how-to-borrow` component’s existing translation patterns
to keep the `term` presentation fully localized.

---

Nitpick comments:
In `@components/open-library/Footer.tsx`:
- Around line 40-53: The Footer navigation links use Nav.Link with direct hrefs
for internal routes, which should be converted to client-side navigation to
match the rest of the open-library flow. Update the Footer component to use
next/link for the /open-library/books and /open-library/how-to-borrow
destinations, keeping the existing Nav.Link styling while routing through Link
like the FeaturedBooks and HowItWorks components do.

In `@components/open-library/HeroSection.tsx`:
- Around line 52-59: The “browse books” action in HeroSection uses Button with a
raw href for browseLink, which triggers a full page load instead of client-side
navigation. Update the HeroSection component so the Button for browseText is
wrapped or rendered through next/link the same way as FeaturedBooks and
HowItWorks, keeping the browseLink navigation as a client-side route transition
while preserving the existing Button styling and props.

In `@pages/open-library/how-to-borrow.tsx`:
- Around line 153-155: This is an internal navigation link issue: the
`ListGroup.Item` in `how-to-borrow` is using a plain `href` for `booksURL`,
which triggers a full page load. Update the browse catalog quick link to use
`next/link` (as the bottom CTA does) by wrapping the clickable item with `Link`
while keeping the `t('browse_book_catalog')` content and `booksURL` target
unchanged.
🪄 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: 82a8fcc9-8a4a-4118-8bb6-06e5b7111cd4

📥 Commits

Reviewing files that changed from the base of the PR and between 264ad3b and 8ee3015.

⛔ 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 (11)
  • components/open-library/BookCard.tsx
  • components/open-library/FeaturedBooks.tsx
  • components/open-library/Footer.tsx
  • components/open-library/HeroSection.tsx
  • components/open-library/HowItWorks.tsx
  • components/open-library/Navbar.tsx
  • pages/_app.tsx
  • pages/open-library/book/[id].tsx
  • pages/open-library/books/index.tsx
  • pages/open-library/how-to-borrow.tsx
  • pages/open-library/index.tsx
💤 Files with no reviewable changes (1)
  • components/open-library/Navbar.tsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • pages/open-library/books/index.tsx
  • pages/open-library/index.tsx
  • pages/_app.tsx
  • components/open-library/BookCard.tsx

Comment on lines +172 to +178
<Image
src={cover || '/images/placeholder-book.svg'}
alt={title}
className="img-fluid"
style={{ maxHeight: '300px' }}
width={200}
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

next/image 还缺少必填的 height

这里 src 是动态字符串且未使用 fillnext/image 需要同时提供 widthheight,否则封面图会在渲染时直接报错。建议补上 height,或改成 fill 布局。

🤖 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/open-library/book/`[id].tsx around lines 172 - 178, The Image in book
detail rendering is missing the required height prop when using next/image with
a dynamic src and no fill layout. Update the Image usage in the open-library
book page component to either provide a valid height alongside the existing
width, or switch the same Image instance to fill-based layout with an
appropriate container so the cover image renders without runtime errors.

@TechQuery TechQuery left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot 所有的问题全篇都要改类似的情况

Comment thread components/open-library/BookCard.tsx Outdated
Comment on lines +28 to +31
bg={book.status === 'available' ? 'success' : 'warning'}
text={book.status === 'available' ? undefined : 'dark'}
>
{book.status === 'available' ? t('available') : t('borrowed')}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

多次使用的表达式抽出一个常量

Comment thread components/open-library/BookCard.tsx Outdated
Comment on lines +40 to +45
className="rounded bg-light"
style={{
height: '180px',
objectFit: 'contain',
padding: '10px',
}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
className="rounded bg-light"
style={{
height: '180px',
objectFit: 'contain',
padding: '10px',
}}
className="rounded bg-light object-fit-contain"
style={{ height: '180px', padding: '10px' }}

Comment thread components/open-library/Footer.tsx Outdated
💬{' '}
<a
className="text-light"
href="https://open.weixin.qq.com/qr/code?username=gh_b8b06d05cfa6"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

多次出现的重复网址也要像上面的邮箱一样声明一个常量,也可以集中放到专门的 model/configuration.ts

Comment thread components/open-library/HowItWorks.tsx Outdated
Comment on lines +9 to +15
export interface Step {
id: number;
title: string;
description: string;
icon: string;
color: string;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

string 类型的字段都放到 extends 后面的 Record

Comment thread components/open-library/Navbar.tsx Outdated
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav className="me-auto">
{/* <Nav.Link href="/open-library">{t('home')}</Nav.Link> */}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
{/* <Nav.Link href="/open-library">{t('home')}</Nav.Link> */}

Comment thread pages/open-library/book/[id].tsx Outdated
Comment on lines +50 to +60
if (!reviews?.[0])
return (
<div className="text-center py-5">
<p className="mb-4">{t('be_first_to_review')}</p>
<Button variant="primary" href={reviewFormURL} target="_blank" rel="noopener noreferrer">
{t('write_review')}
</Button>
</div>
);

return (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

用三目运算符合起来

Comment thread pages/open-library/book/[id].tsx Outdated
Comment on lines +65 to +68
reviewer={reviewer}
rating={rating}
comment={comment}
date={date}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

用展开简写的对象自变量

@TechQuery TechQuery left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

全局所有类似问题都要改。

如果是 AI 智能体在写代码的话,它需要领会每一处建议的用意,而非盲目地从一个极端走向另一个极端,需要体现出智能。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这个页脚组件的设计可以直接用在全局,把老的页脚删掉就行了,文件夹也提升一层。

'title' | 'subtitle' | 'ctaText' | 'ctaLink' | 'browseText' | 'heroImage' | 'heroImageAlt',
string
>,
Partial<Record<'browseLink', string>> {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

我之前的建议核心目的在于“消除重复”,这个单项的它不重复,你这么写反而会让代码更长,interface 的 body 却变成了一个空的花括号……

Comment thread models/configuration.ts
Comment on lines +33 to +37
export const OpenLibraryContactEmail = 'team@fcc-cd.dev';

export const OpenLibraryGitHubURL =
'https://github.com/Open-Source-Bazaar/Open-Source-Bazaar.github.io';
export const OpenLibraryWeChatURL = 'https://open.weixin.qq.com/qr/code?username=gh_b8b06d05cfa6';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这些是整个项目的通用信息,不应该加 OpenLibrary 前缀。

Comment thread models/configuration.ts
Comment on lines +39 to +48
export const OpenLibraryCatalogURL =
'https://open-source-bazaar.feishu.cn/share/base/view/shrcnvT0Lyk8LKS8KtPbO9HPPHb';
export const OpenLibraryBorrowFormURL =
'https://open-source-bazaar.feishu.cn/share/base/form/shrcnNiKwb9ApzFFGI3YkCXDdwe?prefill_%E6%93%8D%E4%BD%9C=%E5%80%9F%E5%85%A5';
export const OpenLibraryHandoffFormURL =
'https://open-source-bazaar.feishu.cn/share/base/form/shrcnuDb3oOuhMjSaXNIHEPA4Ef?prefill_%E6%93%8D%E4%BD%9C=%E5%80%9F%E5%87%BA';
export const OpenLibraryMembershipFormURL =
'https://open-source-bazaar.feishu.cn/share/base/form/shrcngQgMrhjTh6ycO1zcaEWZld';
export const OpenLibraryReviewFormURL =
'https://open-source-bazaar.feishu.cn/share/base/form/shrcnFAX8q7mnywCQOsVnIS5Dwb';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

具体某个子系统的环境变量放到这个文件的最下方,比较通用的才放在上面。

Comment on lines +48 to +52
{reviews.map(({ reviewer, rating, comment, date }) => {
const review = { reviewer, rating, comment, date };

return <ReviewCard key={`${reviewer}-${date}`} {...review} />;
})}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
{reviews.map(({ reviewer, rating, comment, date }) => {
const review = { reviewer, rating, comment, date };
return <ReviewCard key={`${reviewer}-${date}`} {...review} />;
})}
{reviews.map(({ reviewer, rating, comment, date }) =>
<ReviewCard key={`${reviewer}-${date}`} {...{ reviewer, rating, comment, date }} />
)}


const booksURL = '/open-library/books';

const trustedInlineMarkupOf = (text: string) => ({ __html: marked.parseInline(text) as string });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
const trustedInlineMarkupOf = (text: string) => ({ __html: marked.parseInline(text) as string });
const trustedInlineMarkupOf = (text: string) => ({ __html: marked(text) as string });

直接把这个函数返回的东西写在每一处调用代码即可,内容太少,无需封装。

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

Labels

enhancement Some improvements feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants