@qlover/create-app 0.10.1 → 0.10.3
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 +178 -0
- package/dist/configs/_common/.github/workflows/general-check.yml +1 -1
- package/dist/configs/_common/.github/workflows/release.yml +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/templates/next-app/config/IOCIdentifier.ts +2 -2
- package/dist/templates/next-app/config/Identifier/common/common.ts +14 -0
- package/dist/templates/next-app/config/Identifier/pages/index.ts +1 -0
- package/dist/templates/next-app/config/Identifier/pages/page.about.ts +20 -0
- package/dist/templates/next-app/config/common.ts +1 -1
- package/dist/templates/next-app/config/cookies.ts +23 -0
- package/dist/templates/next-app/config/i18n/AboutI18n.ts +14 -0
- package/dist/templates/next-app/config/i18n/i18nConfig.ts +3 -1
- package/dist/templates/next-app/config/i18n/index.ts +1 -0
- package/dist/templates/next-app/config/i18n/loginI18n.ts +8 -0
- package/dist/templates/next-app/config/theme.ts +4 -0
- package/dist/templates/next-app/eslint.config.mjs +9 -2
- package/dist/templates/next-app/next.config.ts +1 -0
- package/dist/templates/next-app/package.json +17 -6
- package/dist/templates/next-app/public/locales/en.json +5 -0
- package/dist/templates/next-app/public/locales/zh.json +5 -0
- package/dist/templates/next-app/src/app/[locale]/admin/AdminI18nProvider.tsx +37 -0
- package/dist/templates/next-app/src/app/[locale]/admin/layout.tsx +30 -6
- package/dist/templates/next-app/src/app/[locale]/admin/locales/page.tsx +1 -1
- package/dist/templates/next-app/src/app/[locale]/layout.tsx +47 -10
- package/dist/templates/next-app/src/app/[locale]/login/LoginForm.tsx +1 -1
- package/dist/templates/next-app/src/app/[locale]/login/page.tsx +22 -10
- package/dist/templates/next-app/src/app/[locale]/page.tsx +23 -8
- package/dist/templates/next-app/src/app/[locale]/register/page.tsx +21 -9
- package/dist/templates/next-app/src/app/api/admin/locales/create/route.ts +7 -28
- package/dist/templates/next-app/src/app/api/admin/locales/import/route.ts +7 -34
- package/dist/templates/next-app/src/app/api/admin/locales/route.ts +12 -34
- package/dist/templates/next-app/src/app/api/admin/locales/update/route.ts +7 -26
- package/dist/templates/next-app/src/app/api/admin/users/route.ts +14 -33
- package/dist/templates/next-app/src/app/api/locales/json/route.ts +13 -25
- package/dist/templates/next-app/src/app/api/user/login/route.ts +6 -46
- package/dist/templates/next-app/src/app/api/user/logout/route.ts +5 -24
- package/dist/templates/next-app/src/app/api/user/register/route.ts +6 -45
- package/dist/templates/next-app/src/app/manifest.ts +16 -0
- package/dist/templates/next-app/src/app/robots.txt +2 -0
- package/dist/templates/next-app/src/base/cases/AdminPageManager.ts +3 -3
- package/dist/templates/next-app/src/base/cases/AppConfig.ts +14 -13
- package/dist/templates/next-app/src/base/cases/Datetime.ts +3 -3
- package/dist/templates/next-app/src/base/cases/DialogErrorPlugin.ts +8 -2
- package/dist/templates/next-app/src/base/cases/DialogHandler.ts +30 -4
- package/dist/templates/next-app/src/base/cases/InversifyContainer.ts +16 -4
- package/dist/templates/next-app/src/base/cases/NavigateBridge.ts +20 -4
- package/dist/templates/next-app/src/base/cases/RequestEncryptPlugin.ts +8 -2
- package/dist/templates/next-app/src/base/cases/ResourceState.ts +3 -3
- package/dist/templates/next-app/src/base/cases/RouterService.ts +28 -10
- package/dist/templates/next-app/src/base/cases/StringEncryptor.ts +14 -2
- package/dist/templates/next-app/src/base/cases/TranslateI18nInterface.ts +1 -1
- package/dist/templates/next-app/src/base/cases/UserServiceApi.ts +20 -5
- package/dist/templates/next-app/src/base/cases/ZodColumnBuilder.ts +31 -8
- package/dist/templates/next-app/src/base/port/AdminLayoutInterface.ts +4 -1
- package/dist/templates/next-app/src/base/port/AppApiInterface.ts +22 -0
- package/dist/templates/next-app/src/base/port/I18nServiceInterface.ts +27 -7
- package/dist/templates/next-app/src/base/port/IOCInterface.ts +9 -0
- package/dist/templates/next-app/src/base/services/AdminPageEvent.ts +1 -1
- package/dist/templates/next-app/src/base/services/AdminPageScheduler.ts +3 -3
- package/dist/templates/next-app/src/base/services/I18nService.ts +20 -10
- package/dist/templates/next-app/src/base/services/ResourceService.ts +32 -11
- package/dist/templates/next-app/src/base/services/UserService.ts +12 -3
- package/dist/templates/next-app/src/base/services/adminApi/AdminLocalesApi.ts +9 -6
- package/dist/templates/next-app/src/base/services/adminApi/AdminUserApi.ts +20 -5
- package/dist/templates/next-app/src/base/services/appApi/AppApiPlugin.ts +21 -4
- package/dist/templates/next-app/src/base/services/appApi/AppUserApi.ts +12 -3
- package/dist/templates/next-app/src/base/services/appApi/AppUserApiBootstrap.ts +10 -2
- package/dist/templates/next-app/src/base/types/{PageProps.ts → AppPageRouter.ts} +4 -1
- package/dist/templates/next-app/src/base/types/PagesRouter.ts +9 -0
- package/dist/templates/next-app/src/core/bootstraps/BootstrapClient.ts +20 -6
- package/dist/templates/next-app/src/core/bootstraps/BootstrapServer.ts +27 -9
- package/dist/templates/next-app/src/core/bootstraps/BootstrapsRegistry.ts +6 -4
- package/dist/templates/next-app/src/core/clientIoc/ClientIOC.ts +39 -9
- package/dist/templates/next-app/src/core/clientIoc/ClientIOCRegister.ts +9 -2
- package/dist/templates/next-app/src/core/serverIoc/ServerIOC.ts +37 -10
- package/dist/templates/next-app/src/core/serverIoc/ServerIOCRegister.ts +9 -2
- package/dist/templates/next-app/src/i18n/loadMessages.ts +103 -0
- package/dist/templates/next-app/src/i18n/request.ts +3 -22
- package/dist/templates/next-app/src/pages/[locale]/about.tsx +61 -0
- package/dist/templates/next-app/src/pages/_app.tsx +50 -0
- package/dist/templates/next-app/src/pages/_document.tsx +13 -0
- package/dist/templates/next-app/src/{middleware.ts → proxy.ts} +2 -1
- package/dist/templates/next-app/src/server/AppErrorApi.ts +1 -1
- package/dist/templates/next-app/src/server/AppPageRouteParams.ts +107 -0
- package/dist/templates/next-app/src/server/AppSuccessApi.ts +1 -1
- package/dist/templates/next-app/src/server/NextApiServer.ts +62 -0
- package/dist/templates/next-app/src/server/PagesRouteParams.ts +146 -0
- package/dist/templates/next-app/src/server/PasswordEncrypt.ts +8 -2
- package/dist/templates/next-app/src/server/ServerAuth.ts +20 -5
- package/dist/templates/next-app/src/server/{sqlBridges/SupabaseBridge.ts → SupabaseBridge.ts} +50 -8
- package/dist/templates/next-app/src/server/UserCredentialToken.ts +8 -2
- package/dist/templates/next-app/src/server/controllers/AdminLocalesController.ts +86 -0
- package/dist/templates/next-app/src/server/controllers/AdminUserController.ts +42 -0
- package/dist/templates/next-app/src/server/controllers/LocalesController.ts +36 -0
- package/dist/templates/next-app/src/server/controllers/UserController.ts +86 -0
- package/dist/templates/next-app/src/server/port/AIControllerInterface.ts +8 -0
- package/dist/templates/next-app/src/server/port/AdminLocalesControllerInterface.ts +21 -0
- package/dist/templates/next-app/src/server/port/AdminUserControllerInterface.ts +11 -0
- package/dist/templates/next-app/src/server/port/LocalesControllerInterface.ts +10 -0
- package/dist/templates/next-app/src/server/port/{ParamsHandlerInterface.ts → RouteParamsnHandlerInterface.ts} +9 -2
- package/dist/templates/next-app/src/server/port/ServerInterface.ts +2 -2
- package/dist/templates/next-app/src/server/port/UserControllerInerface.ts +8 -0
- package/dist/templates/next-app/src/server/port/UserServiceInterface.ts +1 -1
- package/dist/templates/next-app/src/server/port/ValidatorInterface.ts +2 -2
- package/dist/templates/next-app/src/server/repositorys/LocalesRepository.ts +31 -9
- package/dist/templates/next-app/src/server/repositorys/UserRepository.ts +15 -6
- package/dist/templates/next-app/src/server/services/AIService.ts +3 -1
- package/dist/templates/next-app/src/server/services/AdminAuthPlugin.ts +5 -2
- package/dist/templates/next-app/src/{base → server}/services/AdminLocalesService.ts +2 -2
- package/dist/templates/next-app/src/server/services/ApiLocaleService.ts +29 -14
- package/dist/templates/next-app/src/server/services/ApiUserService.ts +6 -3
- package/dist/templates/next-app/src/server/services/UserService.ts +12 -3
- package/dist/templates/next-app/src/server/validators/LocalesValidator.ts +24 -7
- package/dist/templates/next-app/src/server/validators/LoginValidator.ts +17 -5
- package/dist/templates/next-app/src/server/validators/PaginationValidator.ts +17 -11
- package/dist/templates/next-app/src/styles/css/antd-themes/_common/_default.css +0 -44
- package/dist/templates/next-app/src/styles/css/antd-themes/_common/dark.css +0 -44
- package/dist/templates/next-app/src/styles/css/antd-themes/_common/pink.css +0 -44
- package/dist/templates/next-app/src/styles/css/index.css +1 -1
- package/dist/templates/next-app/src/styles/css/scrollbar.css +34 -0
- package/dist/templates/next-app/src/uikit/components/AdminLayout.tsx +34 -11
- package/dist/templates/next-app/src/uikit/components/BootstrapsProvider.tsx +69 -39
- package/dist/templates/next-app/src/uikit/components/ClientRootProvider.tsx +64 -0
- package/dist/templates/next-app/src/uikit/components/ClinetRenderProvider.tsx +42 -0
- package/dist/templates/next-app/src/uikit/components/IOCProvider.tsx +34 -0
- package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportEvent.ts +7 -1
- package/dist/templates/next-app/src/uikit/components-app/AppBridge.tsx +17 -0
- package/dist/templates/next-app/src/uikit/components-app/AppRoutePage.tsx +112 -0
- package/dist/templates/next-app/src/uikit/{components → components-app}/LanguageSwitcher.tsx +15 -19
- package/dist/templates/next-app/src/uikit/{components → components-app}/ThemeSwitcher.tsx +53 -52
- package/dist/templates/next-app/src/uikit/components-pages/LanguageSwitcher.tsx +98 -0
- package/dist/templates/next-app/src/uikit/components-pages/PagesRoutePage.tsx +93 -0
- package/dist/templates/next-app/src/uikit/context/IOCContext.ts +16 -4
- package/dist/templates/next-app/src/uikit/hook/useStrictEffect.ts +32 -0
- package/dist/templates/next-app/tsconfig.json +3 -2
- package/dist/templates/react-app/__tests__/__mocks__/BootstrapTest.ts +3 -1
- package/dist/templates/react-app/__tests__/__mocks__/MockAppConfig.ts +19 -19
- package/dist/templates/react-app/__tests__/__mocks__/MockDialogHandler.ts +8 -8
- package/dist/templates/react-app/__tests__/__mocks__/MockLogger.ts +9 -9
- package/dist/templates/react-app/__tests__/__mocks__/components/TestBootstrapsProvider.tsx +1 -1
- package/dist/templates/react-app/__tests__/__mocks__/i18nextHttpBackend.ts +5 -5
- package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOC.ts +9 -5
- package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOCRegister.ts +8 -4
- package/dist/templates/react-app/__tests__/src/base/cases/I18nKeyErrorPlugin.test.ts +4 -4
- package/dist/templates/react-app/__tests__/src/base/cases/InversifyContainer.test.ts +5 -5
- package/dist/templates/react-app/__tests__/src/core/bootstraps/BootstrapClient.test.ts +3 -3
- package/dist/templates/react-app/__tests__/src/uikit/components/chatMessage/ChatRoot.test.tsx +1 -1
- package/dist/templates/react-app/docs/en/components/chat-message-component.md +35 -29
- package/dist/templates/react-app/docs/en/components/chat-message-refactor.md +18 -5
- package/dist/templates/react-app/docs/en/components/message-base-list-component.md +11 -12
- package/dist/templates/react-app/docs/en/request.md +1 -3
- package/dist/templates/react-app/docs/zh/components/chat-message-component.md +35 -29
- package/dist/templates/react-app/docs/zh/components/chat-message-refactor.md +18 -5
- package/dist/templates/react-app/docs/zh/components/message-base-list-component.md +11 -12
- package/dist/templates/react-app/docs/zh/request.md +1 -3
- package/dist/templates/react-app/eslint.config.mjs +10 -5
- package/dist/templates/react-app/src/App.tsx +1 -1
- package/dist/templates/react-app/src/base/apis/feApi/FeApi.ts +2 -2
- package/dist/templates/react-app/src/base/apis/feApi/FeApiBootstarp.ts +14 -11
- package/dist/templates/react-app/src/base/apis/userApi/UserApi.ts +10 -16
- package/dist/templates/react-app/src/base/apis/userApi/UserApiBootstarp.ts +12 -10
- package/dist/templates/react-app/src/base/cases/AppConfig.ts +19 -19
- package/dist/templates/react-app/src/base/cases/DialogHandler.ts +28 -5
- package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +5 -2
- package/dist/templates/react-app/src/base/cases/InversifyContainer.ts +16 -4
- package/dist/templates/react-app/src/base/cases/PublicAssetsPath.ts +1 -1
- package/dist/templates/react-app/src/base/cases/RequestLanguages.ts +6 -3
- package/dist/templates/react-app/src/base/cases/RequestLogger.ts +17 -8
- package/dist/templates/react-app/src/base/cases/RequestStatusCatcher.ts +4 -6
- package/dist/templates/react-app/src/base/cases/ResourceState.ts +3 -3
- package/dist/templates/react-app/src/base/cases/RouterLoader.ts +3 -3
- package/dist/templates/react-app/src/base/cases/TranslateI18nInterface.ts +1 -1
- package/dist/templates/react-app/src/base/port/ExecutorPageBridgeInterface.ts +2 -2
- package/dist/templates/react-app/src/base/port/IOCInterface.ts +4 -2
- package/dist/templates/react-app/src/base/port/JSONStoragePageBridgeInterface.ts +5 -5
- package/dist/templates/react-app/src/base/port/RequestPageBridgeInterface.ts +7 -7
- package/dist/templates/react-app/src/base/port/RouteServiceInterface.ts +8 -8
- package/dist/templates/react-app/src/base/port/UserServiceInterface.ts +4 -2
- package/dist/templates/react-app/src/base/services/BaseLayoutService.ts +3 -3
- package/dist/templates/react-app/src/base/services/I18nService.ts +24 -13
- package/dist/templates/react-app/src/base/services/IdentifierService.ts +21 -26
- package/dist/templates/react-app/src/base/services/RouteService.ts +8 -8
- package/dist/templates/react-app/src/base/services/UserBootstrap.ts +2 -2
- package/dist/templates/react-app/src/base/services/UserGatewayPlugin.ts +9 -5
- package/dist/templates/react-app/src/base/services/UserService.ts +10 -4
- package/dist/templates/react-app/src/core/bootstraps/BootstrapClient.ts +3 -1
- package/dist/templates/react-app/src/core/bootstraps/BootstrapsRegistry.ts +5 -2
- package/dist/templates/react-app/src/core/clientIoc/ClientIOC.ts +11 -4
- package/dist/templates/react-app/src/core/clientIoc/ClientIOCRegister.ts +5 -4
- package/dist/templates/react-app/src/pages/base/Layout.tsx +1 -1
- package/dist/templates/react-app/src/styles/css/antd-themes/_common/_default.css +0 -44
- package/dist/templates/react-app/src/styles/css/antd-themes/_common/dark.css +0 -44
- package/dist/templates/react-app/src/styles/css/antd-themes/_common/pink.css +0 -44
- package/dist/templates/react-app/src/styles/css/index.css +1 -1
- package/dist/templates/react-app/src/styles/css/scrollbar.css +34 -0
- package/dist/templates/react-app/src/uikit/bridges/ExecutorPageBridge.ts +2 -2
- package/dist/templates/react-app/src/uikit/bridges/JSONStoragePageBridge.ts +4 -4
- package/dist/templates/react-app/src/uikit/bridges/NavigateBridge.ts +8 -2
- package/dist/templates/react-app/src/uikit/bridges/RequestPageBridge.ts +6 -6
- package/dist/templates/react-app/src/uikit/components/AppRouterProvider.tsx +1 -1
- package/dist/templates/react-app/src/uikit/components/BootstrapsProvider.tsx +1 -3
- package/dist/templates/react-app/src/uikit/components/MessageBaseList.tsx +4 -1
- package/dist/templates/react-app/src/uikit/components/chatMessage/ChatMessageBridge.ts +39 -16
- package/dist/templates/react-app/src/uikit/components/chatMessage/MessageApi.ts +4 -2
- package/package.json +3 -3
- package/dist/templates/next-app/src/server/PageParams.ts +0 -66
- package/dist/templates/next-app/src/uikit/components/BaseHeader.tsx +0 -80
- package/dist/templates/next-app/src/uikit/components/BaseLayout.tsx +0 -65
- package/dist/templates/next-app/src/uikit/components/ComboProvider.tsx +0 -58
- package/dist/templates/next-app/src/uikit/components/NextIntlProvider.tsx +0 -21
- package/dist/templates/react-app/makes/eslint-utils.mjs +0 -195
- /package/dist/templates/next-app/{src/app/[locale] → public}/favicon.ico +0 -0
- /package/dist/templates/next-app/src/uikit/{components → components-app}/LogoutButton.tsx +0 -0
|
@@ -30,15 +30,24 @@ export class UserService
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @override
|
|
35
|
+
*/
|
|
36
|
+
public getToken(): string {
|
|
34
37
|
return this.store.getCredential()?.credential_token ?? '';
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @override
|
|
42
|
+
*/
|
|
43
|
+
public isUserInfo(value: unknown): value is UserSchema {
|
|
38
44
|
return userSchema.safeParse(value).success;
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @override
|
|
49
|
+
*/
|
|
50
|
+
public isUserCredential(value: unknown): value is UserCredential {
|
|
42
51
|
return (
|
|
43
52
|
isObject(value) &&
|
|
44
53
|
'credential_token' in value &&
|
|
@@ -30,7 +30,7 @@ export class AdminLocalesApi implements ResourceInterface<LocalesSchema> {
|
|
|
30
30
|
/**
|
|
31
31
|
* @override
|
|
32
32
|
*/
|
|
33
|
-
create(data: LocalesSchema): Promise<unknown> {
|
|
33
|
+
public create(data: LocalesSchema): Promise<unknown> {
|
|
34
34
|
return this.client.request<AdminLocalesListTransaction>({
|
|
35
35
|
url: '/admin/locales/create',
|
|
36
36
|
method: 'POST',
|
|
@@ -41,7 +41,7 @@ export class AdminLocalesApi implements ResourceInterface<LocalesSchema> {
|
|
|
41
41
|
/**
|
|
42
42
|
* @override
|
|
43
43
|
*/
|
|
44
|
-
remove(data: Partial<LocalesSchema>): Promise<unknown> {
|
|
44
|
+
public remove(data: Partial<LocalesSchema>): Promise<unknown> {
|
|
45
45
|
return this.client.request<AdminLocalesListTransaction>({
|
|
46
46
|
url: '/admin/locales',
|
|
47
47
|
method: 'DELETE',
|
|
@@ -52,7 +52,7 @@ export class AdminLocalesApi implements ResourceInterface<LocalesSchema> {
|
|
|
52
52
|
/**
|
|
53
53
|
* @override
|
|
54
54
|
*/
|
|
55
|
-
search(
|
|
55
|
+
public search(
|
|
56
56
|
params: ResourceQuery
|
|
57
57
|
): Promise<AdminLocalesListTransaction['response']> {
|
|
58
58
|
return this.client.request<AdminLocalesListTransaction>({
|
|
@@ -65,7 +65,7 @@ export class AdminLocalesApi implements ResourceInterface<LocalesSchema> {
|
|
|
65
65
|
/**
|
|
66
66
|
* @override
|
|
67
67
|
*/
|
|
68
|
-
export(data: LocalesSchema): Promise<unknown> {
|
|
68
|
+
public export(data: LocalesSchema): Promise<unknown> {
|
|
69
69
|
return this.client.request<AdminLocalesListTransaction>({
|
|
70
70
|
url: '/admin/locales',
|
|
71
71
|
method: 'GET',
|
|
@@ -76,7 +76,7 @@ export class AdminLocalesApi implements ResourceInterface<LocalesSchema> {
|
|
|
76
76
|
/**
|
|
77
77
|
* @override
|
|
78
78
|
*/
|
|
79
|
-
update(
|
|
79
|
+
public update(
|
|
80
80
|
data: Partial<LocalesSchema>
|
|
81
81
|
): Promise<AdminLocalesUpdateTransaction['response']> {
|
|
82
82
|
return this.client.request<AdminLocalesUpdateTransaction>({
|
|
@@ -86,7 +86,10 @@ export class AdminLocalesApi implements ResourceInterface<LocalesSchema> {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
/**
|
|
90
|
+
* @override
|
|
91
|
+
*/
|
|
92
|
+
public import(data: {
|
|
90
93
|
[key in LocaleType]?: File;
|
|
91
94
|
}): Promise<unknown> {
|
|
92
95
|
const formdata = new FormData();
|
|
@@ -21,7 +21,10 @@ export class AdminUserApi implements ResourceInterface<UserSchema> {
|
|
|
21
21
|
protected client: RequestTransaction<AppApiConfig>
|
|
22
22
|
) {}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @override
|
|
26
|
+
*/
|
|
27
|
+
public async search(
|
|
25
28
|
params: AdminUserListTransaction['request']
|
|
26
29
|
): Promise<AdminUserListTransaction['response']> {
|
|
27
30
|
const response = await this.client.request<AdminUserListTransaction>({
|
|
@@ -33,7 +36,10 @@ export class AdminUserApi implements ResourceInterface<UserSchema> {
|
|
|
33
36
|
return response;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @override
|
|
41
|
+
*/
|
|
42
|
+
public create(data: UserSchema): Promise<unknown> {
|
|
37
43
|
return this.client.request<AdminUserListTransaction>({
|
|
38
44
|
url: '/admin/users',
|
|
39
45
|
method: 'POST',
|
|
@@ -41,7 +47,10 @@ export class AdminUserApi implements ResourceInterface<UserSchema> {
|
|
|
41
47
|
});
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
/**
|
|
51
|
+
* @override
|
|
52
|
+
*/
|
|
53
|
+
public remove(data: UserSchema): Promise<unknown> {
|
|
45
54
|
return this.client.request<AdminUserListTransaction>({
|
|
46
55
|
url: '/admin/users',
|
|
47
56
|
method: 'DELETE',
|
|
@@ -49,7 +58,10 @@ export class AdminUserApi implements ResourceInterface<UserSchema> {
|
|
|
49
58
|
});
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
/**
|
|
62
|
+
* @override
|
|
63
|
+
*/
|
|
64
|
+
public update(data: UserSchema): Promise<unknown> {
|
|
53
65
|
return this.client.request<AdminUserListTransaction>({
|
|
54
66
|
url: '/admin/users',
|
|
55
67
|
method: 'PUT',
|
|
@@ -57,7 +69,10 @@ export class AdminUserApi implements ResourceInterface<UserSchema> {
|
|
|
57
69
|
});
|
|
58
70
|
}
|
|
59
71
|
|
|
60
|
-
|
|
72
|
+
/**
|
|
73
|
+
* @override
|
|
74
|
+
*/
|
|
75
|
+
public export(data: UserSchema): Promise<unknown> {
|
|
61
76
|
return this.client.request<AdminUserListTransaction>({
|
|
62
77
|
url: '/admin/users',
|
|
63
78
|
method: 'GET',
|
|
@@ -9,11 +9,14 @@ import type { AppApiConfig } from './AppApiRequester';
|
|
|
9
9
|
import type { LoggerInterface } from '@qlover/logger';
|
|
10
10
|
|
|
11
11
|
export class AppApiPlugin implements ExecutorPlugin {
|
|
12
|
-
readonly pluginName = 'AppApiPlugin';
|
|
12
|
+
public readonly pluginName = 'AppApiPlugin';
|
|
13
13
|
|
|
14
14
|
constructor(protected logger: LoggerInterface) {}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @override
|
|
18
|
+
*/
|
|
19
|
+
public isAppApiErrorInterface(value: unknown): value is AppApiErrorInterface {
|
|
17
20
|
return (
|
|
18
21
|
typeof value === 'object' &&
|
|
19
22
|
value !== null &&
|
|
@@ -24,7 +27,12 @@ export class AppApiPlugin implements ExecutorPlugin {
|
|
|
24
27
|
);
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @override
|
|
32
|
+
*/
|
|
33
|
+
public onSuccess(
|
|
34
|
+
context: ExecutorContext<AppApiConfig>
|
|
35
|
+
): void | Promise<void> {
|
|
28
36
|
const response = context.returnValue;
|
|
29
37
|
const { parameters } = context;
|
|
30
38
|
|
|
@@ -40,7 +48,10 @@ export class AppApiPlugin implements ExecutorPlugin {
|
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
/**
|
|
52
|
+
* @override
|
|
53
|
+
*/
|
|
54
|
+
public async onError(
|
|
44
55
|
context: ExecutorContext<AppApiConfig>
|
|
45
56
|
): Promise<ExecutorError | void> {
|
|
46
57
|
const { error, parameters } = context;
|
|
@@ -66,6 +77,9 @@ export class AppApiPlugin implements ExecutorPlugin {
|
|
|
66
77
|
}
|
|
67
78
|
}
|
|
68
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @override
|
|
82
|
+
*/
|
|
69
83
|
protected async getResponseJson(response: Response): Promise<unknown> {
|
|
70
84
|
try {
|
|
71
85
|
return await response.json();
|
|
@@ -74,6 +88,9 @@ export class AppApiPlugin implements ExecutorPlugin {
|
|
|
74
88
|
}
|
|
75
89
|
}
|
|
76
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @override
|
|
93
|
+
*/
|
|
77
94
|
protected loggerError(config: AppApiConfig, error: unknown): void {
|
|
78
95
|
this.logger.error(
|
|
79
96
|
`%c[AppApi ${config.method} ${config.url}]%c - ${new Date().toLocaleString()}`,
|
|
@@ -23,7 +23,10 @@ export class AppUserApi implements AppUserApiInterface {
|
|
|
23
23
|
protected client: RequestTransaction<AppApiConfig>
|
|
24
24
|
) {}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @override
|
|
28
|
+
*/
|
|
29
|
+
public async login(
|
|
27
30
|
params: UserApiLoginTransaction['data']
|
|
28
31
|
): Promise<UserApiLoginTransaction['response']> {
|
|
29
32
|
const response = await this.client.request<UserApiLoginTransaction>({
|
|
@@ -36,7 +39,10 @@ export class AppUserApi implements AppUserApiInterface {
|
|
|
36
39
|
return response;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @override
|
|
44
|
+
*/
|
|
45
|
+
public async register(
|
|
40
46
|
params: UserApiRegisterTransaction['data']
|
|
41
47
|
): Promise<UserApiRegisterTransaction['response']> {
|
|
42
48
|
const response = await this.client.request<UserApiRegisterTransaction>({
|
|
@@ -49,7 +55,10 @@ export class AppUserApi implements AppUserApiInterface {
|
|
|
49
55
|
return response;
|
|
50
56
|
}
|
|
51
57
|
|
|
52
|
-
|
|
58
|
+
/**
|
|
59
|
+
* @override
|
|
60
|
+
*/
|
|
61
|
+
public async logout(
|
|
53
62
|
_params?: unknown
|
|
54
63
|
): Promise<UserApiLogoutTransaction['response']> {
|
|
55
64
|
return await this.client.request<UserApiLogoutTransaction>({
|
|
@@ -14,11 +14,16 @@ import type {
|
|
|
14
14
|
import type { ExecutorContext, SerializerIneterface } from '@qlover/fe-corekit';
|
|
15
15
|
|
|
16
16
|
export class AppUserApiBootstrap implements BootstrapExecutorPlugin {
|
|
17
|
-
readonly pluginName = 'AppUserApiBootstrap';
|
|
17
|
+
public readonly pluginName = 'AppUserApiBootstrap';
|
|
18
18
|
|
|
19
19
|
constructor(protected serializer: SerializerIneterface) {}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @override
|
|
23
|
+
*/
|
|
24
|
+
public onBefore({
|
|
25
|
+
parameters: { ioc }
|
|
26
|
+
}: BootstrapContext): void | Promise<void> {
|
|
22
27
|
const appUserApi = ioc.get<AppApiRequester>(AppApiRequester);
|
|
23
28
|
|
|
24
29
|
appUserApi.usePlugin(new FetchURLPlugin());
|
|
@@ -32,6 +37,9 @@ export class AppUserApiBootstrap implements BootstrapExecutorPlugin {
|
|
|
32
37
|
appUserApi.usePlugin(ioc.get(DialogErrorPlugin));
|
|
33
38
|
}
|
|
34
39
|
|
|
40
|
+
/**
|
|
41
|
+
* @override
|
|
42
|
+
*/
|
|
35
43
|
protected requestDataSerializer(
|
|
36
44
|
data: unknown,
|
|
37
45
|
context: ExecutorContext<AppApiConfig>
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 该文件主要用于 /src/app 目录下页面路由的类型定义
|
|
3
|
+
*/
|
|
4
|
+
import type { PageWithParams } from '@/server/AppPageRouteParams';
|
|
2
5
|
|
|
3
6
|
export interface PageParamsProps extends PageWithParams {
|
|
4
7
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { Bootstrap } from '@qlover/corekit-bridge';
|
|
3
3
|
import { isObject } from 'lodash';
|
|
4
|
+
import type { IocRegisterOptions } from '@/base/port/IOCInterface';
|
|
4
5
|
import { browserGlobalsName } from '@config/common';
|
|
5
6
|
import type { IOCIdentifierMap } from '@config/IOCIdentifier';
|
|
6
7
|
import { BootstrapsRegistry } from './BootstrapsRegistry';
|
|
7
8
|
import * as globals from '../globals';
|
|
8
9
|
import type {
|
|
9
10
|
IOCContainerInterface,
|
|
10
|
-
IOCFunctionInterface
|
|
11
|
+
IOCFunctionInterface,
|
|
12
|
+
IOCRegisterInterface
|
|
11
13
|
} from '@qlover/corekit-bridge';
|
|
12
14
|
|
|
13
15
|
export type BootstrapAppArgs = {
|
|
@@ -23,23 +25,31 @@ export type BootstrapAppArgs = {
|
|
|
23
25
|
* IOC容器
|
|
24
26
|
*/
|
|
25
27
|
IOC: IOCFunctionInterface<IOCIdentifierMap, IOCContainerInterface>;
|
|
28
|
+
|
|
29
|
+
register?: IOCRegisterInterface<IOCContainerInterface, IocRegisterOptions>;
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
export class BootstrapClient {
|
|
29
|
-
static
|
|
30
|
-
|
|
33
|
+
public static lastTime = 0;
|
|
34
|
+
public static async main(args: BootstrapAppArgs): Promise<BootstrapAppArgs> {
|
|
35
|
+
const { logger, appConfig } = globals;
|
|
36
|
+
|
|
37
|
+
if (BootstrapClient.lastTime) {
|
|
38
|
+
return args;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { root, IOC, register } = args;
|
|
31
42
|
|
|
32
43
|
if (!isObject(root)) {
|
|
33
44
|
throw new Error('root is not an object');
|
|
34
45
|
}
|
|
35
46
|
|
|
36
|
-
const { logger, appConfig } = globals;
|
|
37
|
-
|
|
38
47
|
const bootstrap = new Bootstrap({
|
|
39
48
|
root,
|
|
40
49
|
logger,
|
|
41
50
|
ioc: {
|
|
42
|
-
manager: IOC
|
|
51
|
+
manager: IOC,
|
|
52
|
+
register: register
|
|
43
53
|
},
|
|
44
54
|
globalOptions: {
|
|
45
55
|
sources: globals,
|
|
@@ -53,6 +63,10 @@ export class BootstrapClient {
|
|
|
53
63
|
const bootstrapsRegistry = new BootstrapsRegistry(args);
|
|
54
64
|
|
|
55
65
|
await bootstrap.use(bootstrapsRegistry.register()).start();
|
|
66
|
+
|
|
67
|
+
BootstrapClient.lastTime = Date.now();
|
|
68
|
+
|
|
69
|
+
logger.info('BootstrapClient starup success,', BootstrapClient.lastTime);
|
|
56
70
|
} catch (error) {
|
|
57
71
|
logger.error(`${appConfig.appName} starup error:`, error);
|
|
58
72
|
}
|
|
@@ -4,8 +4,7 @@ import {
|
|
|
4
4
|
type BootstrapContextValue,
|
|
5
5
|
type BootstrapExecutorPlugin,
|
|
6
6
|
type IOCContainerInterface,
|
|
7
|
-
type IOCFunctionInterface
|
|
8
|
-
type LoggerInterface
|
|
7
|
+
type IOCFunctionInterface
|
|
9
8
|
} from '@qlover/corekit-bridge';
|
|
10
9
|
import {
|
|
11
10
|
AsyncExecutor,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
import type { ServerInterface } from '@/server/port/ServerInterface';
|
|
17
16
|
import { I, type IOCIdentifierMapServer } from '@config/IOCIdentifier';
|
|
18
17
|
import { ServerIOC } from '../serverIoc/ServerIOC';
|
|
18
|
+
import type { LoggerInterface } from '@qlover/logger';
|
|
19
19
|
|
|
20
20
|
export interface BootstrapServerContextValue extends BootstrapContextValue {
|
|
21
21
|
IOC: IOCFunctionInterface<IOCIdentifierMapServer, IOCContainerInterface>;
|
|
@@ -28,7 +28,7 @@ export class BootstrapServer implements ServerInterface {
|
|
|
28
28
|
IOCIdentifierMapServer,
|
|
29
29
|
IOCContainerInterface
|
|
30
30
|
>;
|
|
31
|
-
readonly logger: LoggerInterface;
|
|
31
|
+
public readonly logger: LoggerInterface;
|
|
32
32
|
|
|
33
33
|
constructor() {
|
|
34
34
|
const serverIOC = ServerIOC.create();
|
|
@@ -40,12 +40,27 @@ export class BootstrapServer implements ServerInterface {
|
|
|
40
40
|
this.logger = logger;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* @override
|
|
45
|
+
*/
|
|
46
|
+
public getIOC(): IOCFunctionInterface<
|
|
47
|
+
IOCIdentifierMapServer,
|
|
48
|
+
IOCContainerInterface
|
|
49
|
+
>;
|
|
50
|
+
/**
|
|
51
|
+
* @override
|
|
52
|
+
*/
|
|
53
|
+
public getIOC<T extends keyof IOCIdentifierMapServer>(
|
|
45
54
|
identifier: T
|
|
46
55
|
): IOCIdentifierMapServer[T];
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
/**
|
|
57
|
+
* @override
|
|
58
|
+
*/
|
|
59
|
+
public getIOC<T>(serviceIdentifier: ServiceIdentifier<T>): T;
|
|
60
|
+
/**
|
|
61
|
+
* @override
|
|
62
|
+
*/
|
|
63
|
+
public getIOC<T extends keyof IOCIdentifierMapServer>(
|
|
49
64
|
identifier?: T
|
|
50
65
|
):
|
|
51
66
|
| IOCFunctionInterface<IOCIdentifierMapServer, IOCContainerInterface>
|
|
@@ -59,7 +74,7 @@ export class BootstrapServer implements ServerInterface {
|
|
|
59
74
|
/**
|
|
60
75
|
* @override
|
|
61
76
|
*/
|
|
62
|
-
use(
|
|
77
|
+
public use(
|
|
63
78
|
plugin:
|
|
64
79
|
| BootstrapExecutorPlugin
|
|
65
80
|
| BootstrapExecutorPlugin[]
|
|
@@ -78,7 +93,10 @@ export class BootstrapServer implements ServerInterface {
|
|
|
78
93
|
return this;
|
|
79
94
|
}
|
|
80
95
|
|
|
81
|
-
|
|
96
|
+
/**
|
|
97
|
+
* @override
|
|
98
|
+
*/
|
|
99
|
+
public execNoError<Result>(
|
|
82
100
|
task?: PromiseTask<Result, BootstrapServerContextValue>
|
|
83
101
|
): Promise<Result | ExecutorError> {
|
|
84
102
|
const context = {
|
|
@@ -14,15 +14,18 @@ import type {
|
|
|
14
14
|
export class BootstrapsRegistry {
|
|
15
15
|
constructor(protected args: BootstrapAppArgs) {}
|
|
16
16
|
|
|
17
|
-
get IOC(): IOCFunctionInterface<
|
|
17
|
+
public get IOC(): IOCFunctionInterface<
|
|
18
|
+
IOCIdentifierMap,
|
|
19
|
+
IOCContainerInterface
|
|
20
|
+
> {
|
|
18
21
|
return this.args.IOC;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
get appConfig(): EnvConfigInterface {
|
|
24
|
+
public get appConfig(): EnvConfigInterface {
|
|
22
25
|
return this.IOC(IOCIdentifier.AppConfig);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
|
-
register(): BootstrapExecutorPlugin[] {
|
|
28
|
+
public register(): BootstrapExecutorPlugin[] {
|
|
26
29
|
const IOC = this.IOC;
|
|
27
30
|
|
|
28
31
|
const i18nService = IOC(IOCIdentifier.I18nServiceInterface);
|
|
@@ -41,7 +44,6 @@ export class BootstrapsRegistry {
|
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
bootstrapList.push(IocIdentifierTest);
|
|
44
|
-
// TODO: 需要使用到
|
|
45
47
|
|
|
46
48
|
return bootstrapList;
|
|
47
49
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createIOCFunction,
|
|
3
3
|
type IOCContainerInterface,
|
|
4
|
-
type IOCFunctionInterface
|
|
4
|
+
type IOCFunctionInterface,
|
|
5
|
+
type IOCRegisterInterface
|
|
5
6
|
} from '@qlover/corekit-bridge';
|
|
6
7
|
import { InversifyContainer } from '@/base/cases/InversifyContainer';
|
|
7
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
IOCInterface,
|
|
10
|
+
IocRegisterOptions
|
|
11
|
+
} from '@/base/port/IOCInterface';
|
|
8
12
|
import type { IOCIdentifierMap } from '@config/IOCIdentifier';
|
|
9
13
|
import { ClientIOCRegister } from './ClientIOCRegister';
|
|
10
|
-
import {
|
|
14
|
+
import { logger } from '../globals';
|
|
11
15
|
|
|
12
16
|
export class ClientIOC implements IOCInterface<
|
|
13
17
|
IOCIdentifierMap,
|
|
@@ -17,21 +21,47 @@ export class ClientIOC implements IOCInterface<
|
|
|
17
21
|
IOCIdentifierMap,
|
|
18
22
|
IOCContainerInterface
|
|
19
23
|
> | null = null;
|
|
24
|
+
protected registers = 0;
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
constructor(
|
|
27
|
+
protected readonly iocRegister?: IOCRegisterInterface<
|
|
28
|
+
IOCContainerInterface,
|
|
29
|
+
IocRegisterOptions
|
|
30
|
+
>
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @override
|
|
35
|
+
*/
|
|
36
|
+
public create(): IOCFunctionInterface<
|
|
37
|
+
IOCIdentifierMap,
|
|
38
|
+
IOCContainerInterface
|
|
39
|
+
> {
|
|
22
40
|
if (this.ioc) {
|
|
23
41
|
return this.ioc;
|
|
24
42
|
}
|
|
25
43
|
|
|
26
44
|
this.ioc = createIOCFunction<IOCIdentifierMap>(new InversifyContainer());
|
|
27
45
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
46
|
+
return this.ioc;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @override
|
|
51
|
+
*/
|
|
52
|
+
public register(options: IocRegisterOptions): void {
|
|
53
|
+
if (this.registers > 0) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
31
56
|
|
|
32
|
-
|
|
57
|
+
if (!this.ioc) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
33
60
|
|
|
34
|
-
|
|
61
|
+
logger.info('ClientIOC register');
|
|
62
|
+
new ClientIOCRegister(options).register(this.ioc.implemention!, this.ioc);
|
|
63
|
+
|
|
64
|
+
this.registers++;
|
|
35
65
|
}
|
|
36
66
|
}
|
|
37
67
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { CookieStorage } from '@qlover/corekit-bridge';
|
|
1
2
|
import { RouterService } from '@/base/cases/RouterService';
|
|
2
3
|
import type { IocRegisterOptions } from '@/base/port/IOCInterface';
|
|
3
4
|
import { I18nService } from '@/base/services/I18nService';
|
|
4
5
|
import { UserService } from '@/base/services/UserService';
|
|
6
|
+
import { cookiesConfig } from '@config/cookies';
|
|
5
7
|
import { IOCIdentifier as I } from '@config/IOCIdentifier';
|
|
6
8
|
import { dialogHandler, logger, JSON } from '../globals';
|
|
7
9
|
import type {
|
|
@@ -21,6 +23,7 @@ export class ClientIOCRegister implements IOCRegisterInterface<
|
|
|
21
23
|
*
|
|
22
24
|
* 一般用于注册全局
|
|
23
25
|
*
|
|
26
|
+
* @override
|
|
24
27
|
* @param ioc - IOC container
|
|
25
28
|
*/
|
|
26
29
|
protected registerGlobals(ioc: IOCContainerInterface): void {
|
|
@@ -34,7 +37,7 @@ export class ClientIOCRegister implements IOCRegisterInterface<
|
|
|
34
37
|
// ioc.bind(I.AntdStaticApiInterface, dialogHandler);
|
|
35
38
|
// ioc.bind(I.LocalStorage, globals.localStorage);
|
|
36
39
|
// ioc.bind(I.LocalStorageEncrypt, localStorageEncrypt);
|
|
37
|
-
|
|
40
|
+
ioc.bind(I.CookieStorage, new CookieStorage(cookiesConfig));
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
/**
|
|
@@ -45,6 +48,7 @@ export class ClientIOCRegister implements IOCRegisterInterface<
|
|
|
45
48
|
* - 国际化服务
|
|
46
49
|
* - 主题服务
|
|
47
50
|
*
|
|
51
|
+
* @override
|
|
48
52
|
* @param ioc
|
|
49
53
|
*/
|
|
50
54
|
protected registerImplement(ioc: IOCContainerInterface): void {
|
|
@@ -66,6 +70,9 @@ export class ClientIOCRegister implements IOCRegisterInterface<
|
|
|
66
70
|
// ioc.bind(I.RequestPageBridgeInterface, ioc.get(RequestPageBridge));
|
|
67
71
|
}
|
|
68
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @override
|
|
75
|
+
*/
|
|
69
76
|
protected registerCommon(_ioc: IOCContainerInterface): void {
|
|
70
77
|
// const { appConfig } = this.options;
|
|
71
78
|
// const logger = ioc.get(I.Logger);
|
|
@@ -87,7 +94,7 @@ export class ClientIOCRegister implements IOCRegisterInterface<
|
|
|
87
94
|
/**
|
|
88
95
|
* @override
|
|
89
96
|
*/
|
|
90
|
-
register(
|
|
97
|
+
public register(
|
|
91
98
|
ioc: IOCContainerInterface,
|
|
92
99
|
_manager: IOCManagerInterface<IOCContainerInterface>
|
|
93
100
|
): void {
|
|
@@ -5,7 +5,10 @@ import {
|
|
|
5
5
|
} from '@qlover/corekit-bridge';
|
|
6
6
|
import { AppConfig } from '@/base/cases/AppConfig';
|
|
7
7
|
import { InversifyContainer } from '@/base/cases/InversifyContainer';
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
IOCInterface,
|
|
10
|
+
IocRegisterOptions
|
|
11
|
+
} from '@/base/port/IOCInterface';
|
|
9
12
|
import type { IOCIdentifierMapServer } from '@config/IOCIdentifier';
|
|
10
13
|
import { ServerIOCRegister } from './ServerIOCRegister';
|
|
11
14
|
|
|
@@ -13,14 +16,19 @@ export class ServerIOC implements IOCInterface<
|
|
|
13
16
|
IOCIdentifierMapServer,
|
|
14
17
|
IOCContainerInterface
|
|
15
18
|
> {
|
|
16
|
-
static instance: ServerIOC | null = null;
|
|
19
|
+
public static instance: ServerIOC | null = null;
|
|
20
|
+
|
|
21
|
+
protected registers = 0;
|
|
17
22
|
|
|
18
23
|
protected ioc: IOCFunctionInterface<
|
|
19
24
|
IOCIdentifierMapServer,
|
|
20
25
|
IOCContainerInterface
|
|
21
26
|
> | null = null;
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @override
|
|
30
|
+
*/
|
|
31
|
+
public static create(): ServerIOC {
|
|
24
32
|
if (this.instance) {
|
|
25
33
|
return this.instance;
|
|
26
34
|
}
|
|
@@ -30,7 +38,10 @@ export class ServerIOC implements IOCInterface<
|
|
|
30
38
|
return this.instance;
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
|
|
41
|
+
/**
|
|
42
|
+
* @override
|
|
43
|
+
*/
|
|
44
|
+
public create(): IOCFunctionInterface<
|
|
34
45
|
IOCIdentifierMapServer,
|
|
35
46
|
IOCContainerInterface
|
|
36
47
|
> {
|
|
@@ -38,16 +49,32 @@ export class ServerIOC implements IOCInterface<
|
|
|
38
49
|
return this.ioc;
|
|
39
50
|
}
|
|
40
51
|
|
|
41
|
-
this.ioc = createIOCFunction
|
|
42
|
-
new InversifyContainer()
|
|
43
|
-
);
|
|
52
|
+
this.ioc = createIOCFunction(new InversifyContainer());
|
|
44
53
|
|
|
45
|
-
|
|
54
|
+
// 注册默认依赖
|
|
55
|
+
this.register({
|
|
46
56
|
appConfig: new AppConfig()
|
|
47
57
|
});
|
|
48
58
|
|
|
49
|
-
register.register(this.ioc.implemention!, this.ioc);
|
|
50
|
-
|
|
51
59
|
return this.ioc;
|
|
52
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @override
|
|
64
|
+
*/
|
|
65
|
+
public register(options: IocRegisterOptions): void {
|
|
66
|
+
if (this.registers > 0) {
|
|
67
|
+
console.debug('ServerIOC: ioc already registered');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!this.ioc) {
|
|
72
|
+
console.debug('ServerIOC: ioc not initialized');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
new ServerIOCRegister(options).register(this.ioc.implemention!, this.ioc);
|
|
77
|
+
|
|
78
|
+
this.registers++;
|
|
79
|
+
}
|
|
53
80
|
}
|