feat: add MobX-RESTful-Shadcn pagination, scroll-list, and editor demo pages with shared i18n nav#6
Conversation
TechQuery
left a comment
There was a problem hiding this comment.
@copilot 仔细看组件库文档! https://github.com/idea2app/MobX-RESTful-Shadcn 要求全部使用 shadcn-helper 命令行安装所有 Shadcn UI 组件!components/ui/ 所有组件全删掉,全不要提交上来!
…files, add babel TC39 decorator config
已删除全部 |
…vel translation/ and i18n/
…-Staged 17, Shadcn-helper 0.5, Lucide-React 1 & other latest Upstream packages/actions [fix] Shadcn helper installation [remove] Geist for Next.js font
There was a problem hiding this comment.
Pull request overview
Adds two MobX-RESTful-Shadcn demo pages (pagination table + infinite scroll list) and migrates the app’s i18n implementation from static JSON dictionaries to a mobx-i18n-based translation store, alongside related build/tooling updates.
Changes:
- Introduces
/[lang]/paginationand/[lang]/scroll-listdemo pages backed by a sharedRepositoryModel("idea2app")store. - Replaces
dictionaries/*.json+get-dictionary.ts+i18n-config.tswith a newtranslation/module (SSR loader + translation maps). - Updates build/tooling configuration (Babel config, TS target/flags, pnpm workspace, CI action versions, font stack changes).
Reviewed changes
Copilot reviewed 26 out of 29 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Updates TS target and class-fields behavior flag. |
| translation/en-US.ts | Adds English translation map for new UI strings. |
| translation/zh-CN.ts | Adds Simplified Chinese translation map for new UI strings. |
| translation/zh-TW.ts | Adds Traditional Chinese translation map for new UI strings. |
| translation/index.ts | Implements mobx-i18n store creation + SSR language selection helpers. |
| translation/context.ts | Adds client-side React context for i18n store. |
| translation/server.ts | Adds SSR loader that reads headers and returns an i18n store. |
| app/[lang]/page.tsx | Switches home page to SSR i18n store + adds nav links to new demo pages. |
| app/[lang]/pagination/page.tsx | Adds RestTable pagination demo page (client component). |
| app/[lang]/scroll-list/page.tsx | Adds ScrollList infinite-scroll demo page (client component). |
| app/[lang]/layout.tsx | Removes Next font setup; keeps minimal layout wrapper. |
| app/[lang]/globals.css | Replaces Geist CSS variables with system font stacks. |
| models/Repository.ts | Adds GitHub repository store and optional auth middleware. |
| proxy.ts | Rewires locale detection to use new translation exports. |
| components.json | Adds MobX-RESTful-Shadcn registry entry for shadcn-helper. |
| components/index.ini | Lists MobX-RESTful-Shadcn components to install. |
| babel.config.js | Adds custom Babel config for TS + decorators. |
| package.json | Adds MobX-related deps and upgrades tooling; switches build to next build --webpack. |
| pnpm-workspace.yaml | Adds pnpm workspace + build allowlist config. |
| .gitignore | Ignores generated components/ui/ directory. |
| README.md | Removes outdated next/font/Geist documentation references. |
| .github/workflows/main.yml | Updates CI workflow triggers and action versions. |
| .github/workflows/init-template.yml | Updates template init workflow action versions. |
| i18n-config.ts | Removed old locale config constants/types. |
| get-dictionary.ts | Removed old dictionary loader. |
| dictionaries/en-US.json | Removed old JSON dictionary. |
| dictionaries/zh-CN.json | Removed old JSON dictionary. |
| dictionaries/zh-TW.json | Removed old JSON dictionary. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| presets: [ | ||
| // https://babeljs.io/docs/babel-preset-react | ||
| [ | ||
| '@babel/preset-react', | ||
| { | ||
| runtime: 'automatic', | ||
| development: process.env.BABEL_ENV === 'development', | ||
| }, | ||
| ], | ||
| ], | ||
| plugins: [ | ||
| // https://github.com/babel/babel/issues/16262#issuecomment-1962832499 | ||
| [ | ||
| '@babel/plugin-transform-typescript', | ||
| { | ||
| allowDeclareFields: true, | ||
| allowNamespaces: true, | ||
| allExtensions: true, | ||
| isTSX: true, | ||
| }, | ||
| ], | ||
| // https://babeljs.io/docs/babel-plugin-proposal-decorators#note-compatibility-with-babelplugin-transform-class-properties | ||
| ['@babel/plugin-proposal-decorators', { version: '2023-05' }], | ||
| ], |
| export default function RootLayout({ children }: PropsWithChildren<{}>) { | ||
| return ( | ||
| <html lang="en"> | ||
| <body | ||
| className={`${geistSans.variable} ${geistMono.variable} antialiased`} | ||
| > | ||
| {children} | ||
| </body> | ||
| <body className="antialiased">{children}</body> | ||
| </html> |
| <main className="container mx-auto px-4 py-8"> | ||
| <h1 className="my-4 text-2xl font-bold">{i18n.t("load_more")}</h1> |
| required: true, | ||
| minLength: 3, | ||
| invalidMessage: "Input 3 characters at least", | ||
| }, |
| githubClient.use(({ request }, next) => { | ||
| const token = process.env.GITHUB_TOKEN; | ||
|
|
||
| if (token) | ||
| request.headers = { |
已补上移植页面并接入当前 App Router:新增 |
| <nav className="flex flex-col gap-2 sm:flex-row sm:gap-4"> | ||
| <Link | ||
| href={`/${lang}/pagination`} | ||
| className="hover:bg-accent hover:text-accent-foreground rounded-md border px-4 py-2 text-sm font-medium transition-colors" | ||
| > | ||
| {i18n.t("pagination") as string} | ||
| </Link> | ||
| <Link | ||
| href={`/${lang}/scroll-list`} | ||
| className="hover:bg-accent hover:text-accent-foreground rounded-md border px-4 py-2 text-sm font-medium transition-colors" | ||
| > | ||
| {i18n.t("scroll_list") as string} | ||
| </Link> | ||
| <Link | ||
| href={`/${lang}/editor`} | ||
| className="hover:bg-accent hover:text-accent-foreground rounded-md border px-4 py-2 text-sm font-medium transition-colors" | ||
| > | ||
| {i18n.t("editor") as string} | ||
| </Link> | ||
| </nav> |
There was a problem hiding this comment.
参考 https://github.com/GoodAction-Hub/GoodAction-Hub.github.io/blob/main/components%2FMainNav.tsx 将导航栏做成所有页面公用的组件,同时也要实现语言切换下拉框。
There was a problem hiding this comment.
只复制粘贴文件没有用,那你得实际在客户端渲染的时候通过上下文使用国际化数据才行,参考:https://github.com/GoodAction-Hub/GoodAction-Hub.github.io/blob/main/app%2Flayout.tsx#L47-L50
已按参考代码上下文完成重构:把导航抽成全局公用 |
Implements MobX-RESTful-Shadcn demo pages in the App Router scaffold, and updates i18n/navigation wiring to follow the referenced GoodAction-Hub client+server context pattern.
New Pages
/[lang]/pagination—RestTablewith GitHub repos fromidea2apporg: paginated, searchable, with CRUD modals/[lang]/scroll-list—ScrollListwith infinite-scroll card grid of the same repos/[lang]/editor— dynamic-loaded HTML editor demo migrated from upstream exampleShared Navigation & Language Switch
MainNavcomponent used across allapp/[lang]/*pagesapp/[lang]/layout.tsxto render shared nav globallyi18n Runtime (Server + Client)
I18nProviderand wired SSR language/map into client contextI18nContextat render timeeditorandlanguage) in:translation/en-US.tstranslation/zh-CN.tstranslation/zh-TW.tsComponent Installation
Shadcn UI registry components are installed via
shadcn-helper(not committed manually undercomponents/ui/), with required registry entries incomponents/index.ini, including:@mobx-restful-shadcn/badge-bar@mobx-restful-shadcn/rest-table@mobx-restful-shadcn/scroll-list@mobx-restful-shadcn/editorBuild Compatibility
next build --webpackfor production build compatibility in this setupHuman changes