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