@qlover/create-app 0.7.14 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/configs/_common/.gitignore.template +6 -0
- package/dist/configs/_common/.prettierignore +17 -5
- package/dist/configs/_common/.vscode/settings.json +6 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/next-app/.env.template +1 -1
- package/dist/templates/next-app/README.en.md +130 -0
- package/dist/templates/next-app/README.md +114 -20
- package/dist/templates/next-app/config/Identifier/api.ts +5 -5
- package/dist/templates/next-app/config/Identifier/common/admint.table.ts +69 -0
- package/dist/templates/next-app/config/Identifier/common/common.ts +76 -0
- package/dist/templates/next-app/config/Identifier/common/index.ts +3 -0
- package/dist/templates/next-app/config/Identifier/{validator.ts → common/validators.ts} +5 -5
- package/dist/templates/next-app/config/Identifier/index.ts +2 -12
- package/dist/templates/next-app/config/Identifier/pages/index.ts +6 -0
- package/dist/templates/next-app/config/Identifier/pages/page.admin.home.ts +27 -0
- package/dist/templates/next-app/config/Identifier/pages/page.admin.locales.ts +266 -0
- package/dist/templates/next-app/config/Identifier/pages/page.admin.user.ts +293 -0
- package/dist/templates/{react-app/config/Identifier → next-app/config/Identifier/pages}/page.home.ts +15 -22
- package/dist/templates/next-app/config/Identifier/{page.login.ts → pages/page.login.ts} +28 -34
- package/dist/templates/next-app/config/Identifier/{page.register.ts → pages/page.register.ts} +30 -29
- package/dist/templates/next-app/config/adminNavs.ts +19 -0
- package/dist/templates/next-app/config/common.ts +22 -13
- package/dist/templates/next-app/config/i18n/HomeI18n.ts +5 -5
- package/dist/templates/next-app/config/i18n/admin18n.ts +61 -19
- package/dist/templates/next-app/config/i18n/i18nConfig.ts +2 -0
- package/dist/templates/next-app/config/i18n/i18nKeyScheam.ts +36 -0
- package/dist/templates/next-app/config/i18n/loginI18n.ts +22 -22
- package/dist/templates/next-app/config/i18n/register18n.ts +23 -24
- package/dist/templates/next-app/docs/en/api.md +387 -0
- package/dist/templates/next-app/docs/en/component.md +544 -0
- package/dist/templates/next-app/docs/en/database.md +496 -0
- package/dist/templates/next-app/docs/en/development-guide.md +727 -0
- package/dist/templates/next-app/docs/en/env.md +563 -0
- package/dist/templates/next-app/docs/en/i18n.md +287 -0
- package/dist/templates/next-app/docs/en/index.md +165 -0
- package/dist/templates/next-app/docs/en/page.md +457 -0
- package/dist/templates/next-app/docs/en/project-structure.md +176 -0
- package/dist/templates/next-app/docs/en/router.md +427 -0
- package/dist/templates/next-app/docs/en/theme.md +532 -0
- package/dist/templates/next-app/docs/en/validator.md +478 -0
- package/dist/templates/next-app/docs/zh/api.md +387 -0
- package/dist/templates/next-app/docs/zh/component.md +544 -0
- package/dist/templates/next-app/docs/zh/database.md +496 -0
- package/dist/templates/next-app/docs/zh/development-guide.md +727 -0
- package/dist/templates/next-app/docs/zh/env.md +563 -0
- package/dist/templates/next-app/docs/zh/i18n.md +287 -0
- package/dist/templates/next-app/docs/zh/index.md +165 -0
- package/dist/templates/next-app/docs/zh/page.md +457 -0
- package/dist/templates/next-app/docs/zh/project-structure.md +176 -0
- package/dist/templates/next-app/docs/zh/router.md +427 -0
- package/dist/templates/next-app/docs/zh/theme.md +532 -0
- package/dist/templates/next-app/docs/zh/validator.md +476 -0
- package/dist/templates/next-app/make/generateLocales.ts +19 -12
- package/dist/templates/next-app/migrations/schema/LocalesSchema.ts +15 -0
- package/dist/templates/next-app/migrations/sql/1694244000000.sql +11 -0
- package/dist/templates/next-app/package.json +7 -3
- package/dist/templates/next-app/public/locales/en.json +172 -207
- package/dist/templates/next-app/public/locales/zh.json +172 -207
- package/dist/templates/next-app/src/app/[locale]/admin/locales/page.tsx +153 -0
- package/dist/templates/next-app/src/app/[locale]/admin/users/page.tsx +48 -50
- package/dist/templates/next-app/src/app/[locale]/login/LoginForm.tsx +2 -2
- package/dist/templates/next-app/src/app/api/admin/locales/create/route.ts +34 -0
- package/dist/templates/next-app/src/app/api/admin/locales/import/route.ts +40 -0
- package/dist/templates/next-app/src/app/api/admin/locales/route.ts +42 -0
- package/dist/templates/next-app/src/app/api/admin/locales/update/route.ts +32 -0
- package/dist/templates/next-app/src/app/api/locales/json/route.ts +44 -0
- package/dist/templates/next-app/src/base/cases/AdminPageManager.ts +1 -13
- package/dist/templates/next-app/src/base/cases/Datetime.ts +18 -0
- package/dist/templates/next-app/src/base/cases/DialogErrorPlugin.ts +12 -6
- package/dist/templates/next-app/src/base/cases/ResourceState.ts +17 -0
- package/dist/templates/next-app/src/base/cases/TranslateI18nInterface.ts +25 -0
- package/dist/templates/next-app/src/base/cases/ZodColumnBuilder.ts +200 -0
- package/dist/templates/next-app/src/base/port/ZodBuilderInterface.ts +8 -0
- package/dist/templates/next-app/src/base/services/AdminLocalesService.ts +20 -0
- package/dist/templates/next-app/src/base/services/AdminPageEvent.ts +26 -0
- package/dist/templates/next-app/src/base/services/AdminPageScheduler.ts +42 -0
- package/dist/templates/next-app/src/base/services/ResourceService.ts +122 -0
- package/dist/templates/next-app/src/base/services/adminApi/AdminLocalesApi.ts +104 -0
- package/dist/templates/next-app/src/base/services/adminApi/AdminUserApi.ts +38 -5
- package/dist/templates/next-app/src/base/services/appApi/AppApiPlugin.ts +1 -1
- package/dist/templates/next-app/src/i18n/request.ts +30 -1
- package/dist/templates/next-app/src/server/PageParams.ts +2 -10
- package/dist/templates/next-app/src/server/port/DBBridgeInterface.ts +5 -0
- package/dist/templates/next-app/src/server/port/DBTableInterface.ts +2 -0
- package/dist/templates/next-app/src/server/port/LocalesRepositoryInterface.ts +43 -0
- package/dist/templates/next-app/src/server/repositorys/LocalesRepository.ts +197 -0
- package/dist/templates/next-app/src/server/services/ApiLocaleService.ts +122 -0
- package/dist/templates/next-app/src/server/sqlBridges/SupabaseBridge.ts +60 -11
- package/dist/templates/next-app/src/server/validators/ExtendedExecutorError.ts +6 -0
- package/dist/templates/next-app/src/server/validators/LocalesValidator.ts +131 -0
- package/dist/templates/next-app/src/server/validators/LoginValidator.ts +2 -5
- package/dist/templates/next-app/src/server/validators/PaginationValidator.ts +32 -16
- package/dist/templates/next-app/src/styles/css/antd-themes/pagination/_default.css +2 -1
- package/dist/templates/next-app/src/styles/css/antd-themes/pagination/dark.css +28 -29
- package/dist/templates/next-app/src/styles/css/antd-themes/pagination/pink.css +2 -1
- package/dist/templates/next-app/src/uikit/components/AdminLayout.tsx +17 -3
- package/dist/templates/next-app/src/uikit/components/BaseHeader.tsx +5 -4
- package/dist/templates/next-app/src/uikit/components/BaseLayout.tsx +5 -4
- package/dist/templates/next-app/src/uikit/components/BootstrapsProvider.tsx +3 -2
- package/dist/templates/next-app/src/uikit/components/ComboProvider.tsx +1 -1
- package/dist/templates/next-app/src/uikit/components/EditableCell.tsx +118 -0
- package/dist/templates/next-app/src/uikit/components/LogoutButton.tsx +5 -6
- package/dist/templates/next-app/src/uikit/components/ThemeSwitcher.tsx +1 -1
- package/dist/templates/next-app/src/uikit/components/With.tsx +2 -2
- package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportButton.tsx +62 -0
- package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportEvent.ts +28 -0
- package/dist/templates/next-app/src/uikit/components/localesImportButton/import.module.css +6 -0
- package/dist/templates/next-app/src/uikit/hook/useI18nInterface.ts +8 -14
- package/dist/templates/next-app/src/uikit/hook/useWarnTranslations.ts +25 -0
- package/dist/templates/react-app/.prettierignore +17 -0
- package/dist/templates/react-app/README.en.md +71 -54
- package/dist/templates/react-app/README.md +35 -18
- package/dist/templates/react-app/__tests__/__mocks__/BootstrapTest.ts +14 -0
- package/dist/templates/react-app/__tests__/__mocks__/MockAppConfit.ts +1 -1
- package/dist/templates/react-app/__tests__/__mocks__/MockDialogHandler.ts +2 -2
- package/dist/templates/react-app/__tests__/__mocks__/MockLogger.ts +1 -1
- package/dist/templates/react-app/__tests__/__mocks__/components/TestApp.tsx +45 -0
- package/dist/templates/react-app/__tests__/__mocks__/components/TestBootstrapsProvider.tsx +34 -0
- package/dist/templates/react-app/__tests__/__mocks__/components/TestRouter.tsx +46 -0
- package/dist/templates/react-app/__tests__/__mocks__/components/index.ts +12 -0
- package/dist/templates/react-app/__tests__/__mocks__/createMockGlobals.ts +1 -2
- package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOC.ts +51 -0
- package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOCRegister.ts +69 -0
- package/dist/templates/react-app/__tests__/setup/index.ts +1 -51
- package/dist/templates/react-app/__tests__/setup/setupGlobal.ts +51 -0
- package/dist/templates/react-app/__tests__/src/App.structure.test.tsx +115 -0
- package/dist/templates/react-app/__tests__/src/base/cases/AppConfig.test.ts +2 -2
- package/dist/templates/react-app/__tests__/src/base/cases/AppError.test.ts +1 -1
- package/dist/templates/react-app/__tests__/src/base/cases/DialogHandler.test.ts +3 -5
- package/dist/templates/react-app/__tests__/src/base/cases/I18nKeyErrorPlugin.test.ts +13 -2
- package/dist/templates/react-app/__tests__/src/base/cases/InversifyContainer.test.ts +1 -1
- package/dist/templates/react-app/__tests__/src/base/cases/PublicAssetsPath.test.ts +1 -1
- package/dist/templates/react-app/__tests__/src/base/cases/RequestLogger.test.ts +5 -5
- package/dist/templates/react-app/__tests__/src/base/cases/RequestStatusCatcher.test.ts +1 -2
- package/dist/templates/react-app/__tests__/src/base/cases/RouterLoader.test.ts +25 -15
- package/dist/templates/react-app/__tests__/src/base/services/I18nService.test.ts +29 -15
- package/dist/templates/react-app/__tests__/src/core/IOC.test.ts +19 -9
- package/dist/templates/react-app/__tests__/src/core/bootstraps/BootstrapClient.test.ts +153 -0
- package/dist/templates/react-app/__tests__/src/core/bootstraps/BootstrapsApp.test.ts +9 -7
- package/dist/templates/react-app/__tests__/src/main.integration.test.tsx +4 -5
- package/dist/templates/react-app/__tests__/src/main.test.tsx +4 -4
- package/dist/templates/react-app/__tests__/src/uikit/components/BaseHeader.test.tsx +68 -59
- package/dist/templates/react-app/config/IOCIdentifier.ts +8 -8
- package/dist/templates/react-app/config/Identifier/{common.error.ts → common/common.error.ts} +5 -5
- package/dist/templates/react-app/config/Identifier/{common.ts → common/common.ts} +9 -9
- package/dist/templates/react-app/config/Identifier/common/index.ts +2 -0
- package/dist/templates/react-app/config/Identifier/index.ts +1 -9
- package/dist/templates/react-app/config/Identifier/pages/index.ts +8 -0
- package/dist/templates/react-app/config/Identifier/{page.about.ts → pages/page.about.ts} +34 -26
- package/dist/templates/react-app/config/Identifier/{page.executor.ts → pages/page.executor.ts} +47 -39
- package/dist/templates/{next-app/config/Identifier → react-app/config/Identifier/pages}/page.home.ts +24 -23
- package/dist/templates/react-app/config/Identifier/pages/page.identifiter.ts +102 -0
- package/dist/templates/react-app/config/Identifier/{page.jsonStorage.ts → pages/page.jsonStorage.ts} +18 -11
- package/dist/templates/react-app/config/Identifier/{page.login.ts → pages/page.login.ts} +37 -27
- package/dist/templates/react-app/config/Identifier/{page.register.ts → pages/page.register.ts} +37 -25
- package/dist/templates/react-app/config/Identifier/{page.request.ts → pages/page.request.ts} +34 -44
- package/dist/templates/react-app/config/app.router.ts +66 -69
- package/dist/templates/react-app/config/i18n/PageI18nInterface.ts +51 -0
- package/dist/templates/react-app/config/i18n/aboutI18n.ts +42 -0
- package/dist/templates/react-app/config/i18n/executorI18n.ts +51 -0
- package/dist/templates/react-app/config/i18n/homeI18n.ts +24 -0
- package/dist/templates/react-app/config/i18n/i18nConfig.ts +30 -0
- package/dist/templates/react-app/config/i18n/identifiter18n.ts +30 -0
- package/dist/templates/react-app/config/i18n/jsonStorage18n.ts +27 -0
- package/dist/templates/react-app/config/i18n/login18n.ts +42 -0
- package/dist/templates/react-app/config/i18n/notFoundI18n.ts +34 -0
- package/dist/templates/react-app/config/i18n/register18n.ts +40 -0
- package/dist/templates/react-app/config/i18n/request18n.ts +41 -0
- package/dist/templates/react-app/config/theme.ts +14 -4
- package/dist/templates/react-app/docs/en/bootstrap.md +1670 -341
- package/dist/templates/react-app/docs/en/development-guide.md +1021 -345
- package/dist/templates/react-app/docs/en/env.md +1132 -278
- package/dist/templates/react-app/docs/en/i18n.md +858 -147
- package/dist/templates/react-app/docs/en/index.md +733 -104
- package/dist/templates/react-app/docs/en/ioc.md +1228 -287
- package/dist/templates/react-app/docs/en/playwright/e2e-tests.md +321 -0
- package/dist/templates/react-app/docs/en/playwright/index.md +19 -0
- package/dist/templates/react-app/docs/en/playwright/installation-summary.md +332 -0
- package/dist/templates/react-app/docs/en/playwright/overview.md +222 -0
- package/dist/templates/react-app/docs/en/playwright/quickstart.md +325 -0
- package/dist/templates/react-app/docs/en/playwright/reorganization-notes.md +340 -0
- package/dist/templates/react-app/docs/en/playwright/setup-complete.md +290 -0
- package/dist/templates/react-app/docs/en/playwright/testing-guide.md +565 -0
- package/dist/templates/react-app/docs/en/store.md +1194 -184
- package/dist/templates/react-app/docs/en/why-no-globals.md +797 -0
- package/dist/templates/react-app/docs/zh/bootstrap.md +1670 -341
- package/dist/templates/react-app/docs/zh/development-guide.md +1021 -345
- package/dist/templates/react-app/docs/zh/env.md +1132 -275
- package/dist/templates/react-app/docs/zh/i18n.md +858 -147
- package/dist/templates/react-app/docs/zh/index.md +717 -104
- package/dist/templates/react-app/docs/zh/ioc.md +1229 -287
- package/dist/templates/react-app/docs/zh/playwright/e2e-tests.md +321 -0
- package/dist/templates/react-app/docs/zh/playwright/index.md +19 -0
- package/dist/templates/react-app/docs/zh/playwright/installation-summary.md +332 -0
- package/dist/templates/react-app/docs/zh/playwright/overview.md +222 -0
- package/dist/templates/react-app/docs/zh/playwright/quickstart.md +325 -0
- package/dist/templates/react-app/docs/zh/playwright/reorganization-notes.md +340 -0
- package/dist/templates/react-app/docs/zh/playwright/setup-complete.md +290 -0
- package/dist/templates/react-app/docs/zh/playwright/testing-guide.md +565 -0
- package/dist/templates/react-app/docs/zh/store.md +1192 -184
- package/dist/templates/react-app/docs/zh/why-no-globals.md +797 -0
- package/dist/templates/react-app/e2e/App.spec.ts +319 -0
- package/dist/templates/react-app/e2e/fixtures/base.fixture.ts +40 -0
- package/dist/templates/react-app/e2e/main.spec.ts +20 -0
- package/dist/templates/react-app/e2e/utils/test-helpers.ts +19 -0
- package/dist/templates/react-app/eslint.config.mjs +247 -0
- package/dist/templates/react-app/makes/eslint-utils.mjs +195 -0
- package/dist/templates/react-app/makes/generateTs2LocalesOptions.ts +26 -0
- package/dist/templates/react-app/package.json +31 -3
- package/dist/templates/react-app/playwright.config.ts +79 -0
- package/dist/templates/react-app/public/locales/en/common.json +190 -179
- package/dist/templates/react-app/public/locales/zh/common.json +190 -179
- package/dist/templates/react-app/src/App.tsx +15 -42
- package/dist/templates/react-app/src/base/apis/AiApi.ts +5 -5
- package/dist/templates/react-app/src/base/apis/feApi/FeApi.ts +1 -1
- package/dist/templates/react-app/src/base/apis/feApi/FeApiAdapter.ts +1 -1
- package/dist/templates/react-app/src/base/apis/feApi/FeApiBootstarp.ts +8 -8
- package/dist/templates/react-app/src/base/apis/feApi/FeApiType.ts +1 -1
- package/dist/templates/react-app/src/base/apis/userApi/UserApi.ts +6 -6
- package/dist/templates/react-app/src/base/apis/userApi/UserApiAdapter.ts +1 -1
- package/dist/templates/react-app/src/base/apis/userApi/UserApiBootstarp.ts +12 -14
- package/dist/templates/react-app/src/base/apis/userApi/UserApiType.ts +1 -1
- package/dist/templates/react-app/src/base/cases/DialogHandler.ts +5 -2
- package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +3 -3
- package/dist/templates/react-app/src/base/cases/InversifyContainer.ts +3 -3
- package/dist/templates/react-app/src/base/cases/RequestLanguages.ts +2 -2
- package/dist/templates/react-app/src/base/cases/RequestLogger.ts +4 -4
- package/dist/templates/react-app/src/base/cases/RequestStatusCatcher.ts +1 -1
- package/dist/templates/react-app/src/base/cases/ResourceState.ts +23 -0
- package/dist/templates/react-app/src/base/cases/RouterLoader.ts +4 -4
- package/dist/templates/react-app/src/base/cases/TranslateI18nInterface.ts +26 -0
- package/dist/templates/react-app/src/base/port/ExecutorPageBridgeInterface.ts +2 -3
- package/dist/templates/react-app/src/base/port/I18nServiceInterface.ts +1 -1
- package/dist/templates/react-app/src/base/port/IOCInterface.ts +36 -0
- package/dist/templates/react-app/src/base/port/JSONStoragePageBridgeInterface.ts +2 -1
- package/dist/templates/react-app/src/base/port/ProcesserExecutorInterface.ts +1 -1
- package/dist/templates/react-app/src/base/port/RequestPageBridgeInterface.ts +2 -2
- package/dist/templates/react-app/src/base/port/RouteServiceInterface.ts +9 -5
- package/dist/templates/react-app/src/base/port/UserServiceInterface.ts +1 -1
- package/dist/templates/react-app/src/base/services/I18nService.ts +29 -29
- package/dist/templates/react-app/src/base/services/IdentifierService.ts +143 -0
- package/dist/templates/react-app/src/base/services/ProcesserExecutor.ts +3 -3
- package/dist/templates/react-app/src/base/services/RouteService.ts +27 -8
- package/dist/templates/react-app/src/base/services/UserService.ts +8 -8
- package/dist/templates/react-app/src/base/types/Page.ts +14 -2
- package/dist/templates/react-app/src/base/types/global.d.ts +1 -1
- package/dist/templates/react-app/src/core/IOC.ts +5 -46
- package/dist/templates/react-app/src/core/bootstraps/{BootstrapApp.ts → BootstrapClient.ts} +44 -17
- package/dist/templates/react-app/src/core/bootstraps/BootstrapsRegistry.ts +14 -7
- package/dist/templates/react-app/src/core/bootstraps/IocIdentifierTest.ts +1 -1
- package/dist/templates/react-app/src/core/bootstraps/PrintBootstrap.ts +1 -1
- package/dist/templates/react-app/src/core/clientIoc/ClientIOC.ts +40 -0
- package/dist/templates/react-app/src/core/{IocRegisterImpl.ts → clientIoc/ClientIOCRegister.ts} +35 -24
- package/dist/templates/react-app/src/core/globals.ts +9 -9
- package/dist/templates/react-app/src/main.tsx +4 -4
- package/dist/templates/react-app/src/pages/404.tsx +6 -3
- package/dist/templates/react-app/src/pages/500.tsx +5 -2
- package/dist/templates/react-app/src/pages/NoRouteFound.tsx +5 -0
- package/dist/templates/react-app/src/pages/auth/Layout.tsx +9 -6
- package/dist/templates/react-app/src/pages/auth/LoginPage.tsx +46 -56
- package/dist/templates/react-app/src/pages/auth/RegisterPage.tsx +46 -58
- package/dist/templates/react-app/src/pages/base/AboutPage.tsx +35 -40
- package/dist/templates/react-app/src/pages/base/ExecutorPage.tsx +51 -51
- package/dist/templates/react-app/src/pages/base/HomePage.tsx +14 -15
- package/dist/templates/react-app/src/pages/base/IdentifierPage.tsx +70 -11
- package/dist/templates/react-app/src/pages/base/JSONStoragePage.tsx +24 -25
- package/dist/templates/react-app/src/pages/base/Layout.tsx +2 -2
- package/dist/templates/react-app/src/pages/base/RedirectPathname.tsx +3 -2
- package/dist/templates/react-app/src/pages/base/RequestPage.tsx +41 -59
- package/dist/templates/react-app/src/styles/css/antd-themes/{_default.css → _common/_default.css} +85 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/{dark.css → _common/dark.css} +99 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/_common/index.css +3 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/{pink.css → _common/pink.css} +86 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/index.css +4 -3
- package/dist/templates/react-app/src/styles/css/antd-themes/menu/_default.css +108 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/menu/dark.css +67 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/menu/index.css +3 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/menu/pink.css +67 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/pagination/_default.css +34 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/pagination/dark.css +31 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/pagination/index.css +3 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/pagination/pink.css +36 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/table/_default.css +44 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/table/dark.css +43 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/table/index.css +3 -0
- package/dist/templates/react-app/src/styles/css/antd-themes/table/pink.css +43 -0
- package/dist/templates/react-app/src/styles/css/page.css +4 -3
- package/dist/templates/react-app/src/styles/css/themes/_default.css +1 -0
- package/dist/templates/react-app/src/styles/css/themes/dark.css +1 -0
- package/dist/templates/react-app/src/styles/css/themes/pink.css +1 -0
- package/dist/templates/react-app/src/styles/css/zIndex.css +1 -1
- package/dist/templates/react-app/src/uikit/bridges/ExecutorPageBridge.ts +3 -3
- package/dist/templates/react-app/src/uikit/bridges/JSONStoragePageBridge.ts +2 -2
- package/dist/templates/react-app/src/uikit/bridges/NavigateBridge.ts +1 -1
- package/dist/templates/react-app/src/uikit/bridges/RequestPageBridge.ts +3 -3
- package/dist/templates/react-app/src/uikit/components/AppRouterProvider.tsx +35 -0
- package/dist/templates/react-app/src/uikit/components/BaseHeader.tsx +15 -11
- package/dist/templates/react-app/src/uikit/components/BaseRouteProvider.tsx +14 -11
- package/dist/templates/react-app/src/uikit/components/BaseRouteSeo.tsx +18 -0
- package/dist/templates/react-app/src/uikit/components/BootstrapsProvider.tsx +13 -0
- package/dist/templates/react-app/src/uikit/components/ClientSeo.tsx +62 -0
- package/dist/templates/react-app/src/uikit/components/ComboProvider.tsx +38 -0
- package/dist/templates/react-app/src/uikit/components/LanguageSwitcher.tsx +48 -27
- package/dist/templates/react-app/src/uikit/components/Loading.tsx +4 -2
- package/dist/templates/react-app/src/uikit/components/LocaleLink.tsx +4 -5
- package/dist/templates/react-app/src/uikit/components/LogoutButton.tsx +34 -11
- package/dist/templates/react-app/src/uikit/components/ProcessExecutorProvider.tsx +9 -5
- package/dist/templates/react-app/src/uikit/components/RouterRenderComponent.tsx +6 -3
- package/dist/templates/react-app/src/uikit/components/ThemeSwitcher.tsx +97 -40
- package/dist/templates/react-app/src/uikit/components/UserAuthProvider.tsx +5 -5
- package/dist/templates/react-app/src/uikit/components/With.tsx +17 -0
- package/dist/templates/react-app/src/uikit/contexts/BaseRouteContext.ts +17 -11
- package/dist/templates/react-app/src/uikit/contexts/IOCContext.ts +13 -0
- package/dist/templates/react-app/src/uikit/hooks/useAppTranslation.ts +26 -0
- package/dist/templates/react-app/src/uikit/hooks/useI18nGuard.ts +8 -11
- package/dist/templates/react-app/src/uikit/hooks/useI18nInterface.ts +25 -0
- package/dist/templates/react-app/src/uikit/hooks/useIOC.ts +35 -0
- package/dist/templates/react-app/src/uikit/hooks/useNavigateBridge.ts +3 -3
- package/dist/templates/react-app/src/uikit/hooks/useStrictEffect.ts +0 -1
- package/dist/templates/react-app/tsconfig.e2e.json +21 -0
- package/dist/templates/react-app/tsconfig.json +8 -1
- package/dist/templates/react-app/tsconfig.node.json +1 -1
- package/dist/templates/react-app/tsconfig.test.json +3 -1
- package/dist/templates/react-app/vite.config.ts +50 -34
- package/package.json +2 -1
- package/dist/configs/react-app/eslint.config.js +0 -94
- package/dist/templates/next-app/config/Identifier/common.error.ts +0 -41
- package/dist/templates/next-app/config/Identifier/common.ts +0 -69
- package/dist/templates/next-app/config/Identifier/page.about.ts +0 -181
- package/dist/templates/next-app/config/Identifier/page.admin.ts +0 -48
- package/dist/templates/next-app/config/Identifier/page.executor.ts +0 -272
- package/dist/templates/next-app/config/Identifier/page.identifiter.ts +0 -39
- package/dist/templates/next-app/config/Identifier/page.jsonStorage.ts +0 -72
- package/dist/templates/next-app/config/Identifier/page.request.ts +0 -182
- package/dist/templates/next-app/docs/env.md +0 -94
- package/dist/templates/next-app/src/base/cases/ChatAction.ts +0 -21
- package/dist/templates/next-app/src/base/cases/FocusBarAction.ts +0 -36
- package/dist/templates/next-app/src/base/cases/RequestState.ts +0 -20
- package/dist/templates/next-app/src/base/port/AdminPageInterface.ts +0 -85
- package/dist/templates/next-app/src/base/port/AsyncStateInterface.ts +0 -7
- package/dist/templates/next-app/src/base/services/AdminUserService.ts +0 -45
- package/dist/templates/next-app/src/uikit/components/ChatRoot.tsx +0 -17
- package/dist/templates/next-app/src/uikit/components/chat/ChatActionInterface.ts +0 -30
- package/dist/templates/next-app/src/uikit/components/chat/ChatFocusBar.tsx +0 -65
- package/dist/templates/next-app/src/uikit/components/chat/ChatMessages.tsx +0 -59
- package/dist/templates/next-app/src/uikit/components/chat/ChatWrap.tsx +0 -28
- package/dist/templates/next-app/src/uikit/components/chat/FocusBarActionInterface.ts +0 -19
- package/dist/templates/next-app/src/uikit/hook/useMountedClient.ts +0 -17
- package/dist/templates/next-app/src/uikit/hook/useStore.ts +0 -15
- package/dist/templates/react-app/__tests__/__mocks__/I18nService.ts +0 -13
- package/dist/templates/react-app/__tests__/src/App.test.tsx +0 -139
- package/dist/templates/react-app/config/Identifier/page.identifiter.ts +0 -39
- package/dist/templates/react-app/config/i18n.ts +0 -15
- package/dist/templates/react-app/docs/en/project-structure.md +0 -434
- package/dist/templates/react-app/docs/zh/project-structure.md +0 -434
- package/dist/templates/react-app/src/base/cases/RequestState.ts +0 -20
- package/dist/templates/react-app/src/base/port/AsyncStateInterface.ts +0 -7
- package/dist/templates/react-app/src/uikit/hooks/useDocumentTitle.ts +0 -15
- package/dist/templates/react-app/src/uikit/hooks/useStore.ts +0 -15
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# 国际化 (i18n) 指南
|
|
2
|
+
|
|
3
|
+
本文档将详细介绍项目中的国际化实现,包括 API 错误信息、页面内容以及所有需要多语言支持的文本内容。
|
|
4
|
+
|
|
5
|
+
## 目录
|
|
6
|
+
|
|
7
|
+
- [基础配置](#基础配置)
|
|
8
|
+
- [API 错误信息处理](#api-错误信息处理)
|
|
9
|
+
- [页面内容国际化](#页面内容国际化)
|
|
10
|
+
- [使用规范](#使用规范)
|
|
11
|
+
|
|
12
|
+
## 基础配置
|
|
13
|
+
|
|
14
|
+
项目使用 next-intl 进行国际化管理,配置文件位于 `config/i18n/i18nConfig.ts`:
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
export const i18nConfig = {
|
|
18
|
+
localeNames: {
|
|
19
|
+
en: 'English',
|
|
20
|
+
zh: '中文'
|
|
21
|
+
},
|
|
22
|
+
fallbackLng: 'en',
|
|
23
|
+
supportedLngs: ['en', 'zh'],
|
|
24
|
+
localeDetection: true
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
所有支持的语言都在 `supportedLngs` 中定义,默认语言为 `fallbackLng` 指定的语言。
|
|
29
|
+
|
|
30
|
+
## API 错误信息处理
|
|
31
|
+
|
|
32
|
+
API 错误信息的国际化处理流程如下:
|
|
33
|
+
|
|
34
|
+
1. API 响应格式:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
interface AppApiErrorInterface {
|
|
38
|
+
success: false;
|
|
39
|
+
id: string; // i18n key
|
|
40
|
+
message?: string; // 可选的直接显示消息
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
2. 错误处理流程:
|
|
45
|
+
- API 请求通过 `AppApiPlugin` 处理响应
|
|
46
|
+
- 如果响应表示错误,错误信息会被转换为 `ExecutorError`
|
|
47
|
+
- `DialogErrorPlugin` 负责显示错误消息
|
|
48
|
+
- 如果错误消息是 i18n key 格式(如 "namespace_key"),则会通过 i18n 服务翻译后显示
|
|
49
|
+
- 如果不是 i18n key 格式,则直接显示原始消息
|
|
50
|
+
|
|
51
|
+
示例:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// API 返回错误
|
|
55
|
+
{
|
|
56
|
+
success: false,
|
|
57
|
+
id: "error_invalid_password"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// DialogErrorPlugin 会自动翻译并显示对应语言的错误信息
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 页面内容国际化
|
|
64
|
+
|
|
65
|
+
### PageI18nInterface
|
|
66
|
+
|
|
67
|
+
`PageI18nInterface` 是一个核心接口,用于定义页面的国际化内容和 SEO 元数据。这个接口提供了完整的页面元数据结构,包括基本 SEO 信息、Open Graph、Twitter Card 等。
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
interface PageI18nInterface {
|
|
71
|
+
// 基本元数据属性
|
|
72
|
+
title: string; // 页面标题
|
|
73
|
+
description: string; // 页面描述
|
|
74
|
+
content: string; // 页面内容
|
|
75
|
+
keywords: string; // 页面关键词
|
|
76
|
+
|
|
77
|
+
// 规范链接
|
|
78
|
+
canonical?: string; // 可选的规范链接
|
|
79
|
+
|
|
80
|
+
// 爬虫控制
|
|
81
|
+
robots?: {
|
|
82
|
+
index?: boolean; // 是否允许索引
|
|
83
|
+
follow?: boolean; // 是否跟随链接
|
|
84
|
+
noarchive?: boolean; // 是否允许存档
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Open Graph 元数据
|
|
88
|
+
og?: {
|
|
89
|
+
title?: string; // OG 标题
|
|
90
|
+
description?: string; // OG 描述
|
|
91
|
+
type?: string; // 内容类型
|
|
92
|
+
image?: string; // 图片 URL
|
|
93
|
+
url?: string; // 页面 URL
|
|
94
|
+
siteName?: string; // 站点名称
|
|
95
|
+
locale?: string; // 语言地区
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Twitter Card 元数据
|
|
99
|
+
twitter?: {
|
|
100
|
+
card?: 'summary' | 'summary_large_image' | 'app' | 'player'; // 卡片类型
|
|
101
|
+
site?: string; // Twitter 站点
|
|
102
|
+
creator?: string; // 创建者
|
|
103
|
+
title?: string; // Twitter 标题
|
|
104
|
+
description?: string; // Twitter 描述
|
|
105
|
+
image?: string; // Twitter 图片
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// 附加元数据
|
|
109
|
+
author?: string; // 作者
|
|
110
|
+
publishedTime?: string; // 发布时间
|
|
111
|
+
modifiedTime?: string; // 修改时间
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
使用说明:
|
|
116
|
+
|
|
117
|
+
1. 所有字符串类型的值都可以是:
|
|
118
|
+
- i18n key:将会被翻译成当前语言
|
|
119
|
+
- 直接字符串:将直接使用,不进行翻译
|
|
120
|
+
2. 可选字段(带 `?` 的字段)表示该页面可以不包含这些元数据
|
|
121
|
+
3. 这个接口通常用于:
|
|
122
|
+
- 定义页面的 SEO 信息
|
|
123
|
+
- 生成 meta 标签
|
|
124
|
+
- 提供社交媒体分享信息
|
|
125
|
+
- 控制搜索引擎爬虫行为
|
|
126
|
+
|
|
127
|
+
### 在页面中使用 PageI18nInterface
|
|
128
|
+
|
|
129
|
+
以下是一个完整的页面示例,展示如何使用 PageI18nInterface:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// 1. 首先定义页面的 i18n 接口
|
|
133
|
+
export const homeI18n = Object.freeze({
|
|
134
|
+
title: i18nKeys.PAGE_HOME_TITLE,
|
|
135
|
+
description: i18nKeys.PAGE_HOME_DESCRIPTION,
|
|
136
|
+
content: i18nKeys.PAGE_HOME_DESCRIPTION,
|
|
137
|
+
keywords: i18nKeys.PAGE_HOME_KEYWORDS,
|
|
138
|
+
|
|
139
|
+
welcome: i18nKeys.HOME_WELCOME,
|
|
140
|
+
getStartedTitle: i18nKeys.HOME_GET_STARTED_TITLE,
|
|
141
|
+
getStartedDescription: i18nKeys.HOME_GET_STARTED_DESCRIPTION,
|
|
142
|
+
getStartedButton: i18nKeys.HOME_GET_STARTED_BUTTON
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// 2. 在页面中使用
|
|
146
|
+
export async function generateMetadata({ params }: { params: PageParamsType }): Promise<Metadata> {
|
|
147
|
+
const pageParams = new PageParams(await params);
|
|
148
|
+
// 获取页面 SEO 元数据
|
|
149
|
+
return await pageParams.getI18nInterface(homeI18n);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export default async function HomePage({ params }: PageParamsProps) {
|
|
153
|
+
const pageParams = new PageParams(await params!);
|
|
154
|
+
// 获取页面翻译内容
|
|
155
|
+
const tt = await pageParams.getI18nInterface(homeI18n);
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<BaseLayout>
|
|
159
|
+
<section>
|
|
160
|
+
<h1>{tt.welcome}</h1>
|
|
161
|
+
<p>{tt.description}</p>
|
|
162
|
+
<div>
|
|
163
|
+
<h2>{tt.getStartedTitle}</h2>
|
|
164
|
+
<p>{tt.getStartedDescription}</p>
|
|
165
|
+
<Button>{tt.getStartedButton}</Button>
|
|
166
|
+
</div>
|
|
167
|
+
</section>
|
|
168
|
+
</BaseLayout>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
这个示例展示了:
|
|
174
|
+
|
|
175
|
+
1. 如何定义页面特定的 i18n 接口
|
|
176
|
+
2. 如何使用 `getI18nInterface` 获取翻译后的内容
|
|
177
|
+
3. 如何在页面元数据中使用 i18n
|
|
178
|
+
4. 如何在页面组件中使用翻译的内容
|
|
179
|
+
|
|
180
|
+
### 实现页面国际化
|
|
181
|
+
|
|
182
|
+
页面内容的国际化主要通过以下方式实现:
|
|
183
|
+
|
|
184
|
+
1. 页面 i18n 接口定义:
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
// config/i18n/HomeI18n.ts
|
|
188
|
+
export const homeI18n = Object.freeze({
|
|
189
|
+
title: i18nKeys.PAGE_HOME_TITLE,
|
|
190
|
+
description: i18nKeys.PAGE_HOME_DESCRIPTION,
|
|
191
|
+
welcome: i18nKeys.HOME_WELCOME
|
|
192
|
+
// ...
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
2. 获取翻译内容:
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
// 在页面组件中
|
|
200
|
+
const messages = await getMessages({ locale });
|
|
201
|
+
// 或者使用 PageParams
|
|
202
|
+
const i18nContent = await pageParams.getI18nInterface(homeI18n);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
3. 动态路由中的语言处理:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// src/app/[locale]/layout.tsx
|
|
209
|
+
export default async function RootLayout({ children, params }) {
|
|
210
|
+
const pageParams = new PageParams(params);
|
|
211
|
+
const locale = pageParams.getI18nWithNotFound();
|
|
212
|
+
// ...
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## 使用规范
|
|
217
|
+
|
|
218
|
+
1. **所有文本内容必须使用 i18n key**:
|
|
219
|
+
- 不要直接在代码中写入固定文本
|
|
220
|
+
- 所有文本都应该定义在 i18n 配置文件中
|
|
221
|
+
- 使用有意义的 key 名称,如:`PAGE_HOME_TITLE`、`ERROR_INVALID_INPUT`
|
|
222
|
+
|
|
223
|
+
2. **i18n key 命名规范**:
|
|
224
|
+
- 使用大写字母和下划线
|
|
225
|
+
- 使用有意义的前缀表示分类,如:
|
|
226
|
+
- `PAGE_` 前缀表示页面相关
|
|
227
|
+
- `ERROR_` 前缀表示错误信息
|
|
228
|
+
- `COMMON_` 前缀表示通用文本
|
|
229
|
+
|
|
230
|
+
3. **翻译文件组织**:
|
|
231
|
+
- 翻译文件位于 `public/locales/` 目录
|
|
232
|
+
- 按语言代码分类:`en.json`、`zh.json`
|
|
233
|
+
- 保持所有语言文件的 key 一致
|
|
234
|
+
|
|
235
|
+
4. **类型安全**:
|
|
236
|
+
- 使用 TypeScript 接口定义 i18n 内容
|
|
237
|
+
- 所有 i18n key 都应该在 `config/Identifier/` 目录下定义
|
|
238
|
+
- 使用 `Object.freeze` 确保 i18n 对象不被修改
|
|
239
|
+
|
|
240
|
+
5. **最佳实践**:
|
|
241
|
+
- 使用 `PageParams` 类处理页面的语言相关逻辑
|
|
242
|
+
- 在组件中使用 `useTranslations` hook 获取翻译
|
|
243
|
+
- API 错误信息优先使用 i18n key,而不是硬编码的消息
|
|
244
|
+
- 确保所有用户可见的文本都支持多语言
|
|
245
|
+
|
|
246
|
+
## 示例
|
|
247
|
+
|
|
248
|
+
1. 页面组件中使用 i18n:
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
export function LoginForm(props: { tt: LoginI18nInterface }) {
|
|
252
|
+
const { tt } = props;
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<form>
|
|
256
|
+
<h1>{tt.title}</h1>
|
|
257
|
+
<p>{tt.description}</p>
|
|
258
|
+
{/* ... */}
|
|
259
|
+
</form>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
2. API 错误处理:
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
// 后端返回错误
|
|
268
|
+
throw new AppErrorApi({
|
|
269
|
+
id: 'ERROR_INVALID_CREDENTIALS',
|
|
270
|
+
success: false
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// 前端自动处理并显示翻译后的错误消息
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
3. 动态内容:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const t = await getTranslations({
|
|
280
|
+
locale: pageParams.getLocale(),
|
|
281
|
+
namespace: 'common'
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const message = t('welcome', {
|
|
285
|
+
name: userName
|
|
286
|
+
});
|
|
287
|
+
```
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Next.js 全栈应用开发文档
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
|
|
5
|
+
这是一个基于 Next.js 的全栈应用模板,采用面向接口的设计模式,实现了清晰的分层架构。本模板提供了完整的全栈开发解决方案,包括服务端API、客户端状态管理、认证授权、国际化等核心功能。
|
|
6
|
+
|
|
7
|
+
### 主要特性
|
|
8
|
+
|
|
9
|
+
- 🏗️ **全栈架构**:基于 Next.js 的应用路由和API路由
|
|
10
|
+
- 🔌 **接口驱动**:完整的面向接口编程实践
|
|
11
|
+
- 🎨 **主题定制**:基于 Tailwind CSS 的主题系统
|
|
12
|
+
- 🌍 **国际化**:基于 next-intl 的多语言支持
|
|
13
|
+
- 🔄 **依赖注入**:基于 TypeScript 的 IOC 容器
|
|
14
|
+
- 🛡️ **身份认证**:完整的认证和授权方案
|
|
15
|
+
- 📡 **分层设计**:清晰的前后端分层架构
|
|
16
|
+
- 🎮 **状态管理**:基于控制器模式的状态管理
|
|
17
|
+
- 🔗 **数据访问**:灵活的数据库访问层
|
|
18
|
+
|
|
19
|
+
## 快速开始
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# 安装依赖
|
|
23
|
+
pnpm install
|
|
24
|
+
|
|
25
|
+
# 开发环境启动
|
|
26
|
+
pnpm dev
|
|
27
|
+
# cross-env APP_ENV=localhost next dev --turbopack --port 3100
|
|
28
|
+
# 自动加载 .env.localhost -> .env
|
|
29
|
+
|
|
30
|
+
# 预发环境启动
|
|
31
|
+
pnpm dev:staging
|
|
32
|
+
# cross-env APP_ENV=staging next dev --turbopack --port 3100
|
|
33
|
+
# 自动加载 .env.staging -> .env
|
|
34
|
+
|
|
35
|
+
# 构建生产版本
|
|
36
|
+
pnpm build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 架构概览
|
|
40
|
+
|
|
41
|
+
### 1. 客户端架构
|
|
42
|
+
|
|
43
|
+
#### 接口定义 (src/base/port)
|
|
44
|
+
|
|
45
|
+
- AppUserApiInterface: 用户API接口
|
|
46
|
+
- AsyncStateInterface: 异步状态接口
|
|
47
|
+
- RouterInterface: 路由管理接口
|
|
48
|
+
|
|
49
|
+
#### 核心实现
|
|
50
|
+
|
|
51
|
+
- 控制器层:状态和业务逻辑管理
|
|
52
|
+
- 服务层:API调用和数据处理
|
|
53
|
+
- UI组件:可复用的展示组件
|
|
54
|
+
|
|
55
|
+
### 2. 服务端架构
|
|
56
|
+
|
|
57
|
+
#### 接口定义 (src/server/port)
|
|
58
|
+
|
|
59
|
+
- ServerAuthInterface: 认证接口
|
|
60
|
+
- DBBridgeInterface: 数据库操作接口
|
|
61
|
+
- UserRepositoryInterface: 用户仓库接口
|
|
62
|
+
- ValidatorInterface: 数据验证接口
|
|
63
|
+
|
|
64
|
+
#### 核心实现
|
|
65
|
+
|
|
66
|
+
- API路由层:请求处理和响应
|
|
67
|
+
- 服务层:业务逻辑实现
|
|
68
|
+
- 数据访问层:仓库和数据库交互
|
|
69
|
+
|
|
70
|
+
## 开发指南
|
|
71
|
+
|
|
72
|
+
### 1. API 开发流程
|
|
73
|
+
|
|
74
|
+
1. 定义接口 (src/server/port)
|
|
75
|
+
2. 实现验证器 (src/server/validators)
|
|
76
|
+
3. 实现服务层 (src/server/services)
|
|
77
|
+
4. 实现数据访问 (src/server/repositorys)
|
|
78
|
+
5. 创建API路由 (src/app/api)
|
|
79
|
+
|
|
80
|
+
### 2. 页面开发流程
|
|
81
|
+
|
|
82
|
+
1. 创建页面组件 (src/app/[locale])
|
|
83
|
+
2. 实现页面控制器
|
|
84
|
+
3. 添加API服务
|
|
85
|
+
4. 注册IOC容器
|
|
86
|
+
|
|
87
|
+
### 3. 最佳实践
|
|
88
|
+
|
|
89
|
+
#### 接口优先开发
|
|
90
|
+
|
|
91
|
+
- 先定义接口,再实现具体类
|
|
92
|
+
- 保持接口的单一职责
|
|
93
|
+
- 使用依赖注入管理依赖
|
|
94
|
+
|
|
95
|
+
#### 分层原则
|
|
96
|
+
|
|
97
|
+
- 保持层级间的清晰边界
|
|
98
|
+
- 通过接口进行层级间通信
|
|
99
|
+
- 避免跨层级直接调用
|
|
100
|
+
|
|
101
|
+
#### 状态管理
|
|
102
|
+
|
|
103
|
+
- 使用控制器管理复杂状态
|
|
104
|
+
- 保持状态的不可变性
|
|
105
|
+
- 统一的状态更新流程
|
|
106
|
+
|
|
107
|
+
## 核心功能文档
|
|
108
|
+
|
|
109
|
+
### 基础架构
|
|
110
|
+
|
|
111
|
+
- [项目结构说明](./project-structure.md)
|
|
112
|
+
- [开发规范指南](./development-guide.md)
|
|
113
|
+
- [环境配置指南](./env.md)
|
|
114
|
+
|
|
115
|
+
### 服务端开发
|
|
116
|
+
|
|
117
|
+
- [API开发指南](./api.md)
|
|
118
|
+
- [认证授权](./auth.md)
|
|
119
|
+
- [数据访问层](./database.md)
|
|
120
|
+
- [验证器开发](./validator.md)
|
|
121
|
+
|
|
122
|
+
### 客户端开发
|
|
123
|
+
|
|
124
|
+
- [页面开发指南](./page.md)
|
|
125
|
+
- [组件开发](./component.md)
|
|
126
|
+
|
|
127
|
+
### 功能模块
|
|
128
|
+
|
|
129
|
+
- [国际化开发](./i18n.md)
|
|
130
|
+
- [主题系统](./theme.md)
|
|
131
|
+
- [路由管理](./router.md)
|
|
132
|
+
|
|
133
|
+
## 常见问题
|
|
134
|
+
|
|
135
|
+
### 1. 开发环境配置
|
|
136
|
+
|
|
137
|
+
- Node.js >= 16
|
|
138
|
+
- pnpm >= 8.0
|
|
139
|
+
- 推荐使用 VSCode + 推荐插件
|
|
140
|
+
|
|
141
|
+
### 2. 开发相关
|
|
142
|
+
|
|
143
|
+
- 接口设计规范
|
|
144
|
+
- 依赖注入使用
|
|
145
|
+
- 控制器开发规范
|
|
146
|
+
|
|
147
|
+
### 3. 部署相关
|
|
148
|
+
|
|
149
|
+
- 环境变量配置
|
|
150
|
+
- 构建优化
|
|
151
|
+
- 部署流程
|
|
152
|
+
|
|
153
|
+
## 更新日志
|
|
154
|
+
|
|
155
|
+
查看 [CHANGELOG.md](../../CHANGELOG.md) 了解详细的更新历史。
|
|
156
|
+
|
|
157
|
+
## 支持和帮助
|
|
158
|
+
|
|
159
|
+
- 提交 Issue
|
|
160
|
+
- 查看 Wiki
|
|
161
|
+
- 参与讨论
|
|
162
|
+
|
|
163
|
+
## 许可证
|
|
164
|
+
|
|
165
|
+
本项目基于 [ISC 许可证](../../LICENSE) 开源。
|