@qlover/create-app 0.7.15 → 0.9.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 +21 -0
- package/dist/configs/_common/.github/workflows/general-check.yml +1 -1
- package/dist/configs/_common/.github/workflows/release.yml +2 -2
- 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 +0 -1
- package/dist/templates/next-app/README.md +0 -1
- 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/index.md +0 -1
- package/dist/templates/next-app/docs/en/project-structure.md +0 -1
- package/dist/templates/next-app/docs/zh/index.md +0 -1
- package/dist/templates/next-app/docs/zh/project-structure.md +0 -1
- 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/__tests__/src/uikit/components/chatMessage/ChatRoot.test.tsx +274 -0
- package/dist/templates/react-app/config/IOCIdentifier.ts +11 -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/components/component.chatMessage.ts +56 -0
- package/dist/templates/react-app/config/Identifier/components/component.messageBaseList.ts +103 -0
- package/dist/templates/react-app/config/Identifier/index.ts +1 -9
- package/dist/templates/react-app/config/Identifier/pages/index.ts +9 -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/pages/page.message.ts +20 -0
- 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 +81 -61
- 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/chatMessageI18n.ts +17 -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/messageBaseListI18n.ts +22 -0
- package/dist/templates/react-app/config/i18n/messageI18n.ts +14 -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/components/chat-message-component.md +314 -0
- package/dist/templates/react-app/docs/en/components/chat-message-refactor.md +270 -0
- package/dist/templates/react-app/docs/en/components/message-base-list-component.md +172 -0
- 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/components/chat-message-component.md +314 -0
- package/dist/templates/react-app/docs/zh/components/chat-message-refactor.md +270 -0
- package/dist/templates/react-app/docs/zh/components/message-base-list-component.md +172 -0
- 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 +233 -179
- package/dist/templates/react-app/public/locales/zh/common.json +233 -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/MessagePage.tsx +40 -0
- 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/MessageBaseList.tsx +240 -0
- 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/components/chatMessage/ChatMessageBridge.ts +176 -0
- package/dist/templates/react-app/src/uikit/components/chatMessage/ChatRoot.tsx +21 -0
- package/dist/templates/react-app/src/uikit/components/chatMessage/FocusBar.tsx +106 -0
- package/dist/templates/react-app/src/uikit/components/chatMessage/MessageApi.ts +271 -0
- package/dist/templates/react-app/src/uikit/components/chatMessage/MessageItem.tsx +102 -0
- package/dist/templates/react-app/src/uikit/components/chatMessage/MessagesList.tsx +86 -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/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
|
@@ -1,173 +1,786 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 项目架构设计
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **📖 本文档是项目的入口文档,提供架构概览、核心概念和完整的文档导航。**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 📋 目录
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- [快速开始](#-快速开始)
|
|
8
|
+
- [架构概览](#-架构概览)
|
|
9
|
+
- [分层架构](#-分层架构)
|
|
10
|
+
- [完整的工作流程](#-完整的工作流程)
|
|
11
|
+
- [核心概念](#-核心概念)
|
|
12
|
+
- [快速示例](#-快速示例)
|
|
13
|
+
- [详细文档导航](#-详细文档导航)
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
- 🎨 **主题定制**:支持动态主题切换,深色模式
|
|
11
|
-
- 🌍 **国际化**:内置多语言支持
|
|
12
|
-
- 📦 **状态管理**:基于发布订阅的响应式状态管理
|
|
13
|
-
- 🔑 **认证系统**:完整的用户认证解决方案
|
|
14
|
-
- 🛠️ **开发工具**:ESLint、Prettier、TypeScript
|
|
15
|
-
- 📱 **响应式设计**:支持多端适配
|
|
16
|
-
- 🧪 **测试支持**:集成单元测试和组件测试
|
|
15
|
+
---
|
|
17
16
|
|
|
18
|
-
## 快速开始
|
|
17
|
+
## 🚀 快速开始
|
|
18
|
+
|
|
19
|
+
### 新手开发者
|
|
20
|
+
|
|
21
|
+
如果你是第一次接触本项目,建议按以下顺序:
|
|
22
|
+
|
|
23
|
+
1. **阅读本文档** - 了解整体架构和核心理念(10-15 分钟)
|
|
24
|
+
2. **[IOC 容器](./ioc.md)** - 理解 UI 和逻辑分离(10-15 分钟)
|
|
25
|
+
3. **[Store 状态管理](./store.md)** - 理解应用层如何通知 UI 层(10-15 分钟)
|
|
26
|
+
4. **[开发指南](./development-guide.md)** - 跟随完整示例开发一个页面(20-30 分钟)
|
|
27
|
+
|
|
28
|
+
### 有经验的开发者
|
|
29
|
+
|
|
30
|
+
如果你已经有相关经验,可以直接:
|
|
31
|
+
|
|
32
|
+
1. 快速浏览本文档了解架构特点
|
|
33
|
+
2. 查看 [开发指南](./development-guide.md) 了解开发流程
|
|
34
|
+
3. 按需查阅各专题文档
|
|
35
|
+
|
|
36
|
+
### 环境准备
|
|
19
37
|
|
|
20
38
|
```bash
|
|
21
39
|
# 安装依赖
|
|
22
|
-
|
|
40
|
+
pnpm install
|
|
23
41
|
|
|
24
42
|
# 启动开发服务器
|
|
25
|
-
|
|
43
|
+
pnpm dev
|
|
44
|
+
|
|
45
|
+
# 启动测试环境
|
|
46
|
+
pnpm dev:staging
|
|
26
47
|
|
|
27
48
|
# 构建生产版本
|
|
28
|
-
|
|
49
|
+
pnpm build
|
|
50
|
+
|
|
51
|
+
# 运行测试
|
|
52
|
+
pnpm test
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 🎯 架构概览
|
|
58
|
+
|
|
59
|
+
本项目采用**分层架构 + 依赖注入 + 面向接口编程**的设计模式。
|
|
60
|
+
|
|
61
|
+
### 架构全景图
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
┌─────────────────────────────────────────────────────┐
|
|
65
|
+
│ 配置层 (Config Layer) │
|
|
66
|
+
│ • 所有配置统一管理 │
|
|
67
|
+
| (路由、主题、i18n、IOC 等) │
|
|
68
|
+
│ • 环境变量注入目标 |
|
|
69
|
+
| (AppConfig.ts) │
|
|
70
|
+
│ 📄 详见:env.md │
|
|
71
|
+
└─────────────────────────────────────────────────────┘
|
|
72
|
+
↓
|
|
73
|
+
┌─────────────────────────────────────────────────────┐
|
|
74
|
+
│ 入口层 (Entry Layer) │
|
|
75
|
+
│ • main.tsx: 应用启动 │
|
|
76
|
+
│ • 注入全局依赖(window, document 等) │
|
|
77
|
+
│ • 初始化 IOC 容器 │
|
|
78
|
+
│ • 执行 Bootstrap 启动流程 │
|
|
79
|
+
│ 📄 详见:bootstrap.md │
|
|
80
|
+
└─────────────────────────────────────────────────────┘
|
|
81
|
+
↓
|
|
82
|
+
┌─────────────────────────────────────────────────────┐
|
|
83
|
+
│ 核心层 (Core Layer) │
|
|
84
|
+
│ • globals.ts: 封装浏览器 API │
|
|
85
|
+
│ • clientIoc/: IOC 容器管理 │
|
|
86
|
+
│ • bootstraps/: Bootstrap 启动流程 │
|
|
87
|
+
│ 📄 详见:why-no-globals.md │
|
|
88
|
+
└─────────────────────────────────────────────────────┘
|
|
89
|
+
↓
|
|
90
|
+
┌─────────────────────────────────────────────────────┐
|
|
91
|
+
│ 业务层 (Business Layer) │
|
|
92
|
+
│ • port/: 接口定义 (Interface) │
|
|
93
|
+
│ • services/: 服务实现 │
|
|
94
|
+
│ • cases/: 业务用例 │
|
|
95
|
+
│ • apis/: 外部 API 适配 │
|
|
96
|
+
│ 📄 详见:ioc.md │
|
|
97
|
+
└─────────────────────────────────────────────────────┘
|
|
98
|
+
↓
|
|
99
|
+
┌─────────────────────────────────────────────────────┐
|
|
100
|
+
│ UI 层 (UI Layer) │
|
|
101
|
+
│ • pages/: 页面组件 │
|
|
102
|
+
│ • components/: UI 组件 │
|
|
103
|
+
│ • hooks/: React Hooks (useIOC, useStore 等) │
|
|
104
|
+
│ • bridges/: 页面桥接 │
|
|
105
|
+
│ 📄 详见:store.md │
|
|
106
|
+
└─────────────────────────────────────────────────────┘
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 核心原则
|
|
110
|
+
|
|
111
|
+
1. **单向依赖** ↓ - 只能从上往下依赖,不能反向
|
|
112
|
+
2. **依赖接口不依赖实现** 🔌 - 所有依赖都通过 Interface 定义
|
|
113
|
+
3. **UI 与逻辑分离** 🎨 - UI 就是 UI,逻辑就是逻辑
|
|
114
|
+
4. **单一职责** 📦 - 每个模块只做一件事
|
|
115
|
+
5. **配置驱动** ⚙️ - 业务逻辑由配置驱动
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🏗️ 分层架构
|
|
120
|
+
|
|
121
|
+
### 1. 配置层 (Config Layer)
|
|
122
|
+
|
|
123
|
+
**位置:** `config/`, `src/base/cases/AppConfig.ts`
|
|
124
|
+
|
|
125
|
+
**职责:**
|
|
126
|
+
|
|
127
|
+
- 统一管理所有配置(路由、主题、i18n、IOC 标识符等)
|
|
128
|
+
- 作为环境变量的注入目标
|
|
129
|
+
|
|
130
|
+
**文件结构:**
|
|
131
|
+
|
|
29
132
|
```
|
|
133
|
+
config/
|
|
134
|
+
├── common.ts # 公共配置
|
|
135
|
+
├── theme.ts # 主题配置
|
|
136
|
+
├── app.router.ts # 路由配置
|
|
137
|
+
├── IOCIdentifier.ts # IOC 标识符
|
|
138
|
+
├── i18n/ # 国际化配置
|
|
139
|
+
└── Identifier/ # 业务标识符
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**👉 详见:** [环境变量管理文档](./env.md)
|
|
30
143
|
|
|
31
|
-
|
|
144
|
+
### 2. 入口层 (Entry Layer)
|
|
32
145
|
|
|
33
|
-
|
|
146
|
+
**位置:** `src/main.tsx`, `src/core/bootstraps/`
|
|
34
147
|
|
|
35
|
-
|
|
36
|
-
- [开发规范指南](./development-guide.md)
|
|
37
|
-
- [构建部署指南](./deployment.md)
|
|
148
|
+
**职责:**
|
|
38
149
|
|
|
39
|
-
|
|
150
|
+
- 应用启动
|
|
151
|
+
- 注入全局依赖(浏览器 API)
|
|
152
|
+
- 创建 IOC 容器
|
|
153
|
+
- 执行 Bootstrap 启动流程
|
|
40
154
|
|
|
41
|
-
|
|
42
|
-
- [状态管理指南](./store.md)
|
|
43
|
-
- [国际化开发指南](./i18n.md)
|
|
44
|
-
- [主题开发指南](./theme.md)
|
|
45
|
-
- [请求系统指南](./request.md)
|
|
155
|
+
**关键特点:**
|
|
46
156
|
|
|
47
|
-
|
|
157
|
+
- 🔴 **唯一允许直接访问全局变量的地方**
|
|
158
|
+
- 🔴 **Bootstrap 在应用渲染前执行所有初始化**
|
|
48
159
|
|
|
49
|
-
|
|
50
|
-
- [TypeScript 开发规范](./typescript-guide.md)
|
|
51
|
-
- [样式开发指南](./styling-guide.md)
|
|
160
|
+
**👉 详见:** [Bootstrap 启动器文档](./bootstrap.md)
|
|
52
161
|
|
|
53
|
-
###
|
|
162
|
+
### 3. 核心层 (Core Layer)
|
|
54
163
|
|
|
55
|
-
|
|
56
|
-
- [Git 工作流指南](./git-workflow.md)
|
|
57
|
-
- [性能优化指南](./performance.md)
|
|
164
|
+
**位置:** `src/core/`
|
|
58
165
|
|
|
59
|
-
|
|
166
|
+
**职责:**
|
|
60
167
|
|
|
61
|
-
-
|
|
62
|
-
-
|
|
168
|
+
- 封装浏览器 API(localStorage、cookie 等)
|
|
169
|
+
- 管理全局实例(logger、dialog 等)
|
|
170
|
+
- IOC 容器初始化和服务注册
|
|
171
|
+
- Bootstrap 流程控制
|
|
63
172
|
|
|
64
|
-
|
|
173
|
+
**文件结构:**
|
|
65
174
|
|
|
66
175
|
```
|
|
67
|
-
|
|
68
|
-
├──
|
|
69
|
-
├──
|
|
70
|
-
├──
|
|
71
|
-
├──
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
├──
|
|
75
|
-
└──
|
|
176
|
+
core/
|
|
177
|
+
├── globals.ts # 全局变量封装
|
|
178
|
+
├── IOC.ts # IOC 工具
|
|
179
|
+
├── bootstraps/ # 启动流程
|
|
180
|
+
│ ├── BootstrapClient.ts
|
|
181
|
+
│ └── BootstrapsRegistry.ts
|
|
182
|
+
└── clientIoc/ # IOC 容器
|
|
183
|
+
├── ClientIOC.ts
|
|
184
|
+
└── ClientIOCRegister.ts
|
|
76
185
|
```
|
|
77
186
|
|
|
78
|
-
|
|
187
|
+
**👉 详见:** [为什么要禁用全局变量文档](./why-no-globals.md)
|
|
79
188
|
|
|
80
|
-
###
|
|
189
|
+
### 4. 业务层 (Business Layer)
|
|
81
190
|
|
|
82
|
-
|
|
191
|
+
**位置:** `src/base/`
|
|
192
|
+
|
|
193
|
+
**职责:**
|
|
194
|
+
|
|
195
|
+
- 定义业务接口(Port)
|
|
196
|
+
- 实现业务服务(Services)
|
|
197
|
+
- 处理业务逻辑(Cases)
|
|
198
|
+
- 适配外部 API(APIs)
|
|
199
|
+
|
|
200
|
+
**文件结构:**
|
|
83
201
|
|
|
84
202
|
```
|
|
85
|
-
|
|
203
|
+
base/
|
|
204
|
+
├── port/ # 接口定义
|
|
205
|
+
│ ├── UserServiceInterface.ts
|
|
206
|
+
│ └── I18nServiceInterface.ts
|
|
207
|
+
├── services/ # 服务实现
|
|
208
|
+
│ ├── UserService.ts
|
|
209
|
+
│ └── I18nService.ts
|
|
210
|
+
├── cases/ # 业务用例
|
|
211
|
+
│ ├── AppConfig.ts
|
|
212
|
+
│ └── AppError.ts
|
|
213
|
+
└── apis/ # API 适配器
|
|
214
|
+
└── userApi/
|
|
215
|
+
├── UserApi.ts
|
|
216
|
+
└── UserApiType.ts
|
|
86
217
|
```
|
|
87
218
|
|
|
88
|
-
|
|
219
|
+
**关键特点:**
|
|
220
|
+
|
|
221
|
+
- 🔵 **面向接口** - 所有依赖通过接口注入
|
|
222
|
+
- 🔵 **单一职责** - 每个服务只负责一个领域
|
|
223
|
+
- 🔵 **可测试性** - 易于 mock 和测试
|
|
224
|
+
|
|
225
|
+
**👉 详见:** [IOC 容器文档](./ioc.md)
|
|
226
|
+
|
|
227
|
+
### 5. UI 层 (UI Layer)
|
|
228
|
+
|
|
229
|
+
**位置:** `src/pages/`, `src/uikit/`
|
|
230
|
+
|
|
231
|
+
**职责:**
|
|
232
|
+
|
|
233
|
+
- 渲染页面和组件
|
|
234
|
+
- 处理用户交互
|
|
235
|
+
- 通过 `useIOC` 获取服务
|
|
236
|
+
- 通过 `useStore` 订阅状态
|
|
89
237
|
|
|
90
|
-
|
|
238
|
+
**文件结构:**
|
|
91
239
|
|
|
92
240
|
```
|
|
93
|
-
|
|
241
|
+
├── pages/ # 页面组件
|
|
242
|
+
│ ├── base/
|
|
243
|
+
│ └── auth/
|
|
244
|
+
└── uikit/ # UI 工具
|
|
245
|
+
├── components/ # 公共组件
|
|
246
|
+
├── hooks/ # React Hooks
|
|
247
|
+
│ ├── useIOC.ts # IOC Hook
|
|
248
|
+
│ └── useStore.ts # Store Hook
|
|
249
|
+
├── contexts/ # React Context
|
|
250
|
+
└── bridges/ # 页面桥接
|
|
94
251
|
```
|
|
95
252
|
|
|
96
|
-
|
|
253
|
+
**关键特点:**
|
|
254
|
+
|
|
255
|
+
- 🟢 **不直接依赖实现** - 通过 IOC 获取服务
|
|
256
|
+
- 🟢 **UI 和逻辑分离** - 只处理渲染和交互
|
|
257
|
+
- 🟢 **响应式更新** - 通过 Store 自动更新
|
|
258
|
+
|
|
259
|
+
**👉 详见:** [Store 状态管理文档](./store.md)
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## 🔄 完整的工作流程
|
|
264
|
+
|
|
265
|
+
### 数据流向图
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
┌─────────────────────────────────────────────┐
|
|
269
|
+
│ 1. 用户交互(UI 层) │
|
|
270
|
+
│ const userService = useIOC('UserService') │
|
|
271
|
+
│ userService.login(username, password) │
|
|
272
|
+
└──────────────────┬──────────────────────────┘
|
|
273
|
+
↓ (通过 IOC 调用服务)
|
|
274
|
+
┌─────────────────────────────────────────────┐
|
|
275
|
+
│ 2. 服务层处理(Business 层) │
|
|
276
|
+
│ async login(username, password) { │
|
|
277
|
+
│ const response = await this.api.login() │
|
|
278
|
+
│ this.storage.setItem('token', ...) │
|
|
279
|
+
│ this.emit({ user: ... }) // 通知 UI │
|
|
280
|
+
│ } │
|
|
281
|
+
└──────────────┬─────────────┬────────────────┘
|
|
282
|
+
↓ ↓ (调用 API)
|
|
283
|
+
(使用 Storage) ┌─────────────────────┐
|
|
284
|
+
↓ │ 3. API 层 │
|
|
285
|
+
┌──────────────┐ │ POST /api/login │
|
|
286
|
+
│ Core/Globals │ └─────────────────────┘
|
|
287
|
+
│ localStorage │ ↓
|
|
288
|
+
└──────────────┘ (HTTP 请求)
|
|
289
|
+
↓ ↓
|
|
290
|
+
(数据持久化) (后端服务器)
|
|
291
|
+
↓ ↓
|
|
292
|
+
└────←── 返回数据 ←┘
|
|
293
|
+
↓
|
|
294
|
+
(emit 发布新状态)
|
|
295
|
+
↓
|
|
296
|
+
┌─────────────────────────┐
|
|
297
|
+
│ 4. Store 通知订阅者 │
|
|
298
|
+
│ listeners.forEach(...) │
|
|
299
|
+
└─────────────────────────┘
|
|
300
|
+
↓
|
|
301
|
+
┌─────────────────────────┐
|
|
302
|
+
│ 5. UI 自动更新 │
|
|
303
|
+
│ useStore 收到通知 │
|
|
304
|
+
│ 组件重新渲染 │
|
|
305
|
+
└─────────────────────────┘
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### 应用启动流程
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
1️⃣ main.tsx
|
|
312
|
+
↓
|
|
313
|
+
2️⃣ BootstrapClient.main()
|
|
314
|
+
├── 创建 IOC 容器
|
|
315
|
+
├── 注册所有服务
|
|
316
|
+
├── 执行 Bootstrap 插件
|
|
317
|
+
│ ├── InjectEnv (注入环境变量到 AppConfig)
|
|
318
|
+
│ ├── I18nService.onBefore() (初始化 i18n)
|
|
319
|
+
│ ├── UserService.onBefore() (检查用户登录)
|
|
320
|
+
│ └── ProcesserExecutor.startup() (启动处理器)
|
|
321
|
+
└── Bootstrap 完成
|
|
322
|
+
↓
|
|
323
|
+
3️⃣ React 应用渲染
|
|
324
|
+
├── App.tsx
|
|
325
|
+
├── IOCContext.Provider (提供 IOC 容器)
|
|
326
|
+
└── AppRouterProvider (路由)
|
|
327
|
+
↓
|
|
328
|
+
4️⃣ 页面组件渲染
|
|
329
|
+
├── useIOC() 获取服务
|
|
330
|
+
├── useStore() 订阅状态
|
|
331
|
+
└── UI 渲染
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## 💡 核心概念
|
|
337
|
+
|
|
338
|
+
### 1. IOC 容器(依赖注入)⭐
|
|
339
|
+
|
|
340
|
+
**核心理念:** UI 就是 UI,逻辑就是逻辑,两者必须分离
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
// ❌ 传统方式:UI 和逻辑混在一起
|
|
344
|
+
function UserProfile() {
|
|
345
|
+
const [user, setUser] = useState(null);
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
fetch('/api/user').then(res => res.json()).then(setUser);
|
|
348
|
+
}, []);
|
|
349
|
+
return <div>{user?.name}</div>;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// ✅ IOC 方式:UI 和逻辑完全分离
|
|
353
|
+
function UserProfile() {
|
|
354
|
+
const userService = useIOC('UserServiceInterface'); // 获取服务
|
|
355
|
+
const { user } = useStore(userService); // 订阅状态
|
|
356
|
+
return <div>{user?.name}</div>;
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**关键问题:**
|
|
361
|
+
|
|
362
|
+
1. **为什么一个实现类也需要接口?** → 为了可测试性
|
|
363
|
+
2. **为什么简单组件也要分离?** → 现在简单不代表将来简单
|
|
364
|
+
|
|
365
|
+
**👉 详见:** [IOC 容器详细文档](./ioc.md)
|
|
366
|
+
|
|
367
|
+
### 2. Store 状态管理(应用层通知 UI 层)⭐
|
|
368
|
+
|
|
369
|
+
**核心理念:** Service 通过 Store 发布状态,UI 通过 useStore 订阅状态
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
// Service(应用层)
|
|
373
|
+
@injectable()
|
|
374
|
+
export class UserService extends StoreInterface<UserState> {
|
|
375
|
+
async login(username: string, password: string) {
|
|
376
|
+
this.emit({ loading: true }); // 发布:开始加载
|
|
377
|
+
const response = await this.api.login({ username, password });
|
|
378
|
+
this.emit({ user: response.user, loading: false }); // 发布:完成
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// UI(UI 层)
|
|
383
|
+
function LoginPage() {
|
|
384
|
+
const userService = useIOC('UserServiceInterface');
|
|
385
|
+
const { loading } = useStore(userService); // 订阅:自动更新
|
|
386
|
+
|
|
387
|
+
return (
|
|
388
|
+
<button onClick={() => userService.login('user', 'pass')} disabled={loading}>
|
|
389
|
+
{loading ? 'Logging in...' : 'Login'}
|
|
390
|
+
</button>
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**👉 详见:** [Store 状态管理详细文档](./store.md)
|
|
396
|
+
|
|
397
|
+
### 3. Bootstrap 启动器(应用初始化)⭐
|
|
398
|
+
|
|
399
|
+
**核心理念:** 在应用渲染前执行所有初始化逻辑
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
// Bootstrap 插件
|
|
403
|
+
export class I18nService implements BootstrapPlugin {
|
|
404
|
+
onBefore() {
|
|
405
|
+
// 在应用启动前初始化 i18n
|
|
406
|
+
i18n.init({
|
|
407
|
+
/* ... */
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Bootstrap 执行
|
|
413
|
+
const bootstrap = new Bootstrap({
|
|
414
|
+
root: window,
|
|
415
|
+
ioc: clientIOC
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
await bootstrap.initialize(); // 执行所有插件的 onBefore
|
|
419
|
+
await bootstrap.start(); // 启动应用
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
**👉 详见:** [Bootstrap 启动器详细文档](./bootstrap.md)
|
|
423
|
+
|
|
424
|
+
### 4. 环境变量管理(多环境配置)⭐
|
|
97
425
|
|
|
98
|
-
|
|
426
|
+
**核心理念:** 使用 `vite --mode` 切换环境,通过 Bootstrap 注入到 AppConfig
|
|
99
427
|
|
|
428
|
+
```bash
|
|
429
|
+
# 不同环境
|
|
430
|
+
npm run dev # 开发环境 (.env.localhost)
|
|
431
|
+
npm run dev:staging # 测试环境 (.env.staging)
|
|
432
|
+
npm run build # 生产环境 (.env.production)
|
|
100
433
|
```
|
|
101
|
-
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
// AppConfig 自动注入环境变量
|
|
437
|
+
export class AppConfig {
|
|
438
|
+
readonly env: string;
|
|
439
|
+
readonly apiBaseUrl = ''; // 自动从 VITE_API_BASE_URL 注入
|
|
440
|
+
readonly appName = ''; // 自动从 VITE_APP_NAME 注入
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// 使用
|
|
444
|
+
const config = useIOC(IOCIdentifier.AppConfig);
|
|
445
|
+
console.log(config.apiBaseUrl); // 根据环境自动切换
|
|
102
446
|
```
|
|
103
447
|
|
|
104
|
-
|
|
448
|
+
**👉 详见:** [环境变量管理详细文档](./env.md)
|
|
449
|
+
|
|
450
|
+
### 5. 国际化(i18n Key)⭐
|
|
105
451
|
|
|
106
|
-
|
|
452
|
+
**核心理念:** 所有文字都使用 i18n Key,绝不硬编码
|
|
107
453
|
|
|
454
|
+
```typescript
|
|
455
|
+
// ❌ 错误:硬编码文本
|
|
456
|
+
<button>登录</button>
|
|
457
|
+
|
|
458
|
+
// ✅ 正确:使用 i18n Key
|
|
459
|
+
import { BUTTON_LOGIN } from '@config/Identifier';
|
|
460
|
+
<button>{t(BUTTON_LOGIN)}</button>
|
|
108
461
|
```
|
|
109
|
-
|
|
462
|
+
|
|
463
|
+
**核心优势:** 开发者不需要记住 `'common:button.login'` 字符串,只需要知道 `BUTTON_LOGIN` 变量,IDE 会自动补全
|
|
464
|
+
|
|
465
|
+
**👉 详见:** [国际化详细文档](./i18n.md)
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## 📝 快速示例
|
|
470
|
+
|
|
471
|
+
### 示例:创建一个主题切换功能
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
// 1️⃣ 定义接口 (base/port/ThemeServiceInterface.ts)
|
|
475
|
+
export interface ThemeServiceInterface {
|
|
476
|
+
setTheme(theme: 'light' | 'dark'): void;
|
|
477
|
+
getTheme(): 'light' | 'dark';
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// 2️⃣ 实现服务 (base/services/ThemeService.ts)
|
|
481
|
+
@injectable()
|
|
482
|
+
export class ThemeService extends StoreInterface<ThemeState> {
|
|
483
|
+
constructor(
|
|
484
|
+
@inject(IOCIdentifier.LocalStorage) private storage: Storage
|
|
485
|
+
) {
|
|
486
|
+
super(() => ({ theme: 'light' }));
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
setTheme(theme: 'light' | 'dark') {
|
|
490
|
+
this.storage.setItem('theme', theme);
|
|
491
|
+
this.emit({ theme }); // 通知 UI 更新
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
getTheme() {
|
|
495
|
+
return this.state.theme;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// 3️⃣ 注册到 IOC (core/clientIoc/ClientIOCRegister.ts)
|
|
500
|
+
register(ioc: IOCContainer) {
|
|
501
|
+
ioc.bind(IOCIdentifier.ThemeServiceInterface, ThemeService);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// 4️⃣ UI 使用 (components/ThemeSwitcher.tsx)
|
|
505
|
+
function ThemeSwitcher() {
|
|
506
|
+
const themeService = useIOC('ThemeServiceInterface');
|
|
507
|
+
const { theme } = useStore(themeService);
|
|
508
|
+
|
|
509
|
+
return (
|
|
510
|
+
<button onClick={() => themeService.setTheme(theme === 'light' ? 'dark' : 'light')}>
|
|
511
|
+
{theme === 'light' ? '🌙 Dark' : '☀️ Light'}
|
|
512
|
+
</button>
|
|
513
|
+
);
|
|
514
|
+
}
|
|
110
515
|
```
|
|
111
516
|
|
|
112
|
-
|
|
517
|
+
**完整的开发流程请查看:** [开发指南](./development-guide.md)
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
## 📚 详细文档导航
|
|
522
|
+
|
|
523
|
+
### 核心文档 ⭐
|
|
524
|
+
|
|
525
|
+
#### 1. [开发指南](./development-guide.md)
|
|
526
|
+
|
|
527
|
+
**适合人群:** 准备开发新功能的开发者
|
|
528
|
+
**阅读时间:** 20-30 分钟
|
|
529
|
+
|
|
530
|
+
**内容概览:**
|
|
531
|
+
|
|
532
|
+
- 开发一个页面需要什么(8 项清单)
|
|
533
|
+
- 完整的 10 步开发流程
|
|
534
|
+
- 实战示例:用户列表页(完整代码)
|
|
535
|
+
- 常见场景(添加按钮、弹窗、搜索等)
|
|
536
|
+
- 代码规范和开发工具
|
|
537
|
+
|
|
538
|
+
**核心价值:** 手把手教你开发一个完整的页面
|
|
539
|
+
|
|
540
|
+
#### 2. [IOC 容器](./ioc.md)
|
|
541
|
+
|
|
542
|
+
**核心问题:** UI 和逻辑如何分离?为什么需要接口?
|
|
543
|
+
|
|
544
|
+
**关键内容:**
|
|
545
|
+
|
|
546
|
+
- 为什么需要 IOC(UI 和逻辑分离)
|
|
547
|
+
- 两个关键问题:
|
|
548
|
+
1. 为什么一个实现类也需要接口?(可测试性)
|
|
549
|
+
2. 为什么简单组件也要分离?(未来扩展性)
|
|
550
|
+
- 如何独立测试逻辑和 UI
|
|
551
|
+
- 如何组合测试
|
|
552
|
+
- 完整的实战示例
|
|
553
|
+
|
|
554
|
+
**适合场景:**
|
|
555
|
+
|
|
556
|
+
- 需要创建新的服务
|
|
557
|
+
- 需要理解依赖注入
|
|
558
|
+
- 需要编写可测试的代码
|
|
559
|
+
|
|
560
|
+
#### 3. [Store 状态管理](./store.md)
|
|
561
|
+
|
|
562
|
+
**核心问题:** 应用层(Service)如何通知 UI 层更新?
|
|
563
|
+
|
|
564
|
+
**关键内容:**
|
|
565
|
+
|
|
566
|
+
- 为什么需要 Store(解决通信问题)
|
|
567
|
+
- Service 通过 `emit` 发布状态
|
|
568
|
+
- UI 通过 `useStore` 订阅状态
|
|
569
|
+
- 选择器和性能优化
|
|
570
|
+
- 独立测试和组合测试
|
|
571
|
+
|
|
572
|
+
**适合场景:**
|
|
573
|
+
|
|
574
|
+
- Service 需要通知 UI 更新
|
|
575
|
+
- 需要实现响应式 UI
|
|
576
|
+
- 需要优化渲染性能
|
|
577
|
+
|
|
578
|
+
#### 4. [Bootstrap 启动器](./bootstrap.md)
|
|
579
|
+
|
|
580
|
+
**核心问题:** 应用如何初始化?为什么需要 Bootstrap?
|
|
581
|
+
|
|
582
|
+
**关键内容:**
|
|
583
|
+
|
|
584
|
+
- 什么是 Bootstrap(插件系统)
|
|
585
|
+
- 为什么需要 Bootstrap(问题驱动)
|
|
586
|
+
- Bootstrap 的核心优势(特别是测试)
|
|
587
|
+
- 完整的项目实现和示例
|
|
588
|
+
- Vitest 测试指南
|
|
589
|
+
|
|
590
|
+
**适合场景:**
|
|
591
|
+
|
|
592
|
+
- 需要在应用启动前执行初始化逻辑
|
|
593
|
+
- 需要理解应用启动流程
|
|
594
|
+
- 需要添加新的启动插件
|
|
595
|
+
|
|
596
|
+
#### 5. [环境变量管理](./env.md)
|
|
597
|
+
|
|
598
|
+
**核心问题:** 如何管理多环境配置?
|
|
599
|
+
|
|
600
|
+
**关键内容:**
|
|
601
|
+
|
|
602
|
+
- 使用 `vite --mode` 切换环境
|
|
603
|
+
- `.env` 文件管理和优先级
|
|
604
|
+
- AppConfig 自动注入机制
|
|
605
|
+
- Bootstrap 的 InjectEnv 插件
|
|
606
|
+
- 多环境配置示例
|
|
607
|
+
|
|
608
|
+
**适合场景:**
|
|
609
|
+
|
|
610
|
+
- 需要添加新的环境变量
|
|
611
|
+
- 需要切换开发/测试/生产环境
|
|
612
|
+
- 需要理解配置注入机制
|
|
613
|
+
|
|
614
|
+
#### 6. [国际化 (i18n)](./i18n.md)
|
|
113
615
|
|
|
114
|
-
|
|
115
|
-
- 理解业务需求
|
|
116
|
-
- 设计技术方案
|
|
117
|
-
- 评估开发周期
|
|
616
|
+
**核心问题:** 如何管理多语言文本?
|
|
118
617
|
|
|
119
|
-
|
|
120
|
-
- 遵循开发规范
|
|
121
|
-
- 编写单元测试
|
|
122
|
-
- 进行代码审查
|
|
618
|
+
**关键内容:**
|
|
123
619
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
620
|
+
- **核心原则:** 所有文字都使用 i18n Key,绝不硬编码
|
|
621
|
+
- **核心优势:** 减少开发者思考(不需要记字符串,只需记变量名)
|
|
622
|
+
- 自动生成翻译文件(ts2Locales)
|
|
623
|
+
- I18nService Bootstrap 插件
|
|
624
|
+
- 完整的使用示例
|
|
128
625
|
|
|
129
|
-
|
|
130
|
-
- 构建优化
|
|
131
|
-
- 部署配置
|
|
132
|
-
- 监控告警
|
|
626
|
+
**适合场景:**
|
|
133
627
|
|
|
134
|
-
|
|
628
|
+
- 需要添加新的文本
|
|
629
|
+
- 需要支持新语言
|
|
630
|
+
- 需要理解 i18n Key 概念
|
|
135
631
|
|
|
136
|
-
###
|
|
632
|
+
### 辅助文档
|
|
137
633
|
|
|
138
|
-
-
|
|
139
|
-
- 使用推荐的 IDE 配置
|
|
140
|
-
- 安装必要的开发工具
|
|
634
|
+
#### [为什么要禁用全局变量](./why-no-globals.md)
|
|
141
635
|
|
|
142
|
-
|
|
636
|
+
**核心问题:** 为什么不能直接使用 `window`、`document` 等?
|
|
143
637
|
|
|
144
|
-
|
|
145
|
-
- 性能优化建议
|
|
146
|
-
- 部署注意事项
|
|
638
|
+
**关键内容:**
|
|
147
639
|
|
|
148
|
-
|
|
640
|
+
- 核心理念:全局变量应该从入口注入
|
|
641
|
+
- 允许使用的位置:`main.tsx`、`core/globals.ts`
|
|
642
|
+
- 为什么需要这样做(测试、SSR、可追溯性)
|
|
643
|
+
- 实际应用场景(IOC 容器)
|
|
644
|
+
- 测试友好性对比
|
|
149
645
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
646
|
+
#### [路由管理](./router.md)
|
|
647
|
+
|
|
648
|
+
**核心内容:**
|
|
649
|
+
|
|
650
|
+
- 路由配置文件(`config/app.router.ts`)
|
|
651
|
+
- 路由元数据(title、requiresAuth 等)
|
|
652
|
+
- 动态路由加载
|
|
653
|
+
- RouteService 使用
|
|
654
|
+
|
|
655
|
+
#### [主题系统](./theme.md)
|
|
656
|
+
|
|
657
|
+
**核心内容:**
|
|
658
|
+
|
|
659
|
+
- Tailwind CSS 配置
|
|
660
|
+
- CSS 变量管理
|
|
661
|
+
- 主题切换实现
|
|
662
|
+
- ThemeService 使用
|
|
663
|
+
|
|
664
|
+
#### [请求处理](./request.md)
|
|
665
|
+
|
|
666
|
+
**核心内容:**
|
|
667
|
+
|
|
668
|
+
- API 适配器模式
|
|
669
|
+
- 请求插件系统
|
|
670
|
+
- 错误处理
|
|
671
|
+
- Mock 数据
|
|
672
|
+
|
|
673
|
+
#### [测试指南](./test-guide.md)
|
|
674
|
+
|
|
675
|
+
**核心内容:**
|
|
676
|
+
|
|
677
|
+
- Vitest 测试框架
|
|
678
|
+
- 服务测试(逻辑层)
|
|
679
|
+
- UI 测试(组件层)
|
|
680
|
+
- 集成测试(流程)
|
|
681
|
+
- 测试最佳实践
|
|
682
|
+
|
|
683
|
+
#### [TypeScript 指南](./typescript-guide.md)
|
|
684
|
+
|
|
685
|
+
**核心内容:**
|
|
686
|
+
|
|
687
|
+
- TypeScript 类型规范
|
|
688
|
+
- 泛型使用
|
|
689
|
+
- 类型推导
|
|
690
|
+
- 常见问题
|
|
691
|
+
|
|
692
|
+
---
|
|
693
|
+
|
|
694
|
+
## 🎯 快速查找
|
|
695
|
+
|
|
696
|
+
### 我想...
|
|
697
|
+
|
|
698
|
+
**开发一个新页面** → [开发指南](./development-guide.md)
|
|
699
|
+
|
|
700
|
+
**理解 UI 和逻辑分离** → [IOC 容器](./ioc.md)
|
|
701
|
+
|
|
702
|
+
**让 Service 通知 UI 更新** → [Store 状态管理](./store.md)
|
|
703
|
+
|
|
704
|
+
**添加环境变量** → [环境变量管理](./env.md)
|
|
705
|
+
|
|
706
|
+
**添加多语言文本** → [国际化](./i18n.md)
|
|
707
|
+
|
|
708
|
+
**在应用启动前执行初始化** → [Bootstrap 启动器](./bootstrap.md)
|
|
709
|
+
|
|
710
|
+
**封装浏览器 API** → [为什么要禁用全局变量](./why-no-globals.md)
|
|
711
|
+
|
|
712
|
+
**添加路由** → [路由管理](./router.md)
|
|
713
|
+
|
|
714
|
+
**切换主题** → [主题系统](./theme.md)
|
|
715
|
+
|
|
716
|
+
**调用 API** → [请求处理](./request.md)
|
|
717
|
+
|
|
718
|
+
**编写测试** → [测试指南](./test-guide.md)
|
|
719
|
+
|
|
720
|
+
**解决 TypeScript 问题** → [TypeScript 指南](./typescript-guide.md)
|
|
721
|
+
|
|
722
|
+
---
|
|
723
|
+
|
|
724
|
+
## 🎯 核心理念总结
|
|
725
|
+
|
|
726
|
+
| 理念 | 说明 | 收益 |
|
|
727
|
+
| ------------ | ------------------------- | ------------------ |
|
|
728
|
+
| **分层架构** | 清晰的职责划分 | 易于理解、易于维护 |
|
|
729
|
+
| **单向依赖** | 只能从上往下依赖 | 避免循环依赖 |
|
|
730
|
+
| **面向接口** | 依赖接口不依赖实现 | 易于测试、易于替换 |
|
|
731
|
+
| **依赖注入** | 由 IOC 容器管理依赖 | 解耦、可测试 |
|
|
732
|
+
| **UI 分离** | UI 就是 UI,逻辑就是逻辑 | 独立测试、可复用 |
|
|
733
|
+
| **状态管理** | Service emit,UI useStore | 自动更新、保持分离 |
|
|
734
|
+
| **单一职责** | 每个模块只做一件事 | 易于复用、易于维护 |
|
|
735
|
+
| **配置驱动** | 业务由配置驱动 | 灵活、易于扩展 |
|
|
736
|
+
|
|
737
|
+
---
|
|
738
|
+
|
|
739
|
+
## 🚦 开发流程
|
|
740
|
+
|
|
741
|
+
```
|
|
742
|
+
1. 定义 i18n Key (config/Identifier/)
|
|
743
|
+
↓
|
|
744
|
+
2. 定义接口 (base/port/)
|
|
745
|
+
↓
|
|
746
|
+
3. 实现服务 (base/services/)
|
|
747
|
+
↓
|
|
748
|
+
4. 实现 API(如需要) (base/apis/)
|
|
749
|
+
↓
|
|
750
|
+
5. 配置路由 (config/app.router.ts)
|
|
751
|
+
↓
|
|
752
|
+
6. 实现页面 (pages/)
|
|
753
|
+
├── useIOC() 获取服务
|
|
754
|
+
└── useStore() 订阅状态
|
|
755
|
+
↓
|
|
756
|
+
7. 注册 IOC(如果是新服务) (core/clientIoc/)
|
|
757
|
+
↓
|
|
758
|
+
8. 编写测试 (__tests__/)
|
|
759
|
+
├── 服务测试(逻辑)
|
|
760
|
+
├── UI 测试(渲染)
|
|
761
|
+
└── 集成测试(流程)
|
|
762
|
+
```
|
|
153
763
|
|
|
154
|
-
|
|
764
|
+
---
|
|
155
765
|
|
|
156
|
-
|
|
157
|
-
2. 创建特性分支
|
|
158
|
-
3. 提交变更
|
|
159
|
-
4. 发起 Pull Request
|
|
766
|
+
## 💡 开发建议
|
|
160
767
|
|
|
161
|
-
|
|
768
|
+
### 新手开发者
|
|
162
769
|
|
|
163
|
-
|
|
770
|
+
1. 先理解架构 - 阅读本文档
|
|
771
|
+
2. 了解 IOC - 阅读 [IOC 容器文档](./ioc.md)
|
|
772
|
+
3. 了解 Store - 阅读 [Store 文档](./store.md)
|
|
773
|
+
4. 看示例代码 - 参考现有的 `UserService`、`I18nService` 等
|
|
774
|
+
5. 动手实践 - 创建一个简单的功能
|
|
164
775
|
|
|
165
|
-
|
|
776
|
+
### 有经验的开发者
|
|
166
777
|
|
|
167
|
-
-
|
|
168
|
-
-
|
|
169
|
-
-
|
|
778
|
+
- **Bootstrap 机制** → [Bootstrap 文档](./bootstrap.md)
|
|
779
|
+
- **环境变量管理** → [环境变量文档](./env.md)
|
|
780
|
+
- **国际化实现** → [i18n 文档](./i18n.md)
|
|
781
|
+
- **全局变量规范** → [why-no-globals 文档](./why-no-globals.md)
|
|
170
782
|
|
|
171
|
-
|
|
783
|
+
---
|
|
172
784
|
|
|
173
|
-
|
|
785
|
+
**问题反馈:**
|
|
786
|
+
如果你对架构设计有任何疑问或建议,请在团队频道中讨论或提交 Issue。
|