@qlover/create-app 0.3.1 → 0.3.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 +96 -0
- package/configs/_common/.github/workflows/general-check.yml +17 -29
- package/configs/_common/.github/workflows/{release.yml.template → release.yml} +16 -51
- package/package.json +3 -3
- package/templates/pack-app/fe-config.json +30 -1
- package/templates/pack-app/package.json +45 -32
- package/templates/pack-app/tsconfig.test.json +1 -1
- package/templates/react-app/config/Identifier.I18n.ts +878 -0
- package/templates/react-app/config/app.router.json +7 -7
- package/templates/react-app/config/common.ts +7 -4
- package/templates/react-app/config/theme.json +7 -88
- package/templates/react-app/package.json +9 -4
- package/templates/react-app/postcss.config.js +1 -2
- package/templates/react-app/public/locales/en/common.json +118 -1
- package/templates/react-app/public/locales/zh/common.json +118 -1
- package/templates/react-app/src/App.tsx +14 -2
- package/templates/react-app/src/base/cases/RequestLogger.ts +3 -4
- package/templates/react-app/src/base/cases/RequestStatusCatcher.ts +3 -2
- package/templates/react-app/src/base/services/I18nService.ts +31 -3
- package/templates/react-app/src/base/services/ProcesserService.ts +3 -2
- package/templates/react-app/src/core/IOC.ts +15 -9
- package/templates/react-app/src/core/bootstrap.ts +42 -53
- package/templates/react-app/src/core/bootstraps/PrintBootstrap.ts +14 -0
- package/templates/react-app/src/core/bootstraps/index.ts +36 -7
- package/templates/react-app/src/core/globals.ts +4 -6
- package/templates/react-app/src/core/registers/RegisterApi.ts +2 -5
- package/templates/react-app/src/core/registers/RegisterCommon.ts +38 -28
- package/templates/react-app/src/core/registers/RegisterControllers.ts +5 -10
- package/templates/react-app/src/core/registers/RegisterGlobals.ts +15 -14
- package/templates/react-app/src/core/registers/index.ts +27 -12
- package/templates/react-app/src/main.tsx +1 -1
- package/templates/react-app/src/pages/404.tsx +1 -1
- package/templates/react-app/src/pages/500.tsx +1 -1
- package/templates/react-app/src/pages/auth/Login.tsx +128 -36
- package/templates/react-app/src/pages/base/About.tsx +5 -2
- package/templates/react-app/src/pages/base/ErrorIdentifier.tsx +38 -19
- package/templates/react-app/src/pages/base/Executor.tsx +447 -29
- package/templates/react-app/src/pages/base/Home.tsx +99 -93
- package/templates/react-app/src/pages/base/JSONStorage.tsx +47 -38
- package/templates/react-app/src/pages/base/Layout.tsx +5 -2
- package/templates/react-app/src/pages/base/Request.tsx +90 -208
- package/templates/react-app/src/pages/base/components/BaseHeader.tsx +13 -5
- package/templates/react-app/src/styles/css/page.css +11 -0
- package/templates/react-app/src/styles/css/tailwind.css +5 -0
- package/templates/react-app/src/styles/css/themes/_default.css +200 -0
- package/templates/react-app/src/styles/css/themes/dark.css +154 -0
- package/templates/react-app/src/styles/css/themes/index.css +3 -0
- package/templates/react-app/src/styles/css/themes/pink.css +160 -0
- package/templates/react-app/src/uikit/components/LanguageSwitcher.tsx +56 -0
- package/templates/react-app/src/uikit/components/Loading.tsx +27 -21
- package/templates/react-app/src/uikit/components/ThemeSwitcher.tsx +63 -13
- package/templates/react-app/src/uikit/contexts/BaseRouteContext.ts +1 -1
- package/templates/react-app/src/uikit/controllers/RouterController.ts +3 -3
- package/templates/react-app/src/uikit/controllers/UserController.ts +1 -1
- package/templates/react-app/tailwind.config.js +1 -15
- package/templates/react-app/vite.config.ts +9 -3
- package/templates/react-app/lib/tailwind/root10px.js +0 -178
- package/templates/react-app/lib/tailwind/theme-generator.js +0 -238
- package/templates/react-app/public/locales/en/about.json +0 -3
- package/templates/react-app/public/locales/en/executor.json +0 -6
- package/templates/react-app/public/locales/en/home.json +0 -10
- package/templates/react-app/public/locales/en/jsonStorage.json +0 -11
- package/templates/react-app/public/locales/en/login.json +0 -7
- package/templates/react-app/public/locales/en/request.json +0 -15
- package/templates/react-app/public/locales/zh/about.json +0 -3
- package/templates/react-app/public/locales/zh/executor.json +0 -7
- package/templates/react-app/public/locales/zh/home.json +0 -10
- package/templates/react-app/public/locales/zh/jsonStorage.json +0 -11
- package/templates/react-app/public/locales/zh/login.json +0 -8
- package/templates/react-app/public/locales/zh/request.json +0 -15
- package/templates/react-app/src/base/port/InversifyIocInterface.ts +0 -9
- package/templates/react-app/src/uikit/styles/css/page.css +0 -3
- package/templates/react-app/src/uikit/styles/css/tailwind.css +0 -3
- /package/templates/react-app/config/{ErrorIdentifier.ts → Identifier.Error.ts} +0 -0
- /package/templates/react-app/src/{uikit/styles → styles}/css/index.css +0 -0
|
@@ -9,9 +9,21 @@ import {
|
|
|
9
9
|
createIOCFunction,
|
|
10
10
|
ServiceIdentifier
|
|
11
11
|
} from '@qlover/corekit-bridge';
|
|
12
|
-
import type { JSONSerializer, JSONStorage
|
|
12
|
+
import type { JSONSerializer, JSONStorage } from '@qlover/fe-corekit';
|
|
13
|
+
import type { LoggerInterface } from '@qlover/logger';
|
|
13
14
|
import { Container } from 'inversify';
|
|
14
|
-
import {
|
|
15
|
+
import { IOCRegisterInterface } from '@qlover/corekit-bridge';
|
|
16
|
+
|
|
17
|
+
export type IocRegisterOptions = {
|
|
18
|
+
pathname: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type InversifyRegisterContainer = Container;
|
|
22
|
+
/**
|
|
23
|
+
* Inversify register interface.
|
|
24
|
+
*/
|
|
25
|
+
export interface InversifyRegisterInterface
|
|
26
|
+
extends IOCRegisterInterface<InversifyContainer, IocRegisterOptions> {}
|
|
15
27
|
|
|
16
28
|
export class InversifyContainer implements IOCContainerInterface {
|
|
17
29
|
private container: Container;
|
|
@@ -25,12 +37,6 @@ export class InversifyContainer implements IOCContainerInterface {
|
|
|
25
37
|
});
|
|
26
38
|
}
|
|
27
39
|
|
|
28
|
-
configure(registers?: InversifyRegisterInterface[]): void {
|
|
29
|
-
if (registers) {
|
|
30
|
-
registers.forEach((register) => register.register(this.container, this));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
40
|
bind<T>(key: ServiceIdentifier<T>, value: T): void {
|
|
35
41
|
this.container.bind<T>(key).toConstantValue(value);
|
|
36
42
|
}
|
|
@@ -75,7 +81,7 @@ export const IOCIdentifier = Object.freeze({
|
|
|
75
81
|
export interface IOCIdentifierMap {
|
|
76
82
|
[IOCIdentifier.JSON]: JSONSerializer;
|
|
77
83
|
[IOCIdentifier.JSONStorage]: JSONStorage;
|
|
78
|
-
[IOCIdentifier.Logger]:
|
|
84
|
+
[IOCIdentifier.Logger]: LoggerInterface;
|
|
79
85
|
[IOCIdentifier.FeApiToken]: StorageTokenInterface<string>;
|
|
80
86
|
[IOCIdentifier.FeApiCommonPlugin]: RequestCommonPlugin;
|
|
81
87
|
[IOCIdentifier.AppConfig]: EnvConfigInterface;
|
|
@@ -1,78 +1,67 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Bootstrap,
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
type InjectGlobalConfig,
|
|
4
|
+
type InjectIOCOptions,
|
|
5
|
+
type IOCContainerInterface,
|
|
6
|
+
type InjectEnvConfig
|
|
7
7
|
} from '@qlover/corekit-bridge';
|
|
8
8
|
import AppConfig from '@/core/AppConfig';
|
|
9
|
-
import { envPrefix, browserGlobalsName
|
|
9
|
+
import { envBlackList, envPrefix, browserGlobalsName } from '@config/common';
|
|
10
10
|
import { IOC } from './IOC';
|
|
11
11
|
import * as globals from '@/core/globals';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { GLOBAL_NO_WINDOW } from '@config/ErrorIdentifier';
|
|
12
|
+
import { IocRegister } from './registers';
|
|
13
|
+
import { BootstrapsRegistry } from './bootstraps';
|
|
14
|
+
import { GLOBAL_NO_WINDOW } from '@config/Identifier.Error';
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
onSuccess({ parameters: { logger } }) {
|
|
20
|
-
logger.info(
|
|
21
|
-
'bootstrap success!\n\n' +
|
|
22
|
-
`You can use \`%cwindow.${browserGlobalsName}%c\` to access the globals`,
|
|
23
|
-
'color: #0ff; font-weight: bold;',
|
|
24
|
-
'all: unset;'
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Bootstrap
|
|
31
|
-
*
|
|
32
|
-
* 1. inject env config to AppConfig
|
|
33
|
-
* 2. inject IOC to Application
|
|
34
|
-
* 3. inject globals to window
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
export default function startup({
|
|
38
|
-
window,
|
|
16
|
+
export default async function startup({
|
|
17
|
+
root,
|
|
39
18
|
envSource
|
|
40
19
|
}: {
|
|
41
|
-
|
|
20
|
+
root: unknown;
|
|
42
21
|
envSource: Record<string, unknown>;
|
|
43
22
|
}) {
|
|
44
|
-
if (!(typeof
|
|
23
|
+
if (!(typeof root !== 'undefined' && root instanceof Window)) {
|
|
45
24
|
throw new Error(GLOBAL_NO_WINDOW);
|
|
46
25
|
}
|
|
47
26
|
|
|
48
27
|
const { logger } = globals;
|
|
49
28
|
|
|
50
|
-
const
|
|
29
|
+
const envOptions: InjectEnvConfig = {
|
|
30
|
+
target: AppConfig,
|
|
31
|
+
source: envSource,
|
|
32
|
+
prefix: envPrefix,
|
|
33
|
+
blackList: envBlackList
|
|
34
|
+
};
|
|
51
35
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* - inject i18n service to Application
|
|
59
|
-
*/
|
|
60
|
-
const bootstrapList: BootstrapExecutorPlugin[] = [
|
|
61
|
-
new InjectEnv(AppConfig, envSource, envPrefix, envBlackList),
|
|
62
|
-
new InjectIOC(IOC, registerList),
|
|
63
|
-
new InjectGlobal(globals, browserGlobalsName),
|
|
64
|
-
new I18nService(window.location.pathname),
|
|
65
|
-
...appBootstrapList
|
|
66
|
-
];
|
|
36
|
+
const iocOptions: InjectIOCOptions<IOCContainerInterface> = {
|
|
37
|
+
manager: IOC,
|
|
38
|
+
register: new IocRegister({
|
|
39
|
+
pathname: root.location.pathname
|
|
40
|
+
})
|
|
41
|
+
};
|
|
67
42
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
43
|
+
const globalOptions: InjectGlobalConfig = {
|
|
44
|
+
sources: globals,
|
|
45
|
+
target: browserGlobalsName
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const bootstrap = new Bootstrap({
|
|
49
|
+
root,
|
|
50
|
+
logger,
|
|
51
|
+
ioc: iocOptions,
|
|
52
|
+
envOptions,
|
|
53
|
+
globalOptions
|
|
54
|
+
});
|
|
71
55
|
|
|
72
56
|
try {
|
|
73
57
|
logger.info('bootstrap start...');
|
|
74
58
|
|
|
75
|
-
bootstrap
|
|
59
|
+
// init bootstrap
|
|
60
|
+
await bootstrap.initialize();
|
|
61
|
+
|
|
62
|
+
const bootstrapsRegistry = new BootstrapsRegistry(IOC);
|
|
63
|
+
|
|
64
|
+
await bootstrap.use(bootstrapsRegistry.register()).start();
|
|
76
65
|
} catch (error) {
|
|
77
66
|
logger.error(`${AppConfig.appName} starup error:`, error);
|
|
78
67
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { browserGlobalsName } from '@config/common';
|
|
2
|
+
import { BootstrapExecutorPlugin } from '@qlover/corekit-bridge';
|
|
3
|
+
|
|
4
|
+
export const printBootstrap: BootstrapExecutorPlugin = {
|
|
5
|
+
pluginName: 'PrintBootstrap',
|
|
6
|
+
onSuccess({ parameters: { logger } }) {
|
|
7
|
+
logger.info(
|
|
8
|
+
'bootstrap success!\n\n' +
|
|
9
|
+
`You can use \`%cwindow.${browserGlobalsName}%c\` to access the globals`,
|
|
10
|
+
'color: #0ff; font-weight: bold;',
|
|
11
|
+
'all: unset;'
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -1,12 +1,41 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
BootstrapExecutorPlugin,
|
|
3
|
+
EnvConfigInterface,
|
|
4
|
+
IOCContainerInterface,
|
|
5
|
+
IOCFunctionInterface
|
|
6
|
+
} from '@qlover/corekit-bridge';
|
|
2
7
|
import { BootstrapApp } from './BootstrapApp';
|
|
3
8
|
import { UserApiBootstarp } from '@/base/apis/userApi/UserApiBootstarp';
|
|
4
9
|
import { FeApiBootstarp } from '@/base/apis/feApi/FeApiBootstarp';
|
|
5
10
|
import { AiApiBootstarp } from '@/base/apis/AiApi';
|
|
11
|
+
import { printBootstrap } from './PrintBootstrap';
|
|
12
|
+
import { IOCIdentifier, type IOCIdentifierMap } from '../IOC';
|
|
13
|
+
import { I18nService } from '@/base/services/I18nService';
|
|
6
14
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
export class BootstrapsRegistry {
|
|
16
|
+
constructor(
|
|
17
|
+
protected IOC: IOCFunctionInterface<IOCIdentifierMap, IOCContainerInterface>
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
get appConfig(): EnvConfigInterface {
|
|
21
|
+
return this.IOC(IOCIdentifier.AppConfig);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
register(): BootstrapExecutorPlugin[] {
|
|
25
|
+
const IOC = this.IOC;
|
|
26
|
+
|
|
27
|
+
const bootstrapList = [
|
|
28
|
+
IOC(I18nService),
|
|
29
|
+
new UserApiBootstarp(),
|
|
30
|
+
new FeApiBootstarp(),
|
|
31
|
+
AiApiBootstarp,
|
|
32
|
+
new BootstrapApp()
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
if (this.appConfig.env !== 'production') {
|
|
36
|
+
bootstrapList.push(printBootstrap);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return bootstrapList;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
// ! global variables, don't import any dependencies and don't have side effects
|
|
2
2
|
import { JSONStorage, JSONSerializer, SyncStorage } from '@qlover/fe-corekit';
|
|
3
|
-
import {
|
|
4
|
-
import { loggerStyles } from '@config/common';
|
|
3
|
+
import { ColorFormatter, ConsoleHandler, Logger } from '@qlover/corekit-bridge';
|
|
5
4
|
|
|
6
5
|
const isProduction = import.meta.env.VITE_USER_NODE_ENV === 'production';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Global logger
|
|
10
9
|
*/
|
|
11
|
-
export const logger = new
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
colorsMaps: loggerStyles
|
|
10
|
+
export const logger = new Logger({
|
|
11
|
+
handlers: new ConsoleHandler(new ColorFormatter()),
|
|
12
|
+
silent: isProduction
|
|
15
13
|
});
|
|
16
14
|
|
|
17
15
|
/**
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
InversifyRegisterInterface,
|
|
3
|
-
InversifyRegisterContainer
|
|
4
|
-
} from '@/base/port/InversifyIocInterface';
|
|
1
|
+
import { InversifyContainer, InversifyRegisterInterface } from '../IOC';
|
|
5
2
|
|
|
6
3
|
export class RegisterApi implements InversifyRegisterInterface {
|
|
7
|
-
register(_container:
|
|
4
|
+
register(_container: InversifyContainer): void {}
|
|
8
5
|
}
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FetchAbortPlugin, JSONStorage } from '@qlover/fe-corekit';
|
|
2
|
+
import { Logger } from '@qlover/logger';
|
|
3
|
+
import {
|
|
4
|
+
InversifyContainer,
|
|
2
5
|
InversifyRegisterInterface,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import AppConfig from '@/core/AppConfig';
|
|
7
|
-
import { IOCIdentifier } from '@/core/IOC';
|
|
6
|
+
IOCIdentifier,
|
|
7
|
+
IocRegisterOptions
|
|
8
|
+
} from '@/core/IOC';
|
|
8
9
|
import {
|
|
9
10
|
UserToken,
|
|
10
11
|
RequestCommonPlugin,
|
|
11
12
|
ApiMockPlugin,
|
|
12
13
|
ApiCatchPlugin,
|
|
13
|
-
ThemeService
|
|
14
|
+
ThemeService,
|
|
15
|
+
IOCManagerInterface
|
|
14
16
|
} from '@qlover/corekit-bridge';
|
|
15
17
|
import mockDataJson from '@config/feapi.mock.json';
|
|
16
18
|
import { RequestStatusCatcher } from '@/base/cases/RequestStatusCatcher';
|
|
17
|
-
import
|
|
19
|
+
import themeConfig from '@config/theme.json';
|
|
18
20
|
import { localJsonStorage } from '../globals';
|
|
21
|
+
import { I18nService } from '@/base/services/I18nService';
|
|
19
22
|
|
|
20
23
|
export class RegisterCommon implements InversifyRegisterInterface {
|
|
21
|
-
register(
|
|
24
|
+
register(
|
|
25
|
+
container: InversifyContainer,
|
|
26
|
+
_: IOCManagerInterface<InversifyContainer>,
|
|
27
|
+
options: IocRegisterOptions
|
|
28
|
+
): void {
|
|
29
|
+
const AppConfig = container.get(IOCIdentifier.AppConfig);
|
|
30
|
+
|
|
22
31
|
const userToken = new UserToken(
|
|
23
32
|
AppConfig.userTokenStorageKey,
|
|
24
33
|
container.get(JSONStorage)
|
|
@@ -30,30 +39,31 @@ export class RegisterCommon implements InversifyRegisterInterface {
|
|
|
30
39
|
token: () => userToken.getToken()
|
|
31
40
|
});
|
|
32
41
|
|
|
33
|
-
container.bind(FetchAbortPlugin
|
|
34
|
-
container.bind(UserToken
|
|
42
|
+
container.bind(FetchAbortPlugin, feApiAbort);
|
|
43
|
+
container.bind(UserToken, userToken);
|
|
35
44
|
|
|
36
|
-
container.bind(IOCIdentifier.FeApiToken
|
|
37
|
-
container
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
50
|
-
);
|
|
45
|
+
container.bind(IOCIdentifier.FeApiToken, userToken);
|
|
46
|
+
container.bind(IOCIdentifier.FeApiCommonPlugin, feApiRequestCommonPlugin);
|
|
47
|
+
container.bind(
|
|
48
|
+
IOCIdentifier.ApiMockPlugin,
|
|
49
|
+
new ApiMockPlugin(mockDataJson, container.get(Logger))
|
|
50
|
+
);
|
|
51
|
+
container.bind(
|
|
52
|
+
IOCIdentifier.ApiCatchPlugin,
|
|
53
|
+
new ApiCatchPlugin(
|
|
54
|
+
container.get(Logger),
|
|
55
|
+
container.get(RequestStatusCatcher)
|
|
56
|
+
)
|
|
57
|
+
);
|
|
51
58
|
|
|
52
|
-
container.bind(
|
|
59
|
+
container.bind(
|
|
60
|
+
ThemeService,
|
|
53
61
|
new ThemeService({
|
|
54
|
-
...
|
|
62
|
+
...themeConfig,
|
|
55
63
|
storage: localJsonStorage
|
|
56
64
|
})
|
|
57
65
|
);
|
|
66
|
+
|
|
67
|
+
container.bind(I18nService, new I18nService(options.pathname));
|
|
58
68
|
}
|
|
59
69
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
InversifyRegisterInterface,
|
|
3
|
-
InversifyRegisterContainer
|
|
4
|
-
} from '@/base/port/InversifyIocInterface';
|
|
5
|
-
|
|
6
1
|
import { localJsonStorage, logger } from '../globals';
|
|
7
2
|
import { RouterController } from '@/uikit/controllers/RouterController';
|
|
8
3
|
import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
|
|
9
4
|
import { ProcesserService } from '@/base/services/ProcesserService';
|
|
10
5
|
import { UserController } from '@/uikit/controllers/UserController';
|
|
11
6
|
import { base as baseRoutes } from '@config/app.router.json';
|
|
7
|
+
import { InversifyRegisterInterface } from '../IOC';
|
|
8
|
+
import { InversifyContainer } from '../IOC';
|
|
12
9
|
|
|
13
10
|
export class RegisterControllers implements InversifyRegisterInterface {
|
|
14
|
-
register(container:
|
|
11
|
+
register(container: InversifyContainer): void {
|
|
15
12
|
const routerController = new RouterController({
|
|
16
13
|
config: baseRoutes,
|
|
17
14
|
logger
|
|
@@ -19,10 +16,8 @@ export class RegisterControllers implements InversifyRegisterInterface {
|
|
|
19
16
|
|
|
20
17
|
const jsonStorageController = new JSONStorageController(localJsonStorage);
|
|
21
18
|
|
|
22
|
-
container.bind(RouterController
|
|
23
|
-
container
|
|
24
|
-
.bind(JSONStorageController)
|
|
25
|
-
.toConstantValue(jsonStorageController);
|
|
19
|
+
container.bind(RouterController, routerController);
|
|
20
|
+
container.bind(JSONStorageController, jsonStorageController);
|
|
26
21
|
|
|
27
22
|
container.get(ProcesserService).use(container.get(UserController));
|
|
28
23
|
}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { JSONSerializer, JSONStorage
|
|
1
|
+
import { JSONSerializer, JSONStorage } from '@qlover/fe-corekit';
|
|
2
2
|
import type { EnvConfigInterface } from '@qlover/corekit-bridge';
|
|
3
|
-
import type {
|
|
4
|
-
InversifyRegisterInterface,
|
|
5
|
-
InversifyRegisterContainer
|
|
6
|
-
} from '@/base/port/InversifyIocInterface';
|
|
7
3
|
import { JSON, localJsonStorage, logger } from '../globals';
|
|
8
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type InversifyContainer,
|
|
6
|
+
type InversifyRegisterInterface,
|
|
7
|
+
IOCIdentifier
|
|
8
|
+
} from '@/core/IOC';
|
|
9
|
+
import { Logger } from '@qlover/logger';
|
|
9
10
|
|
|
10
11
|
export class RegisterGlobals implements InversifyRegisterInterface {
|
|
11
12
|
constructor(private appConfig: EnvConfigInterface) {}
|
|
12
13
|
|
|
13
|
-
register(container:
|
|
14
|
+
register(container: InversifyContainer): void {
|
|
14
15
|
// inject AppConfig to IOC
|
|
15
|
-
container.bind(IOCIdentifier.AppConfig
|
|
16
|
+
container.bind(IOCIdentifier.AppConfig, this.appConfig);
|
|
16
17
|
|
|
17
|
-
container.bind(JSONSerializer
|
|
18
|
-
container.bind(IOCIdentifier.JSON
|
|
18
|
+
container.bind(JSONSerializer, JSON);
|
|
19
|
+
container.bind(IOCIdentifier.JSON, JSON);
|
|
19
20
|
|
|
20
|
-
container.bind(Logger
|
|
21
|
-
container.bind(IOCIdentifier.Logger
|
|
21
|
+
container.bind(Logger, logger);
|
|
22
|
+
container.bind(IOCIdentifier.Logger, logger);
|
|
22
23
|
|
|
23
|
-
container.bind(JSONStorage
|
|
24
|
-
container.bind(IOCIdentifier.JSONStorage
|
|
24
|
+
container.bind(JSONStorage, localJsonStorage);
|
|
25
|
+
container.bind(IOCIdentifier.JSONStorage, localJsonStorage);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
|
-
import type { InversifyRegisterInterface } from '@/base/port/InversifyIocInterface';
|
|
2
1
|
import { RegisterGlobals } from './RegisterGlobals';
|
|
3
2
|
import { RegisterCommon } from './RegisterCommon';
|
|
4
3
|
import { RegisterApi } from './RegisterApi';
|
|
5
4
|
import { RegisterControllers } from './RegisterControllers';
|
|
6
5
|
import AppConfig from '../AppConfig';
|
|
6
|
+
import {
|
|
7
|
+
InversifyContainer,
|
|
8
|
+
InversifyRegisterInterface,
|
|
9
|
+
IocRegisterOptions
|
|
10
|
+
} from '../IOC';
|
|
11
|
+
import { IOCManagerInterface } from '@qlover/corekit-bridge';
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
export class IocRegister implements InversifyRegisterInterface {
|
|
14
|
+
constructor(protected options: IocRegisterOptions) {}
|
|
15
|
+
|
|
16
|
+
getRegisterList(): InversifyRegisterInterface[] {
|
|
17
|
+
return [
|
|
18
|
+
new RegisterGlobals(AppConfig),
|
|
19
|
+
new RegisterCommon(),
|
|
20
|
+
new RegisterApi(),
|
|
21
|
+
new RegisterControllers()
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
register(
|
|
26
|
+
ioc: InversifyContainer,
|
|
27
|
+
manager: IOCManagerInterface<InversifyContainer>
|
|
28
|
+
): void {
|
|
29
|
+
this.getRegisterList().forEach((register) => {
|
|
30
|
+
register.register(ioc, manager, this.options);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -5,7 +5,7 @@ export default function NotFound({ route }: { route?: string }) {
|
|
|
5
5
|
return (
|
|
6
6
|
<div className="flex flex-col justify-center min-h-screen py-6 bg-background sm:py-12">
|
|
7
7
|
<div className="relative py-3 mx-auto sm:max-w-xl">
|
|
8
|
-
<h1 className="text-
|
|
8
|
+
<h1 className="text-text text-2xl font-bold text-center">
|
|
9
9
|
404 -{route ? `${t('404.notComponent')}: ${route}` : t('404.notPage')}
|
|
10
10
|
</h1>
|
|
11
11
|
</div>
|
|
@@ -5,7 +5,7 @@ export default function NotFound500() {
|
|
|
5
5
|
return (
|
|
6
6
|
<div className="flex flex-col justify-center min-h-screen py-6 bg-background sm:py-12">
|
|
7
7
|
<div className="relative py-3 mx-auto sm:max-w-xl">
|
|
8
|
-
<h1 className="text-
|
|
8
|
+
<h1 className="text-text text-2xl font-bold text-center">
|
|
9
9
|
500 - {t('500.title')}
|
|
10
10
|
</h1>
|
|
11
11
|
</div>
|