@qlover/create-app 0.7.14 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (361) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/configs/_common/.gitignore.template +6 -0
  3. package/dist/configs/_common/.prettierignore +17 -5
  4. package/dist/configs/_common/.vscode/settings.json +6 -1
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/templates/next-app/.env.template +1 -1
  8. package/dist/templates/next-app/README.en.md +130 -0
  9. package/dist/templates/next-app/README.md +114 -20
  10. package/dist/templates/next-app/config/Identifier/api.ts +5 -5
  11. package/dist/templates/next-app/config/Identifier/common/admint.table.ts +69 -0
  12. package/dist/templates/next-app/config/Identifier/common/common.ts +76 -0
  13. package/dist/templates/next-app/config/Identifier/common/index.ts +3 -0
  14. package/dist/templates/next-app/config/Identifier/{validator.ts → common/validators.ts} +5 -5
  15. package/dist/templates/next-app/config/Identifier/index.ts +2 -12
  16. package/dist/templates/next-app/config/Identifier/pages/index.ts +6 -0
  17. package/dist/templates/next-app/config/Identifier/pages/page.admin.home.ts +27 -0
  18. package/dist/templates/next-app/config/Identifier/pages/page.admin.locales.ts +266 -0
  19. package/dist/templates/next-app/config/Identifier/pages/page.admin.user.ts +293 -0
  20. package/dist/templates/{react-app/config/Identifier → next-app/config/Identifier/pages}/page.home.ts +15 -22
  21. package/dist/templates/next-app/config/Identifier/{page.login.ts → pages/page.login.ts} +28 -34
  22. package/dist/templates/next-app/config/Identifier/{page.register.ts → pages/page.register.ts} +30 -29
  23. package/dist/templates/next-app/config/adminNavs.ts +19 -0
  24. package/dist/templates/next-app/config/common.ts +22 -13
  25. package/dist/templates/next-app/config/i18n/HomeI18n.ts +5 -5
  26. package/dist/templates/next-app/config/i18n/admin18n.ts +61 -19
  27. package/dist/templates/next-app/config/i18n/i18nConfig.ts +2 -0
  28. package/dist/templates/next-app/config/i18n/i18nKeyScheam.ts +36 -0
  29. package/dist/templates/next-app/config/i18n/loginI18n.ts +22 -22
  30. package/dist/templates/next-app/config/i18n/register18n.ts +23 -24
  31. package/dist/templates/next-app/docs/en/api.md +387 -0
  32. package/dist/templates/next-app/docs/en/component.md +544 -0
  33. package/dist/templates/next-app/docs/en/database.md +496 -0
  34. package/dist/templates/next-app/docs/en/development-guide.md +727 -0
  35. package/dist/templates/next-app/docs/en/env.md +563 -0
  36. package/dist/templates/next-app/docs/en/i18n.md +287 -0
  37. package/dist/templates/next-app/docs/en/index.md +165 -0
  38. package/dist/templates/next-app/docs/en/page.md +457 -0
  39. package/dist/templates/next-app/docs/en/project-structure.md +176 -0
  40. package/dist/templates/next-app/docs/en/router.md +427 -0
  41. package/dist/templates/next-app/docs/en/theme.md +532 -0
  42. package/dist/templates/next-app/docs/en/validator.md +478 -0
  43. package/dist/templates/next-app/docs/zh/api.md +387 -0
  44. package/dist/templates/next-app/docs/zh/component.md +544 -0
  45. package/dist/templates/next-app/docs/zh/database.md +496 -0
  46. package/dist/templates/next-app/docs/zh/development-guide.md +727 -0
  47. package/dist/templates/next-app/docs/zh/env.md +563 -0
  48. package/dist/templates/next-app/docs/zh/i18n.md +287 -0
  49. package/dist/templates/next-app/docs/zh/index.md +165 -0
  50. package/dist/templates/next-app/docs/zh/page.md +457 -0
  51. package/dist/templates/next-app/docs/zh/project-structure.md +176 -0
  52. package/dist/templates/next-app/docs/zh/router.md +427 -0
  53. package/dist/templates/next-app/docs/zh/theme.md +532 -0
  54. package/dist/templates/next-app/docs/zh/validator.md +476 -0
  55. package/dist/templates/next-app/make/generateLocales.ts +19 -12
  56. package/dist/templates/next-app/migrations/schema/LocalesSchema.ts +15 -0
  57. package/dist/templates/next-app/migrations/sql/1694244000000.sql +11 -0
  58. package/dist/templates/next-app/package.json +7 -3
  59. package/dist/templates/next-app/public/locales/en.json +172 -207
  60. package/dist/templates/next-app/public/locales/zh.json +172 -207
  61. package/dist/templates/next-app/src/app/[locale]/admin/locales/page.tsx +153 -0
  62. package/dist/templates/next-app/src/app/[locale]/admin/users/page.tsx +48 -50
  63. package/dist/templates/next-app/src/app/[locale]/login/LoginForm.tsx +2 -2
  64. package/dist/templates/next-app/src/app/api/admin/locales/create/route.ts +34 -0
  65. package/dist/templates/next-app/src/app/api/admin/locales/import/route.ts +40 -0
  66. package/dist/templates/next-app/src/app/api/admin/locales/route.ts +42 -0
  67. package/dist/templates/next-app/src/app/api/admin/locales/update/route.ts +32 -0
  68. package/dist/templates/next-app/src/app/api/locales/json/route.ts +44 -0
  69. package/dist/templates/next-app/src/base/cases/AdminPageManager.ts +1 -13
  70. package/dist/templates/next-app/src/base/cases/Datetime.ts +18 -0
  71. package/dist/templates/next-app/src/base/cases/DialogErrorPlugin.ts +12 -6
  72. package/dist/templates/next-app/src/base/cases/ResourceState.ts +17 -0
  73. package/dist/templates/next-app/src/base/cases/TranslateI18nInterface.ts +25 -0
  74. package/dist/templates/next-app/src/base/cases/ZodColumnBuilder.ts +200 -0
  75. package/dist/templates/next-app/src/base/port/ZodBuilderInterface.ts +8 -0
  76. package/dist/templates/next-app/src/base/services/AdminLocalesService.ts +20 -0
  77. package/dist/templates/next-app/src/base/services/AdminPageEvent.ts +26 -0
  78. package/dist/templates/next-app/src/base/services/AdminPageScheduler.ts +42 -0
  79. package/dist/templates/next-app/src/base/services/ResourceService.ts +122 -0
  80. package/dist/templates/next-app/src/base/services/adminApi/AdminLocalesApi.ts +104 -0
  81. package/dist/templates/next-app/src/base/services/adminApi/AdminUserApi.ts +38 -5
  82. package/dist/templates/next-app/src/base/services/appApi/AppApiPlugin.ts +1 -1
  83. package/dist/templates/next-app/src/i18n/request.ts +30 -1
  84. package/dist/templates/next-app/src/server/PageParams.ts +2 -10
  85. package/dist/templates/next-app/src/server/port/DBBridgeInterface.ts +5 -0
  86. package/dist/templates/next-app/src/server/port/DBTableInterface.ts +2 -0
  87. package/dist/templates/next-app/src/server/port/LocalesRepositoryInterface.ts +43 -0
  88. package/dist/templates/next-app/src/server/repositorys/LocalesRepository.ts +197 -0
  89. package/dist/templates/next-app/src/server/services/ApiLocaleService.ts +122 -0
  90. package/dist/templates/next-app/src/server/sqlBridges/SupabaseBridge.ts +60 -11
  91. package/dist/templates/next-app/src/server/validators/ExtendedExecutorError.ts +6 -0
  92. package/dist/templates/next-app/src/server/validators/LocalesValidator.ts +131 -0
  93. package/dist/templates/next-app/src/server/validators/LoginValidator.ts +2 -5
  94. package/dist/templates/next-app/src/server/validators/PaginationValidator.ts +32 -16
  95. package/dist/templates/next-app/src/styles/css/antd-themes/pagination/_default.css +2 -1
  96. package/dist/templates/next-app/src/styles/css/antd-themes/pagination/dark.css +28 -29
  97. package/dist/templates/next-app/src/styles/css/antd-themes/pagination/pink.css +2 -1
  98. package/dist/templates/next-app/src/uikit/components/AdminLayout.tsx +17 -3
  99. package/dist/templates/next-app/src/uikit/components/BaseHeader.tsx +5 -4
  100. package/dist/templates/next-app/src/uikit/components/BaseLayout.tsx +5 -4
  101. package/dist/templates/next-app/src/uikit/components/BootstrapsProvider.tsx +3 -2
  102. package/dist/templates/next-app/src/uikit/components/ComboProvider.tsx +1 -1
  103. package/dist/templates/next-app/src/uikit/components/EditableCell.tsx +118 -0
  104. package/dist/templates/next-app/src/uikit/components/LogoutButton.tsx +5 -6
  105. package/dist/templates/next-app/src/uikit/components/ThemeSwitcher.tsx +1 -1
  106. package/dist/templates/next-app/src/uikit/components/With.tsx +2 -2
  107. package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportButton.tsx +62 -0
  108. package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportEvent.ts +28 -0
  109. package/dist/templates/next-app/src/uikit/components/localesImportButton/import.module.css +6 -0
  110. package/dist/templates/next-app/src/uikit/hook/useI18nInterface.ts +8 -14
  111. package/dist/templates/next-app/src/uikit/hook/useWarnTranslations.ts +25 -0
  112. package/dist/templates/react-app/.prettierignore +17 -0
  113. package/dist/templates/react-app/README.en.md +71 -54
  114. package/dist/templates/react-app/README.md +35 -18
  115. package/dist/templates/react-app/__tests__/__mocks__/BootstrapTest.ts +14 -0
  116. package/dist/templates/react-app/__tests__/__mocks__/MockAppConfit.ts +1 -1
  117. package/dist/templates/react-app/__tests__/__mocks__/MockDialogHandler.ts +2 -2
  118. package/dist/templates/react-app/__tests__/__mocks__/MockLogger.ts +1 -1
  119. package/dist/templates/react-app/__tests__/__mocks__/components/TestApp.tsx +45 -0
  120. package/dist/templates/react-app/__tests__/__mocks__/components/TestBootstrapsProvider.tsx +34 -0
  121. package/dist/templates/react-app/__tests__/__mocks__/components/TestRouter.tsx +46 -0
  122. package/dist/templates/react-app/__tests__/__mocks__/components/index.ts +12 -0
  123. package/dist/templates/react-app/__tests__/__mocks__/createMockGlobals.ts +1 -2
  124. package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOC.ts +51 -0
  125. package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOCRegister.ts +69 -0
  126. package/dist/templates/react-app/__tests__/setup/index.ts +1 -51
  127. package/dist/templates/react-app/__tests__/setup/setupGlobal.ts +51 -0
  128. package/dist/templates/react-app/__tests__/src/App.structure.test.tsx +115 -0
  129. package/dist/templates/react-app/__tests__/src/base/cases/AppConfig.test.ts +2 -2
  130. package/dist/templates/react-app/__tests__/src/base/cases/AppError.test.ts +1 -1
  131. package/dist/templates/react-app/__tests__/src/base/cases/DialogHandler.test.ts +3 -5
  132. package/dist/templates/react-app/__tests__/src/base/cases/I18nKeyErrorPlugin.test.ts +13 -2
  133. package/dist/templates/react-app/__tests__/src/base/cases/InversifyContainer.test.ts +1 -1
  134. package/dist/templates/react-app/__tests__/src/base/cases/PublicAssetsPath.test.ts +1 -1
  135. package/dist/templates/react-app/__tests__/src/base/cases/RequestLogger.test.ts +5 -5
  136. package/dist/templates/react-app/__tests__/src/base/cases/RequestStatusCatcher.test.ts +1 -2
  137. package/dist/templates/react-app/__tests__/src/base/cases/RouterLoader.test.ts +25 -15
  138. package/dist/templates/react-app/__tests__/src/base/services/I18nService.test.ts +29 -15
  139. package/dist/templates/react-app/__tests__/src/core/IOC.test.ts +19 -9
  140. package/dist/templates/react-app/__tests__/src/core/bootstraps/BootstrapClient.test.ts +153 -0
  141. package/dist/templates/react-app/__tests__/src/core/bootstraps/BootstrapsApp.test.ts +9 -7
  142. package/dist/templates/react-app/__tests__/src/main.integration.test.tsx +4 -5
  143. package/dist/templates/react-app/__tests__/src/main.test.tsx +4 -4
  144. package/dist/templates/react-app/__tests__/src/uikit/components/BaseHeader.test.tsx +68 -59
  145. package/dist/templates/react-app/config/IOCIdentifier.ts +8 -8
  146. package/dist/templates/react-app/config/Identifier/{common.error.ts → common/common.error.ts} +5 -5
  147. package/dist/templates/react-app/config/Identifier/{common.ts → common/common.ts} +9 -9
  148. package/dist/templates/react-app/config/Identifier/common/index.ts +2 -0
  149. package/dist/templates/react-app/config/Identifier/index.ts +1 -9
  150. package/dist/templates/react-app/config/Identifier/pages/index.ts +8 -0
  151. package/dist/templates/react-app/config/Identifier/{page.about.ts → pages/page.about.ts} +34 -26
  152. package/dist/templates/react-app/config/Identifier/{page.executor.ts → pages/page.executor.ts} +47 -39
  153. package/dist/templates/{next-app/config/Identifier → react-app/config/Identifier/pages}/page.home.ts +24 -23
  154. package/dist/templates/react-app/config/Identifier/pages/page.identifiter.ts +102 -0
  155. package/dist/templates/react-app/config/Identifier/{page.jsonStorage.ts → pages/page.jsonStorage.ts} +18 -11
  156. package/dist/templates/react-app/config/Identifier/{page.login.ts → pages/page.login.ts} +37 -27
  157. package/dist/templates/react-app/config/Identifier/{page.register.ts → pages/page.register.ts} +37 -25
  158. package/dist/templates/react-app/config/Identifier/{page.request.ts → pages/page.request.ts} +34 -44
  159. package/dist/templates/react-app/config/app.router.ts +66 -69
  160. package/dist/templates/react-app/config/i18n/PageI18nInterface.ts +51 -0
  161. package/dist/templates/react-app/config/i18n/aboutI18n.ts +42 -0
  162. package/dist/templates/react-app/config/i18n/executorI18n.ts +51 -0
  163. package/dist/templates/react-app/config/i18n/homeI18n.ts +24 -0
  164. package/dist/templates/react-app/config/i18n/i18nConfig.ts +30 -0
  165. package/dist/templates/react-app/config/i18n/identifiter18n.ts +30 -0
  166. package/dist/templates/react-app/config/i18n/jsonStorage18n.ts +27 -0
  167. package/dist/templates/react-app/config/i18n/login18n.ts +42 -0
  168. package/dist/templates/react-app/config/i18n/notFoundI18n.ts +34 -0
  169. package/dist/templates/react-app/config/i18n/register18n.ts +40 -0
  170. package/dist/templates/react-app/config/i18n/request18n.ts +41 -0
  171. package/dist/templates/react-app/config/theme.ts +14 -4
  172. package/dist/templates/react-app/docs/en/bootstrap.md +1670 -341
  173. package/dist/templates/react-app/docs/en/development-guide.md +1021 -345
  174. package/dist/templates/react-app/docs/en/env.md +1132 -278
  175. package/dist/templates/react-app/docs/en/i18n.md +858 -147
  176. package/dist/templates/react-app/docs/en/index.md +733 -104
  177. package/dist/templates/react-app/docs/en/ioc.md +1228 -287
  178. package/dist/templates/react-app/docs/en/playwright/e2e-tests.md +321 -0
  179. package/dist/templates/react-app/docs/en/playwright/index.md +19 -0
  180. package/dist/templates/react-app/docs/en/playwright/installation-summary.md +332 -0
  181. package/dist/templates/react-app/docs/en/playwright/overview.md +222 -0
  182. package/dist/templates/react-app/docs/en/playwright/quickstart.md +325 -0
  183. package/dist/templates/react-app/docs/en/playwright/reorganization-notes.md +340 -0
  184. package/dist/templates/react-app/docs/en/playwright/setup-complete.md +290 -0
  185. package/dist/templates/react-app/docs/en/playwright/testing-guide.md +565 -0
  186. package/dist/templates/react-app/docs/en/store.md +1194 -184
  187. package/dist/templates/react-app/docs/en/why-no-globals.md +797 -0
  188. package/dist/templates/react-app/docs/zh/bootstrap.md +1670 -341
  189. package/dist/templates/react-app/docs/zh/development-guide.md +1021 -345
  190. package/dist/templates/react-app/docs/zh/env.md +1132 -275
  191. package/dist/templates/react-app/docs/zh/i18n.md +858 -147
  192. package/dist/templates/react-app/docs/zh/index.md +717 -104
  193. package/dist/templates/react-app/docs/zh/ioc.md +1229 -287
  194. package/dist/templates/react-app/docs/zh/playwright/e2e-tests.md +321 -0
  195. package/dist/templates/react-app/docs/zh/playwright/index.md +19 -0
  196. package/dist/templates/react-app/docs/zh/playwright/installation-summary.md +332 -0
  197. package/dist/templates/react-app/docs/zh/playwright/overview.md +222 -0
  198. package/dist/templates/react-app/docs/zh/playwright/quickstart.md +325 -0
  199. package/dist/templates/react-app/docs/zh/playwright/reorganization-notes.md +340 -0
  200. package/dist/templates/react-app/docs/zh/playwright/setup-complete.md +290 -0
  201. package/dist/templates/react-app/docs/zh/playwright/testing-guide.md +565 -0
  202. package/dist/templates/react-app/docs/zh/store.md +1192 -184
  203. package/dist/templates/react-app/docs/zh/why-no-globals.md +797 -0
  204. package/dist/templates/react-app/e2e/App.spec.ts +319 -0
  205. package/dist/templates/react-app/e2e/fixtures/base.fixture.ts +40 -0
  206. package/dist/templates/react-app/e2e/main.spec.ts +20 -0
  207. package/dist/templates/react-app/e2e/utils/test-helpers.ts +19 -0
  208. package/dist/templates/react-app/eslint.config.mjs +247 -0
  209. package/dist/templates/react-app/makes/eslint-utils.mjs +195 -0
  210. package/dist/templates/react-app/makes/generateTs2LocalesOptions.ts +26 -0
  211. package/dist/templates/react-app/package.json +31 -3
  212. package/dist/templates/react-app/playwright.config.ts +79 -0
  213. package/dist/templates/react-app/public/locales/en/common.json +190 -179
  214. package/dist/templates/react-app/public/locales/zh/common.json +190 -179
  215. package/dist/templates/react-app/src/App.tsx +15 -42
  216. package/dist/templates/react-app/src/base/apis/AiApi.ts +5 -5
  217. package/dist/templates/react-app/src/base/apis/feApi/FeApi.ts +1 -1
  218. package/dist/templates/react-app/src/base/apis/feApi/FeApiAdapter.ts +1 -1
  219. package/dist/templates/react-app/src/base/apis/feApi/FeApiBootstarp.ts +8 -8
  220. package/dist/templates/react-app/src/base/apis/feApi/FeApiType.ts +1 -1
  221. package/dist/templates/react-app/src/base/apis/userApi/UserApi.ts +6 -6
  222. package/dist/templates/react-app/src/base/apis/userApi/UserApiAdapter.ts +1 -1
  223. package/dist/templates/react-app/src/base/apis/userApi/UserApiBootstarp.ts +12 -14
  224. package/dist/templates/react-app/src/base/apis/userApi/UserApiType.ts +1 -1
  225. package/dist/templates/react-app/src/base/cases/DialogHandler.ts +5 -2
  226. package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +3 -3
  227. package/dist/templates/react-app/src/base/cases/InversifyContainer.ts +3 -3
  228. package/dist/templates/react-app/src/base/cases/RequestLanguages.ts +2 -2
  229. package/dist/templates/react-app/src/base/cases/RequestLogger.ts +4 -4
  230. package/dist/templates/react-app/src/base/cases/RequestStatusCatcher.ts +1 -1
  231. package/dist/templates/react-app/src/base/cases/ResourceState.ts +23 -0
  232. package/dist/templates/react-app/src/base/cases/RouterLoader.ts +4 -4
  233. package/dist/templates/react-app/src/base/cases/TranslateI18nInterface.ts +26 -0
  234. package/dist/templates/react-app/src/base/port/ExecutorPageBridgeInterface.ts +2 -3
  235. package/dist/templates/react-app/src/base/port/I18nServiceInterface.ts +1 -1
  236. package/dist/templates/react-app/src/base/port/IOCInterface.ts +36 -0
  237. package/dist/templates/react-app/src/base/port/JSONStoragePageBridgeInterface.ts +2 -1
  238. package/dist/templates/react-app/src/base/port/ProcesserExecutorInterface.ts +1 -1
  239. package/dist/templates/react-app/src/base/port/RequestPageBridgeInterface.ts +2 -2
  240. package/dist/templates/react-app/src/base/port/RouteServiceInterface.ts +9 -5
  241. package/dist/templates/react-app/src/base/port/UserServiceInterface.ts +1 -1
  242. package/dist/templates/react-app/src/base/services/I18nService.ts +29 -29
  243. package/dist/templates/react-app/src/base/services/IdentifierService.ts +143 -0
  244. package/dist/templates/react-app/src/base/services/ProcesserExecutor.ts +3 -3
  245. package/dist/templates/react-app/src/base/services/RouteService.ts +27 -8
  246. package/dist/templates/react-app/src/base/services/UserService.ts +8 -8
  247. package/dist/templates/react-app/src/base/types/Page.ts +14 -2
  248. package/dist/templates/react-app/src/base/types/global.d.ts +1 -1
  249. package/dist/templates/react-app/src/core/IOC.ts +5 -46
  250. package/dist/templates/react-app/src/core/bootstraps/{BootstrapApp.ts → BootstrapClient.ts} +44 -17
  251. package/dist/templates/react-app/src/core/bootstraps/BootstrapsRegistry.ts +14 -7
  252. package/dist/templates/react-app/src/core/bootstraps/IocIdentifierTest.ts +1 -1
  253. package/dist/templates/react-app/src/core/bootstraps/PrintBootstrap.ts +1 -1
  254. package/dist/templates/react-app/src/core/clientIoc/ClientIOC.ts +40 -0
  255. package/dist/templates/react-app/src/core/{IocRegisterImpl.ts → clientIoc/ClientIOCRegister.ts} +35 -24
  256. package/dist/templates/react-app/src/core/globals.ts +9 -9
  257. package/dist/templates/react-app/src/main.tsx +4 -4
  258. package/dist/templates/react-app/src/pages/404.tsx +6 -3
  259. package/dist/templates/react-app/src/pages/500.tsx +5 -2
  260. package/dist/templates/react-app/src/pages/NoRouteFound.tsx +5 -0
  261. package/dist/templates/react-app/src/pages/auth/Layout.tsx +9 -6
  262. package/dist/templates/react-app/src/pages/auth/LoginPage.tsx +46 -56
  263. package/dist/templates/react-app/src/pages/auth/RegisterPage.tsx +46 -58
  264. package/dist/templates/react-app/src/pages/base/AboutPage.tsx +35 -40
  265. package/dist/templates/react-app/src/pages/base/ExecutorPage.tsx +51 -51
  266. package/dist/templates/react-app/src/pages/base/HomePage.tsx +14 -15
  267. package/dist/templates/react-app/src/pages/base/IdentifierPage.tsx +70 -11
  268. package/dist/templates/react-app/src/pages/base/JSONStoragePage.tsx +24 -25
  269. package/dist/templates/react-app/src/pages/base/Layout.tsx +2 -2
  270. package/dist/templates/react-app/src/pages/base/RedirectPathname.tsx +3 -2
  271. package/dist/templates/react-app/src/pages/base/RequestPage.tsx +41 -59
  272. package/dist/templates/react-app/src/styles/css/antd-themes/{_default.css → _common/_default.css} +85 -0
  273. package/dist/templates/react-app/src/styles/css/antd-themes/{dark.css → _common/dark.css} +99 -0
  274. package/dist/templates/react-app/src/styles/css/antd-themes/_common/index.css +3 -0
  275. package/dist/templates/react-app/src/styles/css/antd-themes/{pink.css → _common/pink.css} +86 -0
  276. package/dist/templates/react-app/src/styles/css/antd-themes/index.css +4 -3
  277. package/dist/templates/react-app/src/styles/css/antd-themes/menu/_default.css +108 -0
  278. package/dist/templates/react-app/src/styles/css/antd-themes/menu/dark.css +67 -0
  279. package/dist/templates/react-app/src/styles/css/antd-themes/menu/index.css +3 -0
  280. package/dist/templates/react-app/src/styles/css/antd-themes/menu/pink.css +67 -0
  281. package/dist/templates/react-app/src/styles/css/antd-themes/pagination/_default.css +34 -0
  282. package/dist/templates/react-app/src/styles/css/antd-themes/pagination/dark.css +31 -0
  283. package/dist/templates/react-app/src/styles/css/antd-themes/pagination/index.css +3 -0
  284. package/dist/templates/react-app/src/styles/css/antd-themes/pagination/pink.css +36 -0
  285. package/dist/templates/react-app/src/styles/css/antd-themes/table/_default.css +44 -0
  286. package/dist/templates/react-app/src/styles/css/antd-themes/table/dark.css +43 -0
  287. package/dist/templates/react-app/src/styles/css/antd-themes/table/index.css +3 -0
  288. package/dist/templates/react-app/src/styles/css/antd-themes/table/pink.css +43 -0
  289. package/dist/templates/react-app/src/styles/css/page.css +4 -3
  290. package/dist/templates/react-app/src/styles/css/themes/_default.css +1 -0
  291. package/dist/templates/react-app/src/styles/css/themes/dark.css +1 -0
  292. package/dist/templates/react-app/src/styles/css/themes/pink.css +1 -0
  293. package/dist/templates/react-app/src/styles/css/zIndex.css +1 -1
  294. package/dist/templates/react-app/src/uikit/bridges/ExecutorPageBridge.ts +3 -3
  295. package/dist/templates/react-app/src/uikit/bridges/JSONStoragePageBridge.ts +2 -2
  296. package/dist/templates/react-app/src/uikit/bridges/NavigateBridge.ts +1 -1
  297. package/dist/templates/react-app/src/uikit/bridges/RequestPageBridge.ts +3 -3
  298. package/dist/templates/react-app/src/uikit/components/AppRouterProvider.tsx +35 -0
  299. package/dist/templates/react-app/src/uikit/components/BaseHeader.tsx +15 -11
  300. package/dist/templates/react-app/src/uikit/components/BaseRouteProvider.tsx +14 -11
  301. package/dist/templates/react-app/src/uikit/components/BaseRouteSeo.tsx +18 -0
  302. package/dist/templates/react-app/src/uikit/components/BootstrapsProvider.tsx +13 -0
  303. package/dist/templates/react-app/src/uikit/components/ClientSeo.tsx +62 -0
  304. package/dist/templates/react-app/src/uikit/components/ComboProvider.tsx +38 -0
  305. package/dist/templates/react-app/src/uikit/components/LanguageSwitcher.tsx +48 -27
  306. package/dist/templates/react-app/src/uikit/components/Loading.tsx +4 -2
  307. package/dist/templates/react-app/src/uikit/components/LocaleLink.tsx +4 -5
  308. package/dist/templates/react-app/src/uikit/components/LogoutButton.tsx +34 -11
  309. package/dist/templates/react-app/src/uikit/components/ProcessExecutorProvider.tsx +9 -5
  310. package/dist/templates/react-app/src/uikit/components/RouterRenderComponent.tsx +6 -3
  311. package/dist/templates/react-app/src/uikit/components/ThemeSwitcher.tsx +97 -40
  312. package/dist/templates/react-app/src/uikit/components/UserAuthProvider.tsx +5 -5
  313. package/dist/templates/react-app/src/uikit/components/With.tsx +17 -0
  314. package/dist/templates/react-app/src/uikit/contexts/BaseRouteContext.ts +17 -11
  315. package/dist/templates/react-app/src/uikit/contexts/IOCContext.ts +13 -0
  316. package/dist/templates/react-app/src/uikit/hooks/useAppTranslation.ts +26 -0
  317. package/dist/templates/react-app/src/uikit/hooks/useI18nGuard.ts +8 -11
  318. package/dist/templates/react-app/src/uikit/hooks/useI18nInterface.ts +25 -0
  319. package/dist/templates/react-app/src/uikit/hooks/useIOC.ts +35 -0
  320. package/dist/templates/react-app/src/uikit/hooks/useNavigateBridge.ts +3 -3
  321. package/dist/templates/react-app/src/uikit/hooks/useStrictEffect.ts +0 -1
  322. package/dist/templates/react-app/tsconfig.e2e.json +21 -0
  323. package/dist/templates/react-app/tsconfig.json +8 -1
  324. package/dist/templates/react-app/tsconfig.node.json +1 -1
  325. package/dist/templates/react-app/tsconfig.test.json +3 -1
  326. package/dist/templates/react-app/vite.config.ts +50 -34
  327. package/package.json +2 -1
  328. package/dist/configs/react-app/eslint.config.js +0 -94
  329. package/dist/templates/next-app/config/Identifier/common.error.ts +0 -41
  330. package/dist/templates/next-app/config/Identifier/common.ts +0 -69
  331. package/dist/templates/next-app/config/Identifier/page.about.ts +0 -181
  332. package/dist/templates/next-app/config/Identifier/page.admin.ts +0 -48
  333. package/dist/templates/next-app/config/Identifier/page.executor.ts +0 -272
  334. package/dist/templates/next-app/config/Identifier/page.identifiter.ts +0 -39
  335. package/dist/templates/next-app/config/Identifier/page.jsonStorage.ts +0 -72
  336. package/dist/templates/next-app/config/Identifier/page.request.ts +0 -182
  337. package/dist/templates/next-app/docs/env.md +0 -94
  338. package/dist/templates/next-app/src/base/cases/ChatAction.ts +0 -21
  339. package/dist/templates/next-app/src/base/cases/FocusBarAction.ts +0 -36
  340. package/dist/templates/next-app/src/base/cases/RequestState.ts +0 -20
  341. package/dist/templates/next-app/src/base/port/AdminPageInterface.ts +0 -85
  342. package/dist/templates/next-app/src/base/port/AsyncStateInterface.ts +0 -7
  343. package/dist/templates/next-app/src/base/services/AdminUserService.ts +0 -45
  344. package/dist/templates/next-app/src/uikit/components/ChatRoot.tsx +0 -17
  345. package/dist/templates/next-app/src/uikit/components/chat/ChatActionInterface.ts +0 -30
  346. package/dist/templates/next-app/src/uikit/components/chat/ChatFocusBar.tsx +0 -65
  347. package/dist/templates/next-app/src/uikit/components/chat/ChatMessages.tsx +0 -59
  348. package/dist/templates/next-app/src/uikit/components/chat/ChatWrap.tsx +0 -28
  349. package/dist/templates/next-app/src/uikit/components/chat/FocusBarActionInterface.ts +0 -19
  350. package/dist/templates/next-app/src/uikit/hook/useMountedClient.ts +0 -17
  351. package/dist/templates/next-app/src/uikit/hook/useStore.ts +0 -15
  352. package/dist/templates/react-app/__tests__/__mocks__/I18nService.ts +0 -13
  353. package/dist/templates/react-app/__tests__/src/App.test.tsx +0 -139
  354. package/dist/templates/react-app/config/Identifier/page.identifiter.ts +0 -39
  355. package/dist/templates/react-app/config/i18n.ts +0 -15
  356. package/dist/templates/react-app/docs/en/project-structure.md +0 -434
  357. package/dist/templates/react-app/docs/zh/project-structure.md +0 -434
  358. package/dist/templates/react-app/src/base/cases/RequestState.ts +0 -20
  359. package/dist/templates/react-app/src/base/port/AsyncStateInterface.ts +0 -7
  360. package/dist/templates/react-app/src/uikit/hooks/useDocumentTitle.ts +0 -15
  361. 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 integrated practical features and best practices.
3
+ A modern React frontend project template integrated with multiple practical features and best practices.
4
4
 
5
5
  [中文](./README.md)
6
6
 
7
- ## 🌟 Features
7
+ ## 🌟 Highlights
8
8
 
9
- - 🚀 Fast development experience with Vite
9
+ - 🚀 Fast development experience based on Vite
10
10
  - 🎨 Theme system integrated with Tailwind CSS
11
- - 🌍 Comprehensive internationalization support (Chinese & English)
11
+ - 🌍 Complete internationalization support (Chinese and English)
12
12
  - 🔄 TypeScript-based IOC container
13
13
  - 📡 Unified API request handling
14
- - 🎮 Controller pattern for state management
15
- - 📦 Package management with pnpm
16
- - 🧪 Built-in test support
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 # Router page configuration
26
+ ├── config/ # Configuration files directory
27
+ │ ├── app.router.json # Route page configuration
28
28
  │ ├── common.ts # Application common configuration
29
- │ ├── app.router.json # Router configuration
30
- │ ├── i18n.ts # I18n configuration
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 resources directory
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
- ### Basic Documentation
74
- - [Project Overview](./docs/en/index.md) - Project introduction and quick start guide
75
- - [Project Structure](./docs/en/project-structure.md) - Detailed project directory structure explanation
76
- - [Development Guide](./docs/en/development-guide.md) - Project development specifications and best practices
77
- - [Environment Configuration](./docs/en/env.md) - Environment variables and configuration management
78
- - [Global Configuration](./docs/en/global.md) - Application global configuration and settings
79
-
80
- ### Core Features
81
- - [Bootstrap Process](./docs/en/bootstrap.md) - Application startup process and lifecycle management
82
- - [IOC Container](./docs/en/ioc.md) - Dependency injection system usage guide
83
- - [Router Management](./docs/en/router.md) - Router configuration and page navigation
84
- - [State Management](./docs/en/store.md) - Application state management solution
85
- - [Request Handling](./docs/en/request.md) - API request handling mechanism
86
-
87
- ### Feature Extensions
88
- - [Internationalization](./docs/en/i18n.md) - Multi-language support and translation management
89
- - [Theme System](./docs/en/theme.md) - Theme configuration and dark mode support
90
- - [TypeScript Guide](./docs/en/typescript-guide.md) - TypeScript usage specifications and best practices
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
- - Support for automatic service registration and dependency management
98
- - Complete type inference
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://vitejs.dev/guide/env-and-mode.html)
120
+ [Vite Environment Variables and Modes](https://cn.vite.dev/guide/env-and-mode#env-variables-and-modes)
103
121
 
104
- `vite dev` default NODE_ENV is 'development', it will load possible `.env[mode]` files, e.g., .env.local -> .env
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` default NODE_ENV is 'production', it will load possible `.env[mode]` files, e.g., .env.production -> .env
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. Mode can be specified with `--mode` to load different env configurations.
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 i18n solution based on i18next
122
- - Support for Chinese (zh) and English (en) language switching
123
- - Automatic i18n resource generation based on TypeScript comments
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 switcher component
143
+ - Built-in language switching component
126
144
 
127
145
  ### Theme System
128
146
 
129
147
  - Theme configuration based on Tailwind CSS
130
- - Support for dark/light mode
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 Standards
203
+ ### API Development Specifications
186
204
 
187
205
  1. Define interfaces in `src/base/apis`
188
- 2. Support for Mock data configuration
206
+ 2. Support Mock data configuration
189
207
 
190
- ### Adding New Pages
208
+ ### Adding New Pages Process
191
209
 
192
- 1. Create page component in `src/pages`
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 includes the following optimizations:
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 compression
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 for environment variable prefix configuration
255
+ - Support environment variable prefix configuration
238
256
 
239
257
  #### Style Configuration
240
258
 
241
- - Integrate Tailwind CSS
242
- - Load Ant Design component styles on demand
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, configurable via environment variable
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
- - [项目概述](./docs/zh/index.md) - 项目整体介绍和快速开始指南
75
- - [项目结构](./docs/zh/project-structure.md) - 详细的项目目录结构说明
76
- - [开发指南](./docs/zh/development-guide.md) - 项目开发规范和最佳实践
77
- - [环境配置](./docs/zh/env.md) - 环境变量和配置管理说明
78
- - [全局配置](./docs/zh/global.md) - 应用全局配置和设置说明
79
-
80
- ### 核心功能
81
- - [启动流程](./docs/zh/bootstrap.md) - 应用启动流程和生命周期管理
82
- - [IOC容器](./docs/zh/ioc.md) - 依赖注入系统的使用说明
83
- - [路由管理](./docs/zh/router.md) - 路由配置和页面导航说明
84
- - [状态管理](./docs/zh/store.md) - 应用状态管理方案说明
85
- - [请求处理](./docs/zh/request.md) - API 请求处理机制说明
86
-
87
- ### 功能扩展
88
- - [国际化](./docs/zh/i18n.md) - 多语言支持和翻译管理
89
- - [主题系统](./docs/zh/theme.md) - 主题配置和暗色模式支持
90
- - [TypeScript指南](./docs/zh/typescript-guide.md) - TypeScript 使用规范和最佳实践
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,5 +1,5 @@
1
- import { EnvConfigInterface } from '@qlover/corekit-bridge';
2
1
  import { name, version } from '../../package.json';
2
+ import type { EnvConfigInterface } from '@qlover/corekit-bridge';
3
3
 
4
4
  export class MockAppConfig implements EnvConfigInterface {
5
5
  appName = name;
@@ -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
@@ -1,5 +1,5 @@
1
- import { LoggerInterface } from '@qlover/logger';
2
1
  import { vi } from 'vitest';
2
+ import type { LoggerInterface } from '@qlover/logger';
3
3
 
4
4
  export class MockLogger implements LoggerInterface {
5
5
  info = vi.fn();
@@ -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
+ }