@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,19 +1,19 @@
|
|
|
1
1
|
# FE-React Template
|
|
2
2
|
|
|
3
|
-
A modern React frontend project template with
|
|
3
|
+
A modern React frontend project template integrated with multiple practical features and best practices.
|
|
4
4
|
|
|
5
5
|
[中文](./README.md)
|
|
6
6
|
|
|
7
|
-
## 🌟
|
|
7
|
+
## 🌟 Highlights
|
|
8
8
|
|
|
9
|
-
- 🚀 Fast development experience
|
|
9
|
+
- 🚀 Fast development experience based on Vite
|
|
10
10
|
- 🎨 Theme system integrated with Tailwind CSS
|
|
11
|
-
- 🌍
|
|
11
|
+
- 🌍 Complete internationalization support (Chinese and English)
|
|
12
12
|
- 🔄 TypeScript-based IOC container
|
|
13
13
|
- 📡 Unified API request handling
|
|
14
|
-
- 🎮 Controller pattern
|
|
15
|
-
- 📦 Package management
|
|
16
|
-
- 🧪 Built-in
|
|
14
|
+
- 🎮 Controller pattern state management
|
|
15
|
+
- 📦 Package management using pnpm
|
|
16
|
+
- 🧪 Built-in testing support
|
|
17
17
|
|
|
18
18
|
## 🔧 Requirements
|
|
19
19
|
|
|
@@ -23,14 +23,14 @@ A modern React frontend project template with integrated practical features and
|
|
|
23
23
|
## 📁 Project Structure
|
|
24
24
|
|
|
25
25
|
```tree
|
|
26
|
-
├── config/ # Configuration directory
|
|
27
|
-
│ ├── app.router.json #
|
|
26
|
+
├── config/ # Configuration files directory
|
|
27
|
+
│ ├── app.router.json # Route page configuration
|
|
28
28
|
│ ├── common.ts # Application common configuration
|
|
29
|
-
│ ├── app.router.json #
|
|
30
|
-
│ ├── i18n.ts #
|
|
29
|
+
│ ├── app.router.json # Route configuration
|
|
30
|
+
│ ├── i18n.ts # Internationalization configuration
|
|
31
31
|
│ └── theme.json # Theme configuration
|
|
32
32
|
├── lib/ # Common library directory
|
|
33
|
-
├── public/ # Static
|
|
33
|
+
├── public/ # Static assets directory
|
|
34
34
|
├── src/
|
|
35
35
|
│ ├── base/ # Base code
|
|
36
36
|
│ ├── core/ # Core code
|
|
@@ -63,51 +63,69 @@ pnpm build
|
|
|
63
63
|
### Run Tests
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
+
# Run unit tests
|
|
66
67
|
pnpm test
|
|
68
|
+
|
|
69
|
+
# Run E2E tests
|
|
70
|
+
pnpm test:e2e
|
|
71
|
+
|
|
72
|
+
# Run E2E tests (UI mode)
|
|
73
|
+
pnpm test:e2e:ui
|
|
67
74
|
```
|
|
68
75
|
|
|
69
76
|
## 📚 Documentation Guide
|
|
70
77
|
|
|
71
78
|
The project provides detailed development documentation covering all major features and best practices:
|
|
72
79
|
|
|
73
|
-
###
|
|
74
|
-
|
|
75
|
-
- [Project
|
|
76
|
-
- [Development Guide](./docs/en/development-guide.md) -
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
- [
|
|
82
|
-
- [
|
|
83
|
-
- [
|
|
84
|
-
- [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
- [
|
|
89
|
-
- [
|
|
90
|
-
- [
|
|
80
|
+
### 🚀 Getting Started
|
|
81
|
+
|
|
82
|
+
- **[📖 Project Documentation](./docs/en/index.md)** - Architecture overview, core concepts, and complete documentation navigation
|
|
83
|
+
- **[Development Guide](./docs/en/development-guide.md)** - 📝 Complete page development process
|
|
84
|
+
|
|
85
|
+
### 🎯 Core Features
|
|
86
|
+
|
|
87
|
+
- **[Bootstrap Initializer](./docs/en/bootstrap.md)** - ⚡ Application startup and initialization
|
|
88
|
+
- **[IOC Container](./docs/en/ioc.md)** - 🔌 Dependency injection and UI separation
|
|
89
|
+
- **[Store State Management](./docs/en/store.md)** - 📡 How the application layer notifies the UI layer
|
|
90
|
+
- **[Environment Variable Management](./docs/en/env.md)** - ⚙️ Multi-environment configuration
|
|
91
|
+
- **[Internationalization](./docs/en/i18n.md)** - 🌍 i18n Key and translation management
|
|
92
|
+
|
|
93
|
+
### 🧪 Testing Documentation
|
|
94
|
+
|
|
95
|
+
- **[Playwright E2E Testing](./docs/en/playwright/)** - 🎭 Complete end-to-end testing documentation
|
|
96
|
+
- [Overview](./docs/en/playwright/overview.md)
|
|
97
|
+
- [Quick Start](./docs/en/playwright/quickstart.md)
|
|
98
|
+
- [Testing Guide](./docs/en/playwright/testing-guide.md)
|
|
99
|
+
- [Setup Complete](./docs/en/playwright/setup-complete.md)
|
|
100
|
+
- [Unit Testing Guide](./docs/en/test-guide.md) - Vitest unit testing
|
|
101
|
+
|
|
102
|
+
### 📖 Additional Documentation
|
|
103
|
+
|
|
104
|
+
- [Why Disable Global Variables](./docs/en/why-no-globals.md) - Global variable usage guidelines
|
|
105
|
+
- [Route Management](./docs/en/router.md) - Route configuration instructions
|
|
106
|
+
- [Theme System](./docs/en/theme.md) - Theme configuration and switching
|
|
107
|
+
- [Request Handling](./docs/en/request.md) - API request handling
|
|
108
|
+
- [TypeScript Guide](./docs/en/typescript-guide.md) - TypeScript conventions
|
|
91
109
|
|
|
92
110
|
## 🔨 Core Features
|
|
93
111
|
|
|
94
112
|
### IOC Container
|
|
95
113
|
|
|
96
114
|
- TypeScript-based dependency injection system
|
|
97
|
-
-
|
|
98
|
-
-
|
|
115
|
+
- Supports automatic service registration and dependency management
|
|
116
|
+
- Provides complete type inference
|
|
99
117
|
|
|
100
118
|
### Environment Configuration
|
|
101
119
|
|
|
102
|
-
[Vite Environment Variables and Modes](https://
|
|
120
|
+
[Vite Environment Variables and Modes](https://cn.vite.dev/guide/env-and-mode#env-variables-and-modes)
|
|
103
121
|
|
|
104
|
-
`vite dev`
|
|
122
|
+
`vite dev` defaults NODE_ENV to development, it will load possible `.env[mode]` files, such as .env.local -> .env
|
|
105
123
|
|
|
106
|
-
`vite build`
|
|
124
|
+
`vite build` defaults NODE_ENV to production, it will load possible `.env[mode]` files, such as .env.production -> .env
|
|
107
125
|
|
|
108
126
|
Node.js NODE_ENV only supports development, production, test
|
|
109
127
|
|
|
110
|
-
This is completely different from mode in vite
|
|
128
|
+
This is completely different from mode in vite, mode can specify different modes through `--mode` to load different env configurations
|
|
111
129
|
|
|
112
130
|
For example:
|
|
113
131
|
|
|
@@ -118,21 +136,21 @@ vite dev --mode local # Load .env.local
|
|
|
118
136
|
|
|
119
137
|
### Internationalization Support
|
|
120
138
|
|
|
121
|
-
- Complete
|
|
122
|
-
-
|
|
123
|
-
- Automatic
|
|
139
|
+
- Complete internationalization solution based on i18next
|
|
140
|
+
- Supports Chinese (zh) and English (en) bilingual switching
|
|
141
|
+
- Automatic internationalization resource generation based on TypeScript comments
|
|
124
142
|
- URL path language detection and switching
|
|
125
|
-
- Built-in language
|
|
143
|
+
- Built-in language switching component
|
|
126
144
|
|
|
127
145
|
### Theme System
|
|
128
146
|
|
|
129
147
|
- Theme configuration based on Tailwind CSS
|
|
130
|
-
-
|
|
148
|
+
- Supports dark/light mode
|
|
131
149
|
- Custom design token system
|
|
132
150
|
|
|
133
151
|
### API Integration
|
|
134
152
|
|
|
135
|
-
The project provides a powerful API request handling mechanism based on a plugin architecture:
|
|
153
|
+
The project provides a powerful API request handling mechanism based on a plugin architecture design:
|
|
136
154
|
|
|
137
155
|
#### Request Controller
|
|
138
156
|
|
|
@@ -182,24 +200,24 @@ Provides multiple out-of-the-box controllers:
|
|
|
182
200
|
|
|
183
201
|
## 🛠️ Development Guide
|
|
184
202
|
|
|
185
|
-
### API Development
|
|
203
|
+
### API Development Specifications
|
|
186
204
|
|
|
187
205
|
1. Define interfaces in `src/base/apis`
|
|
188
|
-
2. Support
|
|
206
|
+
2. Support Mock data configuration
|
|
189
207
|
|
|
190
|
-
### Adding New Pages
|
|
208
|
+
### Adding New Pages Process
|
|
191
209
|
|
|
192
|
-
1. Create page
|
|
210
|
+
1. Create page components in `src/pages`
|
|
193
211
|
2. Update `config/app.router.json`
|
|
194
212
|
3. Add corresponding controller (if needed)
|
|
195
213
|
|
|
196
214
|
### Build Optimization
|
|
197
215
|
|
|
198
|
-
The project uses Vite for building and
|
|
216
|
+
The project uses Vite for building and has been optimized with the following:
|
|
199
217
|
|
|
200
218
|
#### Code Splitting
|
|
201
219
|
|
|
202
|
-
Automatic intelligent code splitting into the following main chunks:
|
|
220
|
+
Automatic intelligent code splitting, dividing code into the following main chunks:
|
|
203
221
|
|
|
204
222
|
- react-vendor: React core library
|
|
205
223
|
- antd-core: Ant Design core components
|
|
@@ -214,7 +232,7 @@ Automatic intelligent code splitting into the following main chunks:
|
|
|
214
232
|
build: {
|
|
215
233
|
// Chunk size warning limit set to 600kb
|
|
216
234
|
chunkSizeWarningLimit: 600,
|
|
217
|
-
// Use terser for code
|
|
235
|
+
// Use terser for code minification
|
|
218
236
|
minify: 'terser',
|
|
219
237
|
terserOptions: {
|
|
220
238
|
compress: {
|
|
@@ -234,18 +252,18 @@ build: {
|
|
|
234
252
|
|
|
235
253
|
- Use `@qlover/corekit-bridge/vite-env-config` to manage environment variables
|
|
236
254
|
- Automatically inject application name and version information
|
|
237
|
-
- Support
|
|
255
|
+
- Support environment variable prefix configuration
|
|
238
256
|
|
|
239
257
|
#### Style Configuration
|
|
240
258
|
|
|
241
|
-
-
|
|
242
|
-
-
|
|
259
|
+
- Integrated with Tailwind CSS
|
|
260
|
+
- On-demand loading of Ant Design component styles
|
|
243
261
|
- Support theme mode override
|
|
244
262
|
|
|
245
263
|
#### Development Server
|
|
246
264
|
|
|
247
265
|
```bash
|
|
248
|
-
# Default port 3200,
|
|
266
|
+
# Default port 3200, can be configured via environment variables
|
|
249
267
|
VITE_SERVER_PORT=3000 pnpm dev
|
|
250
268
|
```
|
|
251
269
|
|
|
@@ -254,4 +272,3 @@ VITE_SERVER_PORT=3000 pnpm dev
|
|
|
254
272
|
- Use Vitest for unit testing
|
|
255
273
|
- Support JSDOM environment
|
|
256
274
|
- Built-in test tool configuration
|
|
257
|
-
```
|
|
@@ -63,31 +63,48 @@ pnpm build
|
|
|
63
63
|
### 运行测试
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
+
# 运行单元测试
|
|
66
67
|
pnpm test
|
|
68
|
+
|
|
69
|
+
# 运行 E2E 测试
|
|
70
|
+
pnpm test:e2e
|
|
71
|
+
|
|
72
|
+
# 运行 E2E 测试(UI 模式)
|
|
73
|
+
pnpm test:e2e:ui
|
|
67
74
|
```
|
|
68
75
|
|
|
69
76
|
## 📚 文档指南
|
|
70
77
|
|
|
71
78
|
项目提供了详细的开发文档,涵盖了所有主要功能和最佳实践:
|
|
72
79
|
|
|
73
|
-
###
|
|
74
|
-
|
|
75
|
-
- [
|
|
76
|
-
- [开发指南](./docs/zh/development-guide.md) -
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
- [
|
|
82
|
-
- [
|
|
83
|
-
- [
|
|
84
|
-
- [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
- [
|
|
89
|
-
- [
|
|
90
|
-
- [
|
|
80
|
+
### 🚀 快速上手
|
|
81
|
+
|
|
82
|
+
- **[📖 项目文档](./docs/zh/index.md)** - 架构概览、核心理念和完整文档导航
|
|
83
|
+
- **[开发指南](./docs/zh/development-guide.md)** - 📝 完整的页面开发流程
|
|
84
|
+
|
|
85
|
+
### 🎯 核心功能
|
|
86
|
+
|
|
87
|
+
- **[Bootstrap 启动器](./docs/zh/bootstrap.md)** - ⚡ 应用启动和初始化
|
|
88
|
+
- **[IOC 容器](./docs/zh/ioc.md)** - 🔌 依赖注入和 UI 分离
|
|
89
|
+
- **[Store 状态管理](./docs/zh/store.md)** - 📡 应用层如何通知 UI 层
|
|
90
|
+
- **[环境变量管理](./docs/zh/env.md)** - ⚙️ 多环境配置
|
|
91
|
+
- **[国际化](./docs/zh/i18n.md)** - 🌍 i18n Key 和翻译管理
|
|
92
|
+
|
|
93
|
+
### 🧪 测试文档
|
|
94
|
+
|
|
95
|
+
- **[Playwright E2E 测试](./docs/zh/playwright/)** - 🎭 端到端测试完整文档
|
|
96
|
+
- [快速入门](./docs/zh/playwright/quickstart.md)
|
|
97
|
+
- [详细测试指南](./docs/zh/playwright/testing-guide.md)
|
|
98
|
+
- [设置完成指南](./docs/zh/playwright/setup-complete.md)
|
|
99
|
+
- [单元测试指南](./docs/zh/test-guide.md) - Vitest 单元测试
|
|
100
|
+
|
|
101
|
+
### 📖 辅助文档
|
|
102
|
+
|
|
103
|
+
- [为什么要禁用全局变量](./docs/zh/why-no-globals.md) - 全局变量使用规范
|
|
104
|
+
- [路由管理](./docs/zh/router.md) - 路由配置说明
|
|
105
|
+
- [主题系统](./docs/zh/theme.md) - 主题配置和切换
|
|
106
|
+
- [请求处理](./docs/zh/request.md) - API 请求处理
|
|
107
|
+
- [TypeScript 指南](./docs/zh/typescript-guide.md) - TypeScript 规范
|
|
91
108
|
|
|
92
109
|
## 🔨 核心功能
|
|
93
110
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BootstrapClientArgs } from '@/core/bootstraps/BootstrapClient';
|
|
2
|
+
import { BootstrapClient } from '@/core/bootstraps/BootstrapClient';
|
|
3
|
+
import { testIOC } from './testIOC/TestIOC';
|
|
4
|
+
|
|
5
|
+
export interface BootstrapTestArgs extends Omit<BootstrapClientArgs, 'ioc'> {
|
|
6
|
+
ioc?: BootstrapClientArgs['ioc'];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class BootstrapTest {
|
|
10
|
+
static async main(args: BootstrapTestArgs): Promise<BootstrapClientArgs> {
|
|
11
|
+
const result = await BootstrapClient.main({ ...args, ioc: testIOC });
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InteractionHubInterface } from '@/base/port/InteractionHubInterface';
|
|
2
|
-
import { AntdStaticApiInterface } from '@brain-toolkit/antd-theme-override/react';
|
|
3
1
|
import { vi } from 'vitest';
|
|
2
|
+
import type { InteractionHubInterface } from '@/base/port/InteractionHubInterface';
|
|
3
|
+
import type { AntdStaticApiInterface } from '@brain-toolkit/antd-theme-override/react';
|
|
4
4
|
|
|
5
5
|
export class MockDialogHandler
|
|
6
6
|
implements InteractionHubInterface, AntdStaticApiInterface
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TestBootstrapsProvider } from './TestBootstrapsProvider';
|
|
2
|
+
|
|
3
|
+
interface TestAppProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Initial URL path for the router
|
|
7
|
+
* @default ['/en/']
|
|
8
|
+
*/
|
|
9
|
+
routerInitialEntries?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Initial index of the entries array
|
|
12
|
+
* @default 0
|
|
13
|
+
*/
|
|
14
|
+
routerInitialIndex?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* TestApp - Complete test wrapper with IOC and Router
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { TestApp } from '__tests__/__mocks__/components/TestApp';
|
|
23
|
+
*
|
|
24
|
+
* render(
|
|
25
|
+
* <TestApp routerInitialEntries={['/en/dashboard']}>
|
|
26
|
+
* <YourComponent />
|
|
27
|
+
* </TestApp>
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function TestApp({
|
|
32
|
+
children,
|
|
33
|
+
routerInitialEntries,
|
|
34
|
+
routerInitialIndex
|
|
35
|
+
}: TestAppProps) {
|
|
36
|
+
return (
|
|
37
|
+
<TestBootstrapsProvider
|
|
38
|
+
data-testid="TestApp"
|
|
39
|
+
routerInitialEntries={routerInitialEntries}
|
|
40
|
+
routerInitialIndex={routerInitialIndex}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
</TestBootstrapsProvider>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IOCContext } from '@/uikit/contexts/IOCContext';
|
|
2
|
+
import { TestRouter } from './TestRouter';
|
|
3
|
+
import { testIOC } from '../testIOC/TestIOC';
|
|
4
|
+
|
|
5
|
+
export function TestBootstrapsProvider({
|
|
6
|
+
children,
|
|
7
|
+
routerInitialEntries,
|
|
8
|
+
routerInitialIndex
|
|
9
|
+
}: {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Initial URL path for the router
|
|
13
|
+
* @default ['/en/']
|
|
14
|
+
*/
|
|
15
|
+
routerInitialEntries?: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Initial index of the entries array
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
routerInitialIndex?: number;
|
|
21
|
+
}) {
|
|
22
|
+
const IOC = testIOC.create();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<IOCContext.Provider data-testid="TestBootstrapsProvider" value={IOC}>
|
|
26
|
+
<TestRouter
|
|
27
|
+
initialEntries={routerInitialEntries}
|
|
28
|
+
initialIndex={routerInitialIndex}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</TestRouter>
|
|
32
|
+
</IOCContext.Provider>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface TestRouterProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Initial URL path for the router
|
|
8
|
+
* @default '/en/'
|
|
9
|
+
*/
|
|
10
|
+
initialEntries?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Initial index of the entries array
|
|
13
|
+
* @default 0
|
|
14
|
+
*/
|
|
15
|
+
initialIndex?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* TestRouter - A reusable router wrapper for tests
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { TestRouter } from '__tests__/__mocks__/components/TestRouter';
|
|
24
|
+
*
|
|
25
|
+
* render(
|
|
26
|
+
* <TestRouter initialEntries={['/en/dashboard']}>
|
|
27
|
+
* <YourComponent />
|
|
28
|
+
* </TestRouter>
|
|
29
|
+
* );
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function TestRouter({
|
|
33
|
+
children,
|
|
34
|
+
initialEntries = ['/en/'],
|
|
35
|
+
initialIndex = 0
|
|
36
|
+
}: TestRouterProps) {
|
|
37
|
+
return (
|
|
38
|
+
<MemoryRouter
|
|
39
|
+
data-testid="TestRouter"
|
|
40
|
+
initialEntries={initialEntries}
|
|
41
|
+
initialIndex={initialIndex}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</MemoryRouter>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Components - Reusable test wrappers
|
|
3
|
+
*
|
|
4
|
+
* These components provide common test infrastructure:
|
|
5
|
+
* - TestRouter: Provides React Router context
|
|
6
|
+
* - TestBootstrapsProvider: Provides IOC context + Router
|
|
7
|
+
* - TestApp: Complete test wrapper (IOC + Router)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { TestRouter } from './TestRouter';
|
|
11
|
+
export { TestBootstrapsProvider } from './TestBootstrapsProvider';
|
|
12
|
+
export { TestApp } from './TestApp';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { vi } from 'vitest';
|
|
2
|
-
import { MockLogger } from './MockLogger';
|
|
3
2
|
import { MockAppConfig } from './MockAppConfit';
|
|
4
3
|
import { MockDialogHandler } from './MockDialogHandler';
|
|
4
|
+
import { MockLogger } from './MockLogger';
|
|
5
5
|
|
|
6
6
|
export function createMockGlobals() {
|
|
7
7
|
const mockLogger = new MockLogger();
|
|
@@ -16,7 +16,6 @@ export function createMockGlobals() {
|
|
|
16
16
|
parse: vi.fn((data) => JSON.parse(data))
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
19
|
const storageOptions: Record<string, any> = {
|
|
21
20
|
localStorage: {},
|
|
22
21
|
cookieStorage: {},
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createIOCFunction } from '@qlover/corekit-bridge';
|
|
2
|
+
import { InversifyContainer } from '@/base/cases/InversifyContainer';
|
|
3
|
+
import type {
|
|
4
|
+
IOCInterface,
|
|
5
|
+
IocRegisterOptions
|
|
6
|
+
} from '@/base/port/IOCInterface';
|
|
7
|
+
import type { IOCIdentifierMap } from '@config/IOCIdentifier';
|
|
8
|
+
import { TestIOCRegister } from './TestIOCRegister';
|
|
9
|
+
import type {
|
|
10
|
+
IOCContainerInterface,
|
|
11
|
+
IOCFunctionInterface
|
|
12
|
+
} from '@qlover/corekit-bridge';
|
|
13
|
+
|
|
14
|
+
export class TestIOC
|
|
15
|
+
implements IOCInterface<IOCIdentifierMap, IOCContainerInterface>
|
|
16
|
+
{
|
|
17
|
+
protected ioc: IOCFunctionInterface<
|
|
18
|
+
IOCIdentifierMap,
|
|
19
|
+
IOCContainerInterface
|
|
20
|
+
> | null = null;
|
|
21
|
+
|
|
22
|
+
getIoc(): IOCFunctionInterface<
|
|
23
|
+
IOCIdentifierMap,
|
|
24
|
+
IOCContainerInterface
|
|
25
|
+
> | null {
|
|
26
|
+
return this.ioc;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
create(
|
|
30
|
+
options: IocRegisterOptions
|
|
31
|
+
): IOCFunctionInterface<IOCIdentifierMap, IOCContainerInterface> {
|
|
32
|
+
if (this.ioc) {
|
|
33
|
+
return this.ioc;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.ioc = createIOCFunction<IOCIdentifierMap>(new InversifyContainer());
|
|
37
|
+
|
|
38
|
+
// move to BootstrapClient
|
|
39
|
+
const register = new TestIOCRegister(options);
|
|
40
|
+
// const register = new ClientIOCRegister({
|
|
41
|
+
// pathname: '/en/test',
|
|
42
|
+
// appConfig: appConfig
|
|
43
|
+
// });
|
|
44
|
+
|
|
45
|
+
register.register(this.ioc.implemention!, this.ioc);
|
|
46
|
+
|
|
47
|
+
return this.ioc;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const testIOC = new TestIOC();
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { baseNoLocaleRoutes, baseRoutes } from '@config/app.router';
|
|
2
|
+
import { useLocaleRoutes } from '@config/common';
|
|
3
|
+
import { I } from '@config/IOCIdentifier';
|
|
4
|
+
import { themeConfig } from '@config/theme';
|
|
5
|
+
import { ThemeService } from '@qlover/corekit-bridge';
|
|
6
|
+
import type { IocRegisterOptions } from '@/base/port/IOCInterface';
|
|
7
|
+
import { I18nService } from '@/base/services/I18nService';
|
|
8
|
+
import { RouteService } from '@/base/services/RouteService';
|
|
9
|
+
import * as globals from '@/core/globals';
|
|
10
|
+
import { NavigateBridge } from '@/uikit/bridges/NavigateBridge';
|
|
11
|
+
import type {
|
|
12
|
+
IOCContainerInterface,
|
|
13
|
+
IOCManagerInterface,
|
|
14
|
+
IOCRegisterInterface,
|
|
15
|
+
ThemeServiceProps
|
|
16
|
+
} from '@qlover/corekit-bridge';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* TestIOCRegister - Register mock services for testing
|
|
20
|
+
*/
|
|
21
|
+
export class TestIOCRegister
|
|
22
|
+
implements IOCRegisterInterface<IOCContainerInterface, IocRegisterOptions>
|
|
23
|
+
{
|
|
24
|
+
constructor(protected options: IocRegisterOptions) {}
|
|
25
|
+
|
|
26
|
+
protected registerGlobals(ioc: IOCContainerInterface): void {
|
|
27
|
+
const { appConfig, dialogHandler, localStorageEncrypt, JSON, logger } =
|
|
28
|
+
globals;
|
|
29
|
+
|
|
30
|
+
ioc.bind(I.JSONSerializer, JSON);
|
|
31
|
+
ioc.bind(I.Logger, logger);
|
|
32
|
+
ioc.bind(I.AppConfig, appConfig);
|
|
33
|
+
ioc.bind(I.EnvConfigInterface, appConfig);
|
|
34
|
+
ioc.bind(I.DialogHandler, dialogHandler);
|
|
35
|
+
ioc.bind(I.UIDialogInterface, dialogHandler);
|
|
36
|
+
ioc.bind(I.AntdStaticApiInterface, dialogHandler);
|
|
37
|
+
ioc.bind(I.LocalStorage, globals.localStorage);
|
|
38
|
+
ioc.bind(I.LocalStorageEncrypt, localStorageEncrypt);
|
|
39
|
+
ioc.bind(I.CookieStorage, globals.cookieStorage);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
register(
|
|
43
|
+
ioc: IOCContainerInterface,
|
|
44
|
+
_manager: IOCManagerInterface<IOCContainerInterface>
|
|
45
|
+
): void {
|
|
46
|
+
this.registerGlobals(ioc);
|
|
47
|
+
|
|
48
|
+
ioc.bind(I.I18nServiceInterface, new I18nService(this.options.pathname));
|
|
49
|
+
ioc.bind(
|
|
50
|
+
I.RouteServiceInterface,
|
|
51
|
+
new RouteService(
|
|
52
|
+
ioc.get(NavigateBridge),
|
|
53
|
+
ioc.get(I.I18nServiceInterface),
|
|
54
|
+
{
|
|
55
|
+
routes: useLocaleRoutes ? baseRoutes : baseNoLocaleRoutes,
|
|
56
|
+
logger: ioc.get(I.Logger),
|
|
57
|
+
hasLocalRoutes: useLocaleRoutes
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
ioc.bind(
|
|
62
|
+
I.ThemeService,
|
|
63
|
+
new ThemeService({
|
|
64
|
+
...(themeConfig as unknown as ThemeServiceProps),
|
|
65
|
+
storage: ioc.get(I.LocalStorage)
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|