@qlover/create-app 0.4.4 → 0.4.6
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 -34
- 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 → dist/templates}/react-app/config/Identifier/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/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 -114
- package/{templates → dist/templates}/react-app/public/locales/zh/common.json +98 -115
- package/{templates → dist/templates}/react-app/src/App.tsx +6 -5
- package/{templates → dist/templates}/react-app/src/base/cases/AppConfig.ts +3 -1
- 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/{templates → dist/templates}/react-app/src/base/services/UserService.ts +37 -21
- package/{templates → dist/templates}/react-app/src/base/types/Page.ts +12 -2
- package/{templates → dist/templates}/react-app/src/core/bootstrap.ts +1 -1
- package/{templates → dist/templates}/react-app/src/core/bootstraps/index.ts +3 -1
- package/{templates → dist/templates}/react-app/src/core/globals.ts +2 -1
- package/{templates → dist/templates}/react-app/src/core/registers/RegisterCommon.ts +7 -7
- package/{templates → dist/templates}/react-app/src/core/registers/RegisterControllers.ts +7 -2
- 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 -2
- package/{templates/react-app/src/pages/auth/Register.tsx → dist/templates/react-app/src/pages/auth/RegisterPage.tsx} +3 -4
- 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} +2 -2
- package/{templates → dist/templates}/react-app/src/pages/base/Layout.tsx +5 -5
- 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/BaseHeader.tsx +8 -1
- package/dist/templates/react-app/src/uikit/components/LogoutButton.tsx +32 -0
- 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 +2 -2
- 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 -2
- package/package.json +4 -6
- 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/port/LoginInterface.ts +0 -12
- package/templates/react-app/src/base/port/StoreInterface.ts +0 -58
- 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/feapi.mock.json +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/UserApi.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/apis/userApi/UserApiType.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/IOC.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/RegisterApi.ts +0 -0
- /package/{templates → dist/templates}/react-app/src/core/registers/RegisterGlobals.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 → 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
|
@@ -4,11 +4,11 @@ import LanguageDetector from 'i18next-browser-languagedetector';
|
|
|
4
4
|
import HttpApi from 'i18next-http-backend';
|
|
5
5
|
import merge from 'lodash/merge';
|
|
6
6
|
import i18nConfig from '@config/i18n';
|
|
7
|
-
import type { BootstrapExecutorPlugin } from '@qlover/corekit-bridge';
|
|
8
7
|
import {
|
|
9
|
-
|
|
10
|
-
StoreStateInterface
|
|
11
|
-
|
|
8
|
+
type BootstrapExecutorPlugin,
|
|
9
|
+
type StoreStateInterface,
|
|
10
|
+
StoreInterface
|
|
11
|
+
} from '@qlover/corekit-bridge';
|
|
12
12
|
const { supportedLngs, fallbackLng } = i18nConfig;
|
|
13
13
|
|
|
14
14
|
export type I18nServiceLocale = (typeof supportedLngs)[number];
|
|
@@ -2,12 +2,15 @@ import { AsyncExecutor, ExecutorPlugin } from '@qlover/fe-corekit';
|
|
|
2
2
|
import { IOCIdentifier } from '@/core/IOC';
|
|
3
3
|
import { injectable, inject } from 'inversify';
|
|
4
4
|
import type { LoggerInterface } from '@qlover/logger';
|
|
5
|
+
import { RouteService } from './RouteService';
|
|
5
6
|
|
|
6
7
|
@injectable()
|
|
7
|
-
export class
|
|
8
|
+
export class ProcesserExecutor {
|
|
9
|
+
protected executor: AsyncExecutor = new AsyncExecutor();
|
|
10
|
+
|
|
8
11
|
constructor(
|
|
9
12
|
@inject(IOCIdentifier.Logger) private logger: LoggerInterface,
|
|
10
|
-
@inject(
|
|
13
|
+
@inject(RouteService) private routeService: RouteService
|
|
11
14
|
) {}
|
|
12
15
|
|
|
13
16
|
use(plugin: ExecutorPlugin): this {
|
|
@@ -21,9 +24,16 @@ export class ProcesserService {
|
|
|
21
24
|
});
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
async starup(): Promise<unknown> {
|
|
28
|
+
this.logger.info('PageProcesser startup');
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const result = await this.executor.exec(this.handler);
|
|
32
|
+
return result;
|
|
33
|
+
} catch (err) {
|
|
26
34
|
this.logger.error('PageProcesser init failed', err);
|
|
27
|
-
|
|
35
|
+
|
|
36
|
+
this.routeService.gotoLogin();
|
|
37
|
+
}
|
|
28
38
|
}
|
|
29
39
|
}
|
|
@@ -3,23 +3,23 @@ import type { NavigateFunction, NavigateOptions } from 'react-router-dom';
|
|
|
3
3
|
import type { UIDependenciesInterface } from '@/base/port/UIDependenciesInterface';
|
|
4
4
|
import type { LoggerInterface } from '@qlover/logger';
|
|
5
5
|
import { I18nService } from '@/base/services/I18nService';
|
|
6
|
+
import { StoreInterface, StoreStateInterface } from '@qlover/corekit-bridge';
|
|
6
7
|
|
|
7
8
|
export type RouterServiceDependencies = {
|
|
8
9
|
navigate: NavigateFunction;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export type RouterServiceOptions = {
|
|
12
|
-
|
|
13
|
-
routes: RouteConfigValue[];
|
|
14
|
-
};
|
|
13
|
+
routes: RouteConfigValue[];
|
|
15
14
|
logger: LoggerInterface;
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
export
|
|
19
|
-
routes: RouteConfigValue[]
|
|
20
|
-
}
|
|
17
|
+
export class RouterServiceState implements StoreStateInterface {
|
|
18
|
+
constructor(public routes: RouteConfigValue[] = []) {}
|
|
19
|
+
}
|
|
21
20
|
|
|
22
21
|
export class RouteService
|
|
22
|
+
extends StoreInterface<RouterServiceState>
|
|
23
23
|
implements UIDependenciesInterface<RouterServiceDependencies>
|
|
24
24
|
{
|
|
25
25
|
/**
|
|
@@ -27,12 +27,8 @@ export class RouteService
|
|
|
27
27
|
*/
|
|
28
28
|
dependencies?: RouterServiceDependencies;
|
|
29
29
|
|
|
30
|
-
state: RouterServiceState;
|
|
31
|
-
|
|
32
30
|
constructor(private options: RouterServiceOptions) {
|
|
33
|
-
|
|
34
|
-
routes: options.config.routes
|
|
35
|
-
};
|
|
31
|
+
super(() => new RouterServiceState(options.routes));
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
get logger(): LoggerInterface {
|
|
@@ -43,7 +39,9 @@ export class RouteService
|
|
|
43
39
|
const navigate = this.dependencies?.navigate;
|
|
44
40
|
|
|
45
41
|
if (!navigate) {
|
|
46
|
-
this.logger.debug(
|
|
42
|
+
this.logger.debug(
|
|
43
|
+
'Please use `RouterServiceProvider` to set dependencies'
|
|
44
|
+
);
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
return navigate;
|
|
@@ -69,7 +67,7 @@ export class RouteService
|
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
changeRoutes(routes: RouteConfigValue[]): void {
|
|
72
|
-
this.
|
|
70
|
+
this.emit({ routes });
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
goto(path: string, options?: NavigateOptions): void {
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
import { ExecutorPlugin } from '@qlover/fe-corekit';
|
|
1
|
+
import type { ExecutorPlugin } from '@qlover/fe-corekit';
|
|
2
2
|
import type {
|
|
3
3
|
UserApiGetUserInfoTransaction,
|
|
4
4
|
UserApiLoginTransaction
|
|
5
5
|
} from '@/base/apis/userApi/UserApiType';
|
|
6
6
|
import { RouteService } from './RouteService';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
StoreInterface,
|
|
9
|
+
StoreStateInterface,
|
|
10
|
+
type StorageTokenInterface
|
|
11
|
+
} from '@qlover/corekit-bridge';
|
|
8
12
|
import { inject, injectable } from 'inversify';
|
|
9
13
|
import { IOCIdentifier } from '@/core/IOC';
|
|
10
|
-
import { LoginInterface, RegisterFormData } from '@/base/port/LoginInterface';
|
|
11
14
|
import { UserApi } from '@/base/apis/userApi/UserApi';
|
|
12
15
|
import { AppError } from '@/base/cases/AppError';
|
|
13
|
-
import
|
|
14
|
-
|
|
16
|
+
import * as errKeys from '@config/Identifier/error';
|
|
17
|
+
|
|
18
|
+
export type UserServiceUserInfo =
|
|
19
|
+
UserApiGetUserInfoTransaction['response']['data'];
|
|
20
|
+
|
|
21
|
+
export interface RegisterFormData {
|
|
22
|
+
username: string;
|
|
23
|
+
email: string;
|
|
24
|
+
password: string;
|
|
25
|
+
confirmPassword: string;
|
|
26
|
+
agreeToTerms: boolean;
|
|
27
|
+
}
|
|
15
28
|
|
|
16
29
|
class UserServiceState implements StoreStateInterface {
|
|
17
30
|
success: boolean = false;
|
|
18
|
-
userInfo:
|
|
31
|
+
userInfo: UserServiceUserInfo = {
|
|
19
32
|
name: '',
|
|
20
33
|
email: '',
|
|
21
34
|
picture: ''
|
|
@@ -25,28 +38,30 @@ class UserServiceState implements StoreStateInterface {
|
|
|
25
38
|
@injectable()
|
|
26
39
|
export class UserService
|
|
27
40
|
extends StoreInterface<UserServiceState>
|
|
28
|
-
implements ExecutorPlugin
|
|
41
|
+
implements ExecutorPlugin
|
|
29
42
|
{
|
|
30
43
|
readonly pluginName = 'UserService';
|
|
31
44
|
|
|
32
45
|
constructor(
|
|
33
46
|
@inject(UserApi) private userApi: UserApi,
|
|
34
|
-
@inject(RouteService) private
|
|
47
|
+
@inject(RouteService) private routerService: RouteService,
|
|
35
48
|
@inject(IOCIdentifier.FeApiToken)
|
|
36
49
|
private userToken: StorageTokenInterface<string>
|
|
37
50
|
) {
|
|
38
51
|
super(() => new UserServiceState());
|
|
39
52
|
}
|
|
40
53
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
54
|
+
selector = {
|
|
55
|
+
success: (state: UserServiceState) => state.success
|
|
56
|
+
};
|
|
44
57
|
|
|
45
58
|
/**
|
|
46
59
|
* @override
|
|
47
60
|
*/
|
|
48
61
|
async onBefore(): Promise<void> {
|
|
49
|
-
|
|
62
|
+
if (this.isAuthenticated()) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
50
65
|
|
|
51
66
|
const userToken = this.userToken.getToken();
|
|
52
67
|
|
|
@@ -56,19 +71,18 @@ export class UserService
|
|
|
56
71
|
|
|
57
72
|
const userInfo = await this.userApi.getUserInfo();
|
|
58
73
|
|
|
59
|
-
this.
|
|
74
|
+
this.emit({
|
|
60
75
|
success: true,
|
|
61
76
|
userInfo: userInfo.data
|
|
62
77
|
});
|
|
63
78
|
}
|
|
64
79
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.routerController.gotoLogin();
|
|
80
|
+
onSuccess(): void | Promise<void> {
|
|
81
|
+
if (this.isAuthenticated()) {
|
|
82
|
+
this.emit({ ...this.state, success: true });
|
|
83
|
+
} else {
|
|
84
|
+
this.logout();
|
|
85
|
+
}
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
/**
|
|
@@ -91,7 +105,7 @@ export class UserService
|
|
|
91
105
|
|
|
92
106
|
const userInfo = await this.userApi.getUserInfo();
|
|
93
107
|
|
|
94
|
-
this.
|
|
108
|
+
this.emit({
|
|
95
109
|
success: true,
|
|
96
110
|
userInfo: userInfo.data
|
|
97
111
|
});
|
|
@@ -104,6 +118,8 @@ export class UserService
|
|
|
104
118
|
*/
|
|
105
119
|
logout(): void {
|
|
106
120
|
this.reset();
|
|
121
|
+
this.routerService.reset();
|
|
122
|
+
this.routerService.gotoLogin();
|
|
107
123
|
}
|
|
108
124
|
|
|
109
125
|
/**
|
|
@@ -10,12 +10,22 @@ export interface BasePageProvider {
|
|
|
10
10
|
type RouteCategory = 'main' | 'auth' | 'common';
|
|
11
11
|
|
|
12
12
|
export interface RouteMeta {
|
|
13
|
-
category?: RouteCategory;
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* The title of the route
|
|
16
15
|
*/
|
|
17
16
|
title?: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The description of the route
|
|
20
|
+
*/
|
|
21
|
+
description?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The icon of the route
|
|
25
|
+
*/
|
|
18
26
|
icon?: string;
|
|
27
|
+
|
|
28
|
+
category?: RouteCategory;
|
|
19
29
|
/**
|
|
20
30
|
* from app.router.json
|
|
21
31
|
*
|
|
@@ -4,7 +4,7 @@ import { IOC } from './IOC';
|
|
|
4
4
|
import * as globals from '@/core/globals';
|
|
5
5
|
import { IocRegister } from './registers';
|
|
6
6
|
import { BootstrapsRegistry } from './bootstraps';
|
|
7
|
-
import { GLOBAL_NO_WINDOW } from '@config/Identifier/
|
|
7
|
+
import { GLOBAL_NO_WINDOW } from '@config/Identifier/error';
|
|
8
8
|
|
|
9
9
|
export default async function startup({
|
|
10
10
|
root,
|
|
@@ -11,6 +11,7 @@ import { AiApiBootstarp } from '@/base/apis/AiApi';
|
|
|
11
11
|
import { printBootstrap } from './PrintBootstrap';
|
|
12
12
|
import { IOCIdentifier, type IOCIdentifierMap } from '../IOC';
|
|
13
13
|
import { I18nService } from '@/base/services/I18nService';
|
|
14
|
+
import { I18nKeyErrorPlugin } from '@/base/cases/I18nKeyErrorPlugin';
|
|
14
15
|
|
|
15
16
|
export class BootstrapsRegistry {
|
|
16
17
|
constructor(
|
|
@@ -29,7 +30,8 @@ export class BootstrapsRegistry {
|
|
|
29
30
|
new UserApiBootstarp(),
|
|
30
31
|
new FeApiBootstarp(),
|
|
31
32
|
AiApiBootstarp,
|
|
32
|
-
new BootstrapApp()
|
|
33
|
+
new BootstrapApp(),
|
|
34
|
+
IOC(I18nKeyErrorPlugin)
|
|
33
35
|
];
|
|
34
36
|
|
|
35
37
|
if (this.appConfig.env !== 'production') {
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
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
|
|
19
|
+
import { themeConfig } from '@config/theme';
|
|
20
20
|
import { localJsonStorage, 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
24
|
|
|
25
25
|
export class RegisterCommon implements InversifyRegisterInterface {
|
|
26
26
|
register(
|
|
@@ -30,10 +30,10 @@ export class RegisterCommon implements InversifyRegisterInterface {
|
|
|
30
30
|
): void {
|
|
31
31
|
const AppConfig = container.get(IOCIdentifier.AppConfig);
|
|
32
32
|
|
|
33
|
-
const userToken = new UserToken(
|
|
34
|
-
AppConfig.userTokenStorageKey,
|
|
35
|
-
container.get(JSONStorage)
|
|
36
|
-
);
|
|
33
|
+
const userToken = new UserToken({
|
|
34
|
+
storageKey: AppConfig.userTokenStorageKey,
|
|
35
|
+
storage: container.get(JSONStorage)
|
|
36
|
+
});
|
|
37
37
|
const feApiAbort = new FetchAbortPlugin();
|
|
38
38
|
const feApiRequestCommonPlugin = new RequestCommonPlugin({
|
|
39
39
|
tokenPrefix: AppConfig.openAiTokenPrefix,
|
|
@@ -69,7 +69,7 @@ export class RegisterCommon implements InversifyRegisterInterface {
|
|
|
69
69
|
container.bind(
|
|
70
70
|
RouteService,
|
|
71
71
|
new RouteService({
|
|
72
|
-
|
|
72
|
+
routes: baseRoutes,
|
|
73
73
|
logger
|
|
74
74
|
})
|
|
75
75
|
);
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { localJsonStorage } 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
11
|
const jsonStorageController = new JSONStorageController(localJsonStorage);
|
|
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,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/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,7 +2,7 @@ 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);
|
|
@@ -15,7 +15,7 @@ export default function Layout() {
|
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<>
|
|
18
|
-
<BaseHeader />
|
|
18
|
+
<BaseHeader showLogoutButton={false} />
|
|
19
19
|
<div className="flex-1">
|
|
20
20
|
<Outlet />
|
|
21
21
|
</div>
|
|
@@ -6,7 +6,7 @@ import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
|
6
6
|
import { RouteService } from '@/base/services/RouteService';
|
|
7
7
|
import { UserService } from '@/base/services/UserService';
|
|
8
8
|
import { useStore } from '@/uikit/hooks/useStore';
|
|
9
|
-
import * as i18nKeys from '@config/Identifier/
|
|
9
|
+
import * as i18nKeys from '@config/Identifier/page.login';
|
|
10
10
|
import LocaleLink from '@/uikit/components/LocaleLink';
|
|
11
11
|
|
|
12
12
|
interface LoginFormData {
|
|
@@ -14,7 +14,7 @@ interface LoginFormData {
|
|
|
14
14
|
password: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export default function
|
|
17
|
+
export default function LoginPage() {
|
|
18
18
|
const { t } = useBaseRoutePage();
|
|
19
19
|
const userService = IOC(UserService);
|
|
20
20
|
const AppConfig = IOC('AppConfig');
|
|
@@ -4,12 +4,11 @@ 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';
|
|
7
|
+
import { RegisterFormData, UserService } from '@/base/services/UserService';
|
|
8
8
|
import { useStore } from '@/uikit/hooks/useStore';
|
|
9
|
-
import * as i18nKeys from '@config/Identifier/
|
|
10
|
-
import type { RegisterFormData } from '@/base/port/LoginInterface';
|
|
9
|
+
import * as i18nKeys from '@config/Identifier/page.register';
|
|
11
10
|
|
|
12
|
-
export default function
|
|
11
|
+
export default function RegisterPage() {
|
|
13
12
|
const { t } = useBaseRoutePage();
|
|
14
13
|
const userService = IOC(UserService);
|
|
15
14
|
const AppConfig = IOC('AppConfig');
|
|
@@ -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/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();
|
|
@@ -1,20 +1,20 @@
|
|
|
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"
|
|
11
11
|
>
|
|
12
|
-
<BaseHeader />
|
|
12
|
+
<BaseHeader showLogoutButton />
|
|
13
13
|
|
|
14
14
|
<div className="text-text bg-primary">
|
|
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));
|