@qlover/create-app 0.4.5 → 0.5.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 +95 -35
- package/dist/index.cjs +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -2418
- package/{templates → dist/templates}/node-lib/package.json +2 -2
- package/{templates → dist/templates}/react-app/README.md +6 -6
- package/{templates/react-app/config/Identifier/Error.ts → dist/templates/react-app/config/Identifier/common.error.ts} +8 -8
- package/dist/templates/react-app/config/Identifier/common.ts +62 -0
- package/dist/templates/react-app/config/Identifier/index.ts +10 -0
- package/dist/templates/react-app/config/Identifier/page.about.ts +181 -0
- package/dist/templates/react-app/config/Identifier/page.executor.ts +267 -0
- package/dist/templates/react-app/config/Identifier/page.home.ts +63 -0
- package/dist/templates/react-app/config/Identifier/page.identifiter.ts +39 -0
- package/dist/templates/react-app/config/Identifier/page.jsonStorage.ts +70 -0
- package/dist/templates/react-app/config/Identifier/page.login.ts +152 -0
- package/dist/templates/react-app/config/Identifier/page.register.ts +147 -0
- package/dist/templates/react-app/config/Identifier/page.request.ts +179 -0
- package/dist/templates/react-app/config/app.router.ts +163 -0
- package/{templates → dist/templates}/react-app/config/feapi.mock.json +6 -0
- package/dist/templates/react-app/config/theme.ts +11 -0
- package/{templates → dist/templates}/react-app/package.json +2 -2
- package/{templates → dist/templates}/react-app/public/locales/en/common.json +97 -116
- package/{templates → dist/templates}/react-app/public/locales/zh/common.json +98 -117
- package/{templates → dist/templates}/react-app/src/App.tsx +6 -5
- package/dist/templates/react-app/src/base/apis/userApi/UserApi.ts +142 -0
- package/{templates → dist/templates}/react-app/src/base/apis/userApi/UserApiType.ts +11 -0
- package/{templates → dist/templates}/react-app/src/base/cases/AppConfig.ts +11 -0
- package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +36 -0
- package/{templates → dist/templates}/react-app/src/base/cases/RouterLoader.ts +2 -1
- package/{templates → dist/templates}/react-app/src/base/services/I18nService.ts +4 -4
- package/{templates/react-app/src/base/services/ProcesserService.ts → dist/templates/react-app/src/base/services/ProcesserExecutor.ts} +15 -5
- package/{templates → dist/templates}/react-app/src/base/services/RouteService.ts +11 -13
- package/dist/templates/react-app/src/base/services/UserService.ts +132 -0
- package/{templates → dist/templates}/react-app/src/base/types/Page.ts +12 -2
- package/{templates → dist/templates}/react-app/src/core/IOC.ts +11 -6
- package/{templates → dist/templates}/react-app/src/core/bootstrap.ts +2 -2
- package/{templates → dist/templates}/react-app/src/core/bootstraps/index.ts +3 -1
- package/{templates → dist/templates}/react-app/src/core/globals.ts +23 -7
- package/{templates → dist/templates}/react-app/src/core/registers/RegisterApi.ts +1 -1
- package/{templates → dist/templates}/react-app/src/core/registers/RegisterCommon.ts +14 -15
- package/{templates → dist/templates}/react-app/src/core/registers/RegisterControllers.ts +9 -4
- package/{templates → dist/templates}/react-app/src/core/registers/RegisterGlobals.ts +12 -4
- package/{templates → dist/templates}/react-app/src/pages/404.tsx +4 -1
- package/{templates → dist/templates}/react-app/src/pages/500.tsx +2 -1
- package/{templates → dist/templates}/react-app/src/pages/auth/Layout.tsx +2 -2
- package/{templates/react-app/src/pages/auth/Login.tsx → dist/templates/react-app/src/pages/auth/LoginPage.tsx} +2 -4
- package/{templates/react-app/src/pages/auth/Register.tsx → dist/templates/react-app/src/pages/auth/RegisterPage.tsx} +3 -6
- package/{templates/react-app/src/pages/base/About.tsx → dist/templates/react-app/src/pages/base/AboutPage.tsx} +4 -4
- package/{templates/react-app/src/pages/base/ErrorIdentifier.tsx → dist/templates/react-app/src/pages/base/ErrorIdentifierPage.tsx} +3 -3
- package/{templates/react-app/src/pages/base/Executor.tsx → dist/templates/react-app/src/pages/base/ExecutorPage.tsx} +3 -3
- package/{templates/react-app/src/pages/base/Home.tsx → dist/templates/react-app/src/pages/base/HomePage.tsx} +15 -45
- package/{templates/react-app/src/pages/base/JSONStorage.tsx → dist/templates/react-app/src/pages/base/JSONStoragePage.tsx} +3 -3
- package/{templates → dist/templates}/react-app/src/pages/base/Layout.tsx +4 -4
- package/{templates/react-app/src/pages/base/Request.tsx → dist/templates/react-app/src/pages/base/RequestPage.tsx} +2 -2
- package/{templates/react-app/src/pages/base → dist/templates/react-app/src/uikit}/components/LogoutButton.tsx +1 -1
- package/{templates → dist/templates}/react-app/src/uikit/components/ThemeSwitcher.tsx +5 -6
- package/{templates → dist/templates}/react-app/src/uikit/contexts/BaseRouteContext.ts +1 -1
- package/{templates → dist/templates}/react-app/src/uikit/controllers/ExecutorController.ts +2 -2
- package/{templates → dist/templates}/react-app/src/uikit/controllers/JSONStorageController.ts +5 -5
- package/{templates → dist/templates}/react-app/src/uikit/controllers/RequestController.ts +1 -1
- package/{templates/react-app/src/uikit/hooks/useLanguageGuard.ts → dist/templates/react-app/src/uikit/hooks/useI18nGuard.ts} +1 -1
- package/{templates → dist/templates}/react-app/src/uikit/hooks/useStore.ts +2 -2
- package/dist/templates/react-app/src/uikit/hooks/userRouterService.ts +12 -0
- package/{templates → dist/templates}/react-app/src/uikit/providers/BaseRouteProvider.tsx +1 -0
- package/dist/templates/react-app/src/uikit/providers/ProcessExecutorProvider.tsx +24 -0
- package/dist/templates/react-app/src/uikit/providers/UserAuthProvider.tsx +16 -0
- package/{templates → dist/templates}/react-app/vite.config.ts +2 -1
- package/package.json +4 -6
- package/templates/react-app/config/Identifier/Auth.ts +0 -13
- package/templates/react-app/config/Identifier/I18n.ts +0 -1366
- package/templates/react-app/config/app.router.json +0 -159
- package/templates/react-app/config/theme.json +0 -9
- package/templates/react-app/src/base/apis/userApi/UserApi.ts +0 -64
- package/templates/react-app/src/base/port/LoginInterface.ts +0 -12
- package/templates/react-app/src/base/port/StoreInterface.ts +0 -58
- package/templates/react-app/src/base/services/UserService.ts +0 -130
- package/templates/react-app/src/uikit/providers/ProcessProvider.tsx +0 -45
- /package/{configs → dist/configs}/_common/.editorconfig +0 -0
- /package/{configs → dist/configs}/_common/.env.template +0 -0
- /package/{configs → dist/configs}/_common/.gitattributes +0 -0
- /package/{configs → dist/configs}/_common/.github/workflows/general-check.yml +0 -0
- /package/{configs → dist/configs}/_common/.github/workflows/release.yml +0 -0
- /package/{configs → dist/configs}/_common/.gitignore.template +0 -0
- /package/{configs → dist/configs}/_common/.husky/commit-msg +0 -0
- /package/{configs → dist/configs}/_common/.husky/pre-commit +0 -0
- /package/{configs → dist/configs}/_common/.prettierignore +0 -0
- /package/{configs → dist/configs}/_common/.prettierrc.js +0 -0
- /package/{configs → dist/configs}/_common/.vscode/extensions.json +0 -0
- /package/{configs → dist/configs}/_common/.vscode/react.code-snippets +0 -0
- /package/{configs → dist/configs}/_common/.vscode/settings.json +0 -0
- /package/{configs → dist/configs}/_common/commitlint.config.js +0 -0
- /package/{configs → dist/configs}/_common/package.json.template +0 -0
- /package/{configs → dist/configs}/node-lib/eslint.config.js +0 -0
- /package/{configs → dist/configs}/react-app/eslint.config.js +0 -0
- /package/{templates → dist/templates}/node-lib/__tests__/readJson.test.ts +0 -0
- /package/{templates → dist/templates}/node-lib/bin/test.js +0 -0
- /package/{templates → dist/templates}/node-lib/rollup.config.js +0 -0
- /package/{templates → dist/templates}/node-lib/src/index.ts +0 -0
- /package/{templates → dist/templates}/node-lib/src/readJson.ts +0 -0
- /package/{templates → dist/templates}/node-lib/tsconfig.json +0 -0
- /package/{templates → dist/templates}/pack-app/README.md +0 -0
- /package/{templates → dist/templates}/pack-app/eslint.config.js +0 -0
- /package/{templates → dist/templates}/pack-app/fe-config.json +0 -0
- /package/{templates → dist/templates}/pack-app/package.json +0 -0
- /package/{templates → dist/templates}/pack-app/pnpm-workspace.yaml +0 -0
- /package/{templates → dist/templates}/pack-app/tsconfig.json +0 -0
- /package/{templates → dist/templates}/pack-app/tsconfig.test.json +0 -0
- /package/{templates → dist/templates}/pack-app/vite.config.ts +0 -0
- /package/{templates → dist/templates}/react-app/.env.template +0 -0
- /package/{templates → dist/templates}/react-app/config/common.ts +0 -0
- /package/{templates → dist/templates}/react-app/config/i18n.ts +0 -0
- /package/{templates → dist/templates}/react-app/index.html +0 -0
- /package/{templates → dist/templates}/react-app/postcss.config.js +0 -0
- /package/{templates → dist/templates}/react-app/public/logo.svg +0 -0
- /package/{templates → dist/templates}/react-app/public/router-root/logo.svg +0 -0
- /package/{templates → dist/templates}/react-app/src/assets/react.svg +0 -0
- /package/{templates → dist/templates}/react-app/src/base/apis/AiApi.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/apis/feApi/FeApi.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/apis/feApi/FeApiAdapter.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/apis/feApi/FeApiBootstarp.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/apis/feApi/FeApiType.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/apis/userApi/UserApiAdapter.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/apis/userApi/UserApiBootstarp.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/cases/AppError.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/cases/DialogHandler.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/cases/PublicAssetsPath.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/cases/RequestLogger.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/cases/RequestStatusCatcher.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/port/ApiTransactionInterface.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/port/InteractionHubInterface.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/port/RequestCatcherInterface.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/port/UIDependenciesInterface.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/types/deprecated-antd.d.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/base/types/global.d.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/core/bootstraps/BootstrapApp.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/core/bootstraps/PrintBootstrap.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/core/registers/index.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/main.tsx +0 -0
- /package/{templates → dist/templates}/react-app/src/pages/base/RedirectPathname.tsx +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/_default.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/dark.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/index.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/no-context.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/pink.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/index.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/page.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/tailwind.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/themes/_default.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/themes/dark.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/themes/index.css +0 -0
- /package/{templates → dist/templates}/react-app/src/styles/css/themes/pink.css +0 -0
- /package/{templates/react-app/src/pages/base → dist/templates/react-app/src/uikit}/components/BaseHeader.tsx +0 -0
- /package/{templates → dist/templates}/react-app/src/uikit/components/LanguageSwitcher.tsx +0 -0
- /package/{templates → dist/templates}/react-app/src/uikit/components/Loading.tsx +0 -0
- /package/{templates → dist/templates}/react-app/src/uikit/components/LocaleLink.tsx +0 -0
- /package/{templates → dist/templates}/react-app/src/uikit/components/RouterRenderComponent.tsx +0 -0
- /package/{templates → dist/templates}/react-app/src/uikit/hooks/useDocumentTitle.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/uikit/hooks/useStrictEffect.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/vite-env.d.ts +0 -0
- /package/{templates → dist/templates}/react-app/tailwind.config.js +0 -0
- /package/{templates → dist/templates}/react-app/tsconfig.app.json +0 -0
- /package/{templates → dist/templates}/react-app/tsconfig.json +0 -0
- /package/{templates → dist/templates}/react-app/tsconfig.node.json +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FetchAbortPlugin
|
|
1
|
+
import { FetchAbortPlugin } from '@qlover/fe-corekit';
|
|
2
2
|
import { Logger } from '@qlover/logger';
|
|
3
3
|
import {
|
|
4
4
|
InversifyContainer,
|
|
@@ -7,20 +7,21 @@ import {
|
|
|
7
7
|
IocRegisterOptions
|
|
8
8
|
} from '@/core/IOC';
|
|
9
9
|
import {
|
|
10
|
-
UserToken,
|
|
11
10
|
RequestCommonPlugin,
|
|
12
11
|
ApiMockPlugin,
|
|
13
12
|
ApiCatchPlugin,
|
|
14
13
|
ThemeService,
|
|
15
|
-
IOCManagerInterface
|
|
14
|
+
IOCManagerInterface,
|
|
15
|
+
TokenStorage
|
|
16
16
|
} from '@qlover/corekit-bridge';
|
|
17
17
|
import mockDataJson from '@config/feapi.mock.json';
|
|
18
18
|
import { RequestStatusCatcher } from '@/base/cases/RequestStatusCatcher';
|
|
19
|
-
import themeConfig from '@config/theme
|
|
20
|
-
import {
|
|
19
|
+
import { themeConfig } from '@config/theme';
|
|
20
|
+
import { localStorage, logger } from '../globals';
|
|
21
21
|
import { I18nService } from '@/base/services/I18nService';
|
|
22
22
|
import { RouteService } from '@/base/services/RouteService';
|
|
23
|
-
import {
|
|
23
|
+
import { baseRoutes } from '@config/app.router';
|
|
24
|
+
import { UserService } from '@/base/services/UserService';
|
|
24
25
|
|
|
25
26
|
export class RegisterCommon implements InversifyRegisterInterface {
|
|
26
27
|
register(
|
|
@@ -30,21 +31,19 @@ export class RegisterCommon implements InversifyRegisterInterface {
|
|
|
30
31
|
): void {
|
|
31
32
|
const AppConfig = container.get(IOCIdentifier.AppConfig);
|
|
32
33
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
34
|
+
const feApiToken = new TokenStorage(AppConfig.userTokenStorageKey, {
|
|
35
|
+
storage: container.get(IOCIdentifier.LocalStorageEncrypt)
|
|
36
|
+
});
|
|
37
37
|
const feApiAbort = new FetchAbortPlugin();
|
|
38
38
|
const feApiRequestCommonPlugin = new RequestCommonPlugin({
|
|
39
39
|
tokenPrefix: AppConfig.openAiTokenPrefix,
|
|
40
40
|
requiredToken: true,
|
|
41
|
-
token: () =>
|
|
41
|
+
token: () => container.get(UserService).getToken()
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
container.bind(FetchAbortPlugin, feApiAbort);
|
|
45
|
-
container.bind(UserToken, userToken);
|
|
46
45
|
|
|
47
|
-
container.bind(IOCIdentifier.FeApiToken,
|
|
46
|
+
container.bind(IOCIdentifier.FeApiToken, feApiToken);
|
|
48
47
|
container.bind(IOCIdentifier.FeApiCommonPlugin, feApiRequestCommonPlugin);
|
|
49
48
|
container.bind(
|
|
50
49
|
IOCIdentifier.ApiMockPlugin,
|
|
@@ -62,14 +61,14 @@ export class RegisterCommon implements InversifyRegisterInterface {
|
|
|
62
61
|
ThemeService,
|
|
63
62
|
new ThemeService({
|
|
64
63
|
...themeConfig,
|
|
65
|
-
storage:
|
|
64
|
+
storage: localStorage
|
|
66
65
|
})
|
|
67
66
|
);
|
|
68
67
|
|
|
69
68
|
container.bind(
|
|
70
69
|
RouteService,
|
|
71
70
|
new RouteService({
|
|
72
|
-
|
|
71
|
+
routes: baseRoutes,
|
|
73
72
|
logger
|
|
74
73
|
})
|
|
75
74
|
);
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { localStorage } from '../globals';
|
|
2
2
|
import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
|
|
3
|
-
import {
|
|
3
|
+
import { ProcesserExecutor } from '@/base/services/ProcesserExecutor';
|
|
4
4
|
import { UserService } from '@/base/services/UserService';
|
|
5
5
|
import { InversifyRegisterInterface } from '../IOC';
|
|
6
6
|
import { InversifyContainer } from '../IOC';
|
|
7
|
+
import { I18nKeyErrorPlugin } from '@/base/cases/I18nKeyErrorPlugin';
|
|
8
|
+
|
|
7
9
|
export class RegisterControllers implements InversifyRegisterInterface {
|
|
8
10
|
register(container: InversifyContainer): void {
|
|
9
|
-
const jsonStorageController = new JSONStorageController(
|
|
11
|
+
const jsonStorageController = new JSONStorageController(localStorage);
|
|
10
12
|
|
|
11
13
|
container.bind(JSONStorageController, jsonStorageController);
|
|
12
14
|
|
|
13
|
-
container
|
|
15
|
+
container
|
|
16
|
+
.get(ProcesserExecutor)
|
|
17
|
+
.use(container.get(I18nKeyErrorPlugin))
|
|
18
|
+
.use(container.get(UserService));
|
|
14
19
|
}
|
|
15
20
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { JSONSerializer
|
|
1
|
+
import { JSONSerializer } from '@qlover/fe-corekit';
|
|
2
2
|
import type { IOCManagerInterface } from '@qlover/corekit-bridge';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
cookieStorage,
|
|
5
|
+
dialogHandler,
|
|
6
|
+
JSON,
|
|
7
|
+
localStorage,
|
|
8
|
+
localStorageEncrypt,
|
|
9
|
+
logger
|
|
10
|
+
} from '../globals';
|
|
4
11
|
import {
|
|
5
12
|
type InversifyContainer,
|
|
6
13
|
type InversifyRegisterInterface,
|
|
@@ -25,7 +32,8 @@ export class RegisterGlobals implements InversifyRegisterInterface {
|
|
|
25
32
|
container.bind(Logger, logger);
|
|
26
33
|
container.bind(IOCIdentifier.Logger, logger);
|
|
27
34
|
|
|
28
|
-
container.bind(
|
|
29
|
-
container.bind(IOCIdentifier.
|
|
35
|
+
container.bind(IOCIdentifier.LocalStorage, localStorage);
|
|
36
|
+
container.bind(IOCIdentifier.LocalStorageEncrypt, localStorageEncrypt);
|
|
37
|
+
container.bind(IOCIdentifier.CookieStorage, cookieStorage);
|
|
30
38
|
}
|
|
31
39
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
2
|
+
import { PAGE_404_TITLE } from '@config/Identifier/common';
|
|
3
|
+
import { NOT_FOUND_COMPONENT } from '@config/Identifier/common.error';
|
|
2
4
|
|
|
3
5
|
export default function NotFound({ route }: { route?: string }) {
|
|
4
6
|
const { t } = useBaseRoutePage();
|
|
@@ -6,7 +8,8 @@ export default function NotFound({ route }: { route?: string }) {
|
|
|
6
8
|
<div className="flex flex-col justify-center min-h-screen py-6 bg-background sm:py-12">
|
|
7
9
|
<div className="relative py-3 mx-auto sm:max-w-xl">
|
|
8
10
|
<h1 className="text-text text-2xl font-bold text-center">
|
|
9
|
-
404 -
|
|
11
|
+
404 -
|
|
12
|
+
{route ? `${t(NOT_FOUND_COMPONENT)}: ${route}` : t(PAGE_404_TITLE)}
|
|
10
13
|
</h1>
|
|
11
14
|
</div>
|
|
12
15
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
2
|
+
import { PAGE_500_TITLE } from '@config/Identifier/common';
|
|
2
3
|
|
|
3
4
|
export default function NotFound500() {
|
|
4
5
|
const { t } = useBaseRoutePage();
|
|
@@ -6,7 +7,7 @@ export default function NotFound500() {
|
|
|
6
7
|
<div className="flex flex-col justify-center min-h-screen py-6 bg-background sm:py-12">
|
|
7
8
|
<div className="relative py-3 mx-auto sm:max-w-xl">
|
|
8
9
|
<h1 className="text-text text-2xl font-bold text-center">
|
|
9
|
-
500 - {t(
|
|
10
|
+
500 - {t(PAGE_500_TITLE)}
|
|
10
11
|
</h1>
|
|
11
12
|
</div>
|
|
12
13
|
</div>
|
|
@@ -2,11 +2,11 @@ import { IOC } from '@/core/IOC';
|
|
|
2
2
|
import { UserService } from '@/base/services/UserService';
|
|
3
3
|
import { Navigate, Outlet } from 'react-router-dom';
|
|
4
4
|
import { useStore } from '@/uikit/hooks/useStore';
|
|
5
|
-
import BaseHeader from '
|
|
5
|
+
import BaseHeader from '../../uikit/components/BaseHeader';
|
|
6
6
|
|
|
7
7
|
export default function Layout() {
|
|
8
8
|
const userService = IOC(UserService);
|
|
9
|
-
useStore(userService
|
|
9
|
+
useStore(userService.store);
|
|
10
10
|
|
|
11
11
|
// If user is authenticated, redirect to home page
|
|
12
12
|
if (userService.isAuthenticated()) {
|
|
@@ -5,8 +5,7 @@ import { IOC } from '@/core/IOC';
|
|
|
5
5
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
6
6
|
import { RouteService } from '@/base/services/RouteService';
|
|
7
7
|
import { UserService } from '@/base/services/UserService';
|
|
8
|
-
import
|
|
9
|
-
import * as i18nKeys from '@config/Identifier/I18n';
|
|
8
|
+
import * as i18nKeys from '@config/Identifier/page.login';
|
|
10
9
|
import LocaleLink from '@/uikit/components/LocaleLink';
|
|
11
10
|
|
|
12
11
|
interface LoginFormData {
|
|
@@ -14,11 +13,10 @@ interface LoginFormData {
|
|
|
14
13
|
password: string;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
export default function
|
|
16
|
+
export default function LoginPage() {
|
|
18
17
|
const { t } = useBaseRoutePage();
|
|
19
18
|
const userService = IOC(UserService);
|
|
20
19
|
const AppConfig = IOC('AppConfig');
|
|
21
|
-
useStore(userService);
|
|
22
20
|
const [loading, setLoading] = useState(false);
|
|
23
21
|
|
|
24
22
|
const handleLogin = async (values: LoginFormData) => {
|
|
@@ -4,16 +4,13 @@ import { UserOutlined, LockOutlined, MailOutlined } from '@ant-design/icons';
|
|
|
4
4
|
import { IOC } from '@/core/IOC';
|
|
5
5
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
6
6
|
import { RouteService } from '@/base/services/RouteService';
|
|
7
|
-
import { UserService } from '@/base/services/UserService';
|
|
8
|
-
import
|
|
9
|
-
import * as i18nKeys from '@config/Identifier/I18n';
|
|
10
|
-
import type { RegisterFormData } from '@/base/port/LoginInterface';
|
|
7
|
+
import { RegisterFormData, UserService } from '@/base/services/UserService';
|
|
8
|
+
import * as i18nKeys from '@config/Identifier/page.register';
|
|
11
9
|
|
|
12
|
-
export default function
|
|
10
|
+
export default function RegisterPage() {
|
|
13
11
|
const { t } = useBaseRoutePage();
|
|
14
12
|
const userService = IOC(UserService);
|
|
15
13
|
const AppConfig = IOC('AppConfig');
|
|
16
|
-
useStore(userService);
|
|
17
14
|
const [loading, setLoading] = useState(false);
|
|
18
15
|
const [form] = Form.useForm();
|
|
19
16
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
2
|
-
import * as i18nKeys from '@config/Identifier/
|
|
2
|
+
import * as i18nKeys from '@config/Identifier/page.about';
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
5
5
|
Tooltip,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from 'antd';
|
|
14
14
|
import { useState } from 'react';
|
|
15
15
|
|
|
16
|
-
export default function
|
|
16
|
+
export default function AboutPage() {
|
|
17
17
|
const { t } = useBaseRoutePage();
|
|
18
18
|
const [messageApi, contextHolder] = message.useMessage();
|
|
19
19
|
const [notificationApi, contextHolder2] = notification.useNotification();
|
|
@@ -108,8 +108,8 @@ export default function About() {
|
|
|
108
108
|
<Popconfirm
|
|
109
109
|
title={t(i18nKeys.ABOUT_POPCONFIRM_TITLE)}
|
|
110
110
|
description={t(i18nKeys.ABOUT_POPCONFIRM_DESC)}
|
|
111
|
-
okText={t(i18nKeys.
|
|
112
|
-
cancelText={t(i18nKeys.
|
|
111
|
+
okText={t(i18nKeys.ABOUT_OK_TEXT)}
|
|
112
|
+
cancelText={t(i18nKeys.ABOUT_CANCEL_TEXT)}
|
|
113
113
|
>
|
|
114
114
|
<Button>{t(i18nKeys.ABOUT_BTN_POPCONFIRM)}</Button>
|
|
115
115
|
</Popconfirm>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Button } from 'antd';
|
|
2
2
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
3
|
-
import * as ErrorIdentifierList from '@config/Identifier/
|
|
4
|
-
import * as i18nKeys from '@config/Identifier/
|
|
3
|
+
import * as ErrorIdentifierList from '@config/Identifier/common.error';
|
|
4
|
+
import * as i18nKeys from '@config/Identifier/page.identifiter';
|
|
5
5
|
|
|
6
|
-
export default function
|
|
6
|
+
export default function ErrorIdentifierPage() {
|
|
7
7
|
const { t } = useBaseRoutePage();
|
|
8
8
|
|
|
9
9
|
return (
|
|
@@ -5,7 +5,7 @@ import { IOC } from '@/core/IOC';
|
|
|
5
5
|
import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
|
|
6
6
|
import { ExecutorController } from '@/uikit/controllers/ExecutorController';
|
|
7
7
|
import { useStore } from '@/uikit/hooks/useStore';
|
|
8
|
-
import * as i18nKeys from '@config/Identifier/
|
|
8
|
+
import * as i18nKeys from '@config/Identifier/page.executor';
|
|
9
9
|
|
|
10
10
|
interface Task {
|
|
11
11
|
id: string;
|
|
@@ -20,7 +20,7 @@ interface Task {
|
|
|
20
20
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export default function
|
|
23
|
+
export default function ExecutorPage() {
|
|
24
24
|
const { t } = useBaseRoutePage();
|
|
25
25
|
const executorController = IOC(ExecutorController);
|
|
26
26
|
const jSONStorageController = IOC(JSONStorageController);
|
|
@@ -250,7 +250,7 @@ export default function Executor() {
|
|
|
250
250
|
</h2>
|
|
251
251
|
<div className="space-y-4">
|
|
252
252
|
<div className="text-text-secondary">
|
|
253
|
-
{t(i18nKeys.
|
|
253
|
+
{t(i18nKeys.PAGE_EXECUTOR_REQUEST_TIMEOUT)}: {requestTimeout}
|
|
254
254
|
</div>
|
|
255
255
|
<div>
|
|
256
256
|
{helloState.loading ? (
|
|
@@ -2,53 +2,23 @@ import { Button } from 'antd';
|
|
|
2
2
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
3
3
|
import LocaleLink from '@/uikit/components/LocaleLink';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import * as i18nKeys from '@config/Identifier
|
|
5
|
+
import * as i18nKeys from '@config/Identifier';
|
|
6
|
+
import { baseRoutes } from '@config/app.router';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const layoutRoutes = baseRoutes.filter(
|
|
9
|
+
(route) => route.element === 'base/Layout'
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const navigationItems = layoutRoutes[0]!
|
|
13
|
+
.children!.filter((route) => !route.index)
|
|
14
|
+
.map((route) => ({
|
|
15
|
+
href: `/${route.path}`,
|
|
16
|
+
titleKey: route.meta!.title!,
|
|
17
|
+
descriptionKey: route.meta!.description!
|
|
18
|
+
}));
|
|
9
19
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
href: '/about',
|
|
13
|
-
bgColor: 'bg-blue-50',
|
|
14
|
-
hoverColor: 'hover:bg-blue-100',
|
|
15
|
-
titleColor: 'text-blue-700',
|
|
16
|
-
titleKey: i18nKeys.PAGE_ABOUT_TITLE,
|
|
17
|
-
descriptionKey: i18nKeys.PAGE_ABOUT_DESCRIPTION
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
href: '/jsonstorage',
|
|
21
|
-
bgColor: 'bg-green-50',
|
|
22
|
-
hoverColor: 'hover:bg-green-100',
|
|
23
|
-
titleColor: 'text-green-700',
|
|
24
|
-
titleKey: i18nKeys.PAGE_JSONSTORAGE_TITLE,
|
|
25
|
-
descriptionKey: i18nKeys.PAGE_JSONSTORAGE_DESCRIPTION
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
href: '/request',
|
|
29
|
-
bgColor: 'bg-red-50',
|
|
30
|
-
hoverColor: 'hover:bg-red-100',
|
|
31
|
-
titleColor: 'text-red-700',
|
|
32
|
-
titleKey: i18nKeys.PAGE_REQUEST_TITLE,
|
|
33
|
-
descriptionKey: i18nKeys.PAGE_REQUEST_DESCRIPTION
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
href: '/executor',
|
|
37
|
-
bgColor: 'bg-purple-50',
|
|
38
|
-
hoverColor: 'hover:bg-purple-100',
|
|
39
|
-
titleColor: 'text-purple-700',
|
|
40
|
-
titleKey: i18nKeys.PAGE_EXECUTOR_TITLE,
|
|
41
|
-
descriptionKey: i18nKeys.PAGE_EXECUTOR_DESCRIPTION
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
href: '/errorIdentifier',
|
|
45
|
-
bgColor: 'bg-amber-50',
|
|
46
|
-
hoverColor: 'hover:bg-amber-100',
|
|
47
|
-
titleColor: 'text-amber-700',
|
|
48
|
-
titleKey: i18nKeys.PAGE_ERROR_IDENTIFIER_TITLE,
|
|
49
|
-
descriptionKey: i18nKeys.PAGE_ERROR_IDENTIFIER_DESCRIPTION
|
|
50
|
-
}
|
|
51
|
-
];
|
|
20
|
+
export default function HomePage() {
|
|
21
|
+
const { t } = useBaseRoutePage();
|
|
52
22
|
|
|
53
23
|
return (
|
|
54
24
|
<div className="min-h-screen bg-primary">
|
|
@@ -4,9 +4,9 @@ import template from 'lodash/template';
|
|
|
4
4
|
import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
|
|
5
5
|
import { useStore } from '@/uikit/hooks/useStore';
|
|
6
6
|
import { Button, Input } from 'antd';
|
|
7
|
-
import * as i18nKeys from '@config/Identifier/
|
|
7
|
+
import * as i18nKeys from '@config/Identifier/page.jsonStorage';
|
|
8
8
|
|
|
9
|
-
export default function
|
|
9
|
+
export default function JSONStoragePage() {
|
|
10
10
|
const jsonStorageController = IOC(JSONStorageController);
|
|
11
11
|
const controllerState = useStore(jsonStorageController);
|
|
12
12
|
const { t } = useBaseRoutePage();
|
|
@@ -46,7 +46,7 @@ export default function JSONStorage() {
|
|
|
46
46
|
{t(i18nKeys.PAGE_JSONSTORAGE_CURRENT_VALUE)}:{' '}
|
|
47
47
|
</span>
|
|
48
48
|
<span className="font-semibold text-text">
|
|
49
|
-
{controllerState.testKey1}
|
|
49
|
+
{JSON.stringify(controllerState.testKey1)}
|
|
50
50
|
</span>
|
|
51
51
|
</div>
|
|
52
52
|
</div>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import BaseHeader from '
|
|
1
|
+
import BaseHeader from '../../uikit/components/BaseHeader';
|
|
2
2
|
import { Outlet } from 'react-router-dom';
|
|
3
|
-
import {
|
|
3
|
+
import { ProcessExecutorProvider } from '@/uikit/providers/ProcessExecutorProvider';
|
|
4
4
|
|
|
5
5
|
export default function Layout() {
|
|
6
6
|
return (
|
|
7
|
-
<
|
|
7
|
+
<ProcessExecutorProvider>
|
|
8
8
|
<div
|
|
9
9
|
data-testid="basic-layout"
|
|
10
10
|
className="text-base min-h-screen bg-primary"
|
|
@@ -15,6 +15,6 @@ export default function Layout() {
|
|
|
15
15
|
<Outlet />
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
|
-
</
|
|
18
|
+
</ProcessExecutorProvider>
|
|
19
19
|
);
|
|
20
20
|
}
|
|
@@ -6,7 +6,7 @@ import { useMemo } from 'react';
|
|
|
6
6
|
import { useStore } from '@/uikit/hooks/useStore';
|
|
7
7
|
import { Button } from 'antd';
|
|
8
8
|
import { LoadingOutlined } from '@ant-design/icons';
|
|
9
|
-
import * as i18nKeys from '@config/Identifier/
|
|
9
|
+
import * as i18nKeys from '@config/Identifier/page.request';
|
|
10
10
|
|
|
11
11
|
function JSONValue({ value }: { value: unknown }) {
|
|
12
12
|
const output = useMemo(() => {
|
|
@@ -23,7 +23,7 @@ function JSONValue({ value }: { value: unknown }) {
|
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export default function
|
|
26
|
+
export default function RequestPage() {
|
|
27
27
|
const requestController = IOC(RequestController);
|
|
28
28
|
const requestControllerState = useStore(requestController);
|
|
29
29
|
const jsonStorageControllerState = useStore(IOC(JSONStorageController));
|
|
@@ -3,7 +3,7 @@ import { IOC } from '@/core/IOC';
|
|
|
3
3
|
import {
|
|
4
4
|
AUTH_LOGOUT_DIALOG_CONTENT,
|
|
5
5
|
AUTH_LOGOUT_DIALOG_TITLE
|
|
6
|
-
} from '@config/Identifier/
|
|
6
|
+
} from '@config/Identifier/common';
|
|
7
7
|
import { Button } from 'antd';
|
|
8
8
|
import { useCallback } from 'react';
|
|
9
9
|
import { useTranslation } from 'react-i18next';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IOC } from '@/core/IOC';
|
|
2
|
-
import { ThemeService
|
|
2
|
+
import { ThemeService } from '@qlover/corekit-bridge';
|
|
3
3
|
import { useStore } from '@/uikit/hooks/useStore';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { Select } from 'antd';
|
|
@@ -11,8 +11,7 @@ import {
|
|
|
11
11
|
} from '@ant-design/icons';
|
|
12
12
|
import clsx from 'clsx';
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
-
import * as i18nKeys from '@config/Identifier/
|
|
15
|
-
import { StoreInterface } from '@/base/port/StoreInterface';
|
|
14
|
+
import * as i18nKeys from '@config/Identifier/common';
|
|
16
15
|
|
|
17
16
|
const colorMap: Record<
|
|
18
17
|
string,
|
|
@@ -37,9 +36,9 @@ const colorMap: Record<
|
|
|
37
36
|
|
|
38
37
|
export default function ThemeSwitcher() {
|
|
39
38
|
const themeService = IOC(ThemeService);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
39
|
+
// FIXME:
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
const { theme } = useStore(themeService as any);
|
|
43
42
|
const themes = themeService.getSupportedThemes();
|
|
44
43
|
const { t } = useTranslation('common');
|
|
45
44
|
|
|
@@ -5,7 +5,7 @@ import { RouteMeta } from '@/base/types/Page';
|
|
|
5
5
|
import { createContext } from 'react';
|
|
6
6
|
import merge from 'lodash/merge';
|
|
7
7
|
import i18nConfig from '@config/i18n';
|
|
8
|
-
import { WITHIN_PAGE_PROVIDER } from '@config/Identifier/
|
|
8
|
+
import { WITHIN_PAGE_PROVIDER } from '@config/Identifier/common.error';
|
|
9
9
|
|
|
10
10
|
const { defaultNS } = i18nConfig;
|
|
11
11
|
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
import { inject, injectable } from 'inversify';
|
|
9
9
|
import {
|
|
10
10
|
StoreInterface,
|
|
11
|
-
StoreStateInterface
|
|
12
|
-
} from '
|
|
11
|
+
type StoreStateInterface
|
|
12
|
+
} from '@qlover/corekit-bridge';
|
|
13
13
|
|
|
14
14
|
class ExecutorControllerState implements StoreStateInterface {
|
|
15
15
|
helloState = {
|
package/{templates → dist/templates}/react-app/src/uikit/controllers/JSONStorageController.ts
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { JSONStorage } from '@qlover/fe-corekit';
|
|
2
1
|
import {
|
|
3
2
|
StoreInterface,
|
|
4
|
-
StoreStateInterface
|
|
5
|
-
} from '
|
|
6
|
-
import {
|
|
3
|
+
type StoreStateInterface
|
|
4
|
+
} from '@qlover/corekit-bridge';
|
|
5
|
+
import { SyncStorageInterface } from '@qlover/fe-corekit';
|
|
6
|
+
import random from 'lodash/random';
|
|
7
7
|
|
|
8
8
|
interface JSONStoragePageState extends StoreStateInterface {
|
|
9
9
|
testKey1?: number;
|
|
@@ -17,7 +17,7 @@ export class JSONStorageController extends StoreInterface<JSONStoragePageState>
|
|
|
17
17
|
requestTimeout: (state: JSONStoragePageState) => state.requestTimeout
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
constructor(private storage:
|
|
20
|
+
constructor(private storage: SyncStorageInterface<string, number>) {
|
|
21
21
|
super(() => ({
|
|
22
22
|
testKey1: storage.getItem('testKey1') ?? 0,
|
|
23
23
|
testKey2: storage.getItem('testKey2') ?? 0,
|
|
@@ -3,7 +3,7 @@ import { FeApi } from '@/base/apis/feApi/FeApi';
|
|
|
3
3
|
import { logger } from '@/core/globals';
|
|
4
4
|
import { UserApi } from '@/base/apis/userApi/UserApi';
|
|
5
5
|
import { aiHello } from '@/base/apis/AiApi';
|
|
6
|
-
import { StoreInterface } from '
|
|
6
|
+
import { StoreInterface } from '@qlover/corekit-bridge';
|
|
7
7
|
|
|
8
8
|
function createDefaultState() {
|
|
9
9
|
return {
|
|
@@ -10,7 +10,7 @@ import { useParams } from 'react-router-dom';
|
|
|
10
10
|
*
|
|
11
11
|
* TODO: if language not found, use default language
|
|
12
12
|
*/
|
|
13
|
-
export function
|
|
13
|
+
export function useI18nGuard() {
|
|
14
14
|
const { lng } = useParams<{ lng: I18nServiceLocale }>();
|
|
15
15
|
const navigate = useNavigate();
|
|
16
16
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RouteService } from '@/base/services/RouteService';
|
|
2
|
+
import { IOC } from '@/core/IOC';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { useNavigate } from 'react-router-dom';
|
|
5
|
+
|
|
6
|
+
export function useRouterService() {
|
|
7
|
+
const navigate = useNavigate();
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
IOC(RouteService).setDependencies({ navigate });
|
|
11
|
+
}, [navigate]);
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { UserAuthProvider } from './UserAuthProvider';
|
|
2
|
+
import { useStrictEffect } from '../hooks/useStrictEffect';
|
|
3
|
+
import { IOC } from '@/core/IOC';
|
|
4
|
+
import { ProcesserExecutor } from '@/base/services/ProcesserExecutor';
|
|
5
|
+
import { useI18nGuard } from '../hooks/useI18nGuard';
|
|
6
|
+
import { useRouterService } from '../hooks/userRouterService';
|
|
7
|
+
|
|
8
|
+
export function ProcessExecutorProvider({
|
|
9
|
+
children
|
|
10
|
+
}: {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}) {
|
|
13
|
+
const processerExecutor = IOC(ProcesserExecutor);
|
|
14
|
+
|
|
15
|
+
useI18nGuard();
|
|
16
|
+
|
|
17
|
+
useRouterService();
|
|
18
|
+
|
|
19
|
+
useStrictEffect(() => {
|
|
20
|
+
processerExecutor.starup();
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
return <UserAuthProvider>{children}</UserAuthProvider>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IOC } from '@/core/IOC';
|
|
2
|
+
import { Loading } from '../components/Loading';
|
|
3
|
+
import { UserService } from '@/base/services/UserService';
|
|
4
|
+
import { useStore } from '../hooks/useStore';
|
|
5
|
+
|
|
6
|
+
export function UserAuthProvider({ children }: { children: React.ReactNode }) {
|
|
7
|
+
const userService = IOC(UserService);
|
|
8
|
+
|
|
9
|
+
useStore(userService.store);
|
|
10
|
+
|
|
11
|
+
if (!userService.isAuthenticated()) {
|
|
12
|
+
return <Loading fullscreen />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return children;
|
|
16
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import { defineConfig } from 'vitest/config';
|
|
2
3
|
import react from '@vitejs/plugin-react';
|
|
3
4
|
import {
|
|
@@ -111,7 +112,7 @@ export default defineConfig({
|
|
|
111
112
|
overriedCssFilePath: './src/styles/css/antd-themes/no-context.css',
|
|
112
113
|
targetPath: './src/base/types/deprecated-antd.d.ts'
|
|
113
114
|
})
|
|
114
|
-
],
|
|
115
|
+
] as any[],
|
|
115
116
|
base: routerPrefix,
|
|
116
117
|
envPrefix: envPrefix,
|
|
117
118
|
publicDir: 'public',
|