@qlover/create-app 0.1.15 → 0.1.17
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 +39 -27
- package/bin/create-app.js +0 -0
- package/configs/_common/package.json.template +11 -1
- package/configs/react-app/eslint.config.js +70 -42
- package/dist/index.cjs +1 -3631
- package/dist/index.js +1 -3625
- package/package.json +8 -8
- package/templates/node-lib/package.json +1 -1
- package/templates/pack-app/package.json +1 -1
- package/templates/react-app/.env +1 -0
- package/templates/react-app/README.md +0 -1
- package/templates/react-app/config/ErrorIdentifier.ts +27 -0
- package/templates/react-app/config/app.router.json +9 -0
- package/templates/react-app/config/common.ts +12 -0
- package/templates/react-app/config/feapi.mock.json +15 -2
- package/templates/react-app/config/i18n.ts +3 -11
- package/templates/react-app/package.json +7 -4
- package/templates/react-app/public/locales/en/common.json +6 -2
- package/templates/react-app/public/locales/zh/common.json +6 -3
- package/templates/react-app/src/App.tsx +8 -8
- package/templates/react-app/src/base/apis/AiApi.ts +55 -0
- package/templates/react-app/src/base/apis/feApi/FeApi.ts +13 -44
- package/templates/react-app/src/base/apis/feApi/FeApiAdapter.ts +14 -0
- package/templates/react-app/src/base/apis/feApi/FeApiBootstarp.ts +67 -0
- package/templates/react-app/src/base/apis/feApi/FeApiType.ts +2 -35
- package/templates/react-app/src/base/apis/userApi/UserApi.ts +64 -0
- package/templates/react-app/src/base/apis/userApi/UserApiAdapter.ts +14 -0
- package/templates/react-app/src/base/apis/userApi/UserApiBootstarp.ts +75 -0
- package/templates/react-app/src/base/apis/userApi/UserApiType.ts +52 -0
- package/templates/react-app/src/base/cases/RequestLogger.ts +71 -0
- package/templates/react-app/src/base/cases/RequestStatusCatcher.ts +41 -0
- package/templates/react-app/src/base/cases/appError/AppError.ts +13 -0
- package/templates/react-app/{lib/router-loader/RouterLoader.ts → src/base/cases/router-loader/index.ts} +1 -1
- package/templates/react-app/src/base/port/ApiTransactionInterface.ts +7 -0
- package/templates/react-app/src/base/port/InversifyIocInterface.ts +1 -1
- package/templates/react-app/src/base/port/LoginInterface.ts +4 -0
- package/templates/react-app/src/base/port/RequestCatcherInterface.ts +12 -0
- package/templates/react-app/src/{services → base/services}/I18nService.ts +7 -2
- package/templates/react-app/src/{services/processer → base/services}/ProcesserService.ts +10 -11
- package/templates/react-app/src/base/types/Page.ts +1 -13
- package/templates/react-app/src/core/AppConfig.ts +14 -5
- package/templates/react-app/src/core/IOC.ts +77 -37
- package/templates/react-app/src/core/bootstrap.ts +38 -25
- package/templates/react-app/src/core/bootstraps/BootstrapApp.ts +7 -0
- package/templates/react-app/src/core/bootstraps/index.ts +12 -0
- package/templates/react-app/src/core/globals.ts +7 -10
- package/templates/react-app/src/core/registers/RegisterApi.ts +1 -52
- package/templates/react-app/src/core/registers/RegisterCommon.ts +44 -6
- package/templates/react-app/src/core/registers/RegisterControllers.ts +5 -34
- package/templates/react-app/src/core/registers/RegisterGlobals.ts +8 -2
- package/templates/react-app/src/core/registers/index.ts +2 -1
- package/templates/react-app/src/main.tsx +4 -1
- package/templates/react-app/src/pages/auth/Layout.tsx +4 -3
- package/templates/react-app/src/pages/auth/Login.tsx +5 -3
- package/templates/react-app/src/pages/base/ErrorIdentifier.tsx +39 -0
- package/templates/react-app/src/pages/base/Executor.tsx +31 -10
- package/templates/react-app/src/pages/base/Home.tsx +58 -30
- package/templates/react-app/src/pages/base/JSONStorage.tsx +2 -4
- package/templates/react-app/src/pages/base/Request.tsx +318 -73
- package/templates/react-app/src/pages/base/components/BaseHeader.tsx +2 -2
- package/templates/react-app/src/{components → uikit/components}/RouterRenderComponent.tsx +1 -1
- package/templates/react-app/src/{components → uikit/components}/ThemeSwitcher.tsx +6 -6
- package/templates/react-app/src/uikit/contexts/BaseRouteContext.ts +6 -3
- package/templates/react-app/src/uikit/controllers/ExecutorController.ts +52 -22
- package/templates/react-app/src/uikit/controllers/JSONStorageController.ts +7 -3
- package/templates/react-app/src/uikit/controllers/RequestController.ts +65 -11
- package/templates/react-app/src/uikit/controllers/RouterController.ts +8 -7
- package/templates/react-app/src/uikit/controllers/UserController.ts +48 -54
- package/templates/react-app/src/uikit/hooks/useLanguageGuard.ts +1 -2
- package/templates/react-app/src/uikit/providers/ProcessProvider.tsx +4 -4
- package/templates/react-app/src/uikit/styles/css/index.css +1 -1
- package/templates/react-app/src/uikit/styles/css/page.css +1 -1
- package/templates/react-app/tailwind.config.js +2 -2
- package/templates/react-app/tsconfig.json +0 -1
- package/templates/react-app/tsconfig.node.json +1 -2
- package/templates/react-app/vite.config.ts +21 -26
- package/templates/react-app/.env.local +0 -24
- package/templates/react-app/lib/bootstrap/Bootstrap.ts +0 -36
- package/templates/react-app/lib/bootstrap/BootstrapExecutorPlugin.ts +0 -20
- package/templates/react-app/lib/bootstrap/IOCContainerInterface.ts +0 -33
- package/templates/react-app/lib/bootstrap/IOCManagerInterface.ts +0 -12
- package/templates/react-app/lib/bootstrap/index.ts +0 -7
- package/templates/react-app/lib/bootstrap/plugins/InjectEnv.ts +0 -61
- package/templates/react-app/lib/bootstrap/plugins/InjectGlobal.ts +0 -36
- package/templates/react-app/lib/bootstrap/plugins/InjectIOC.ts +0 -24
- package/templates/react-app/lib/env-config/injectPkgConfig.ts +0 -11
- package/templates/react-app/lib/fe-react-controller/FeController.ts +0 -19
- package/templates/react-app/lib/fe-react-controller/index.ts +0 -2
- package/templates/react-app/lib/fe-react-controller/useController.ts +0 -71
- package/templates/react-app/lib/fe-react-theme/ThemeController.ts +0 -40
- package/templates/react-app/lib/fe-react-theme/ThemeStateGetter.ts +0 -53
- package/templates/react-app/lib/fe-react-theme/index.ts +0 -3
- package/templates/react-app/lib/fe-react-theme/type.ts +0 -21
- package/templates/react-app/lib/openAiApi/OpenAIAuthPlugin.ts +0 -29
- package/templates/react-app/lib/openAiApi/OpenAIClient.ts +0 -51
- package/templates/react-app/lib/openAiApi/StreamProcessor.ts +0 -81
- package/templates/react-app/lib/openAiApi/index.ts +0 -3
- package/templates/react-app/lib/request-common-plugin/index.ts +0 -169
- package/templates/react-app/lib/router-loader/Page.ts +0 -68
- package/templates/react-app/lib/tw-root10px/index.css +0 -4
- package/templates/react-app/pnpm-lock.yaml +0 -5892
- package/templates/react-app/src/base/apis/feApi/FeApiMockPlugin.ts +0 -44
- package/templates/react-app/src/base/apis/feApi/index.ts +0 -2
- package/templates/react-app/src/base/cases/UserToken.ts +0 -47
- package/templates/react-app/src/base/consts/IOCIdentifier.ts +0 -16
- package/templates/react-app/src/base/port/IOCFunctionInterface.ts +0 -39
- package/templates/react-app/src/base/port/StorageTokenInterface.ts +0 -27
- package/templates/react-app/src/core/AppIOCContainer.ts +0 -30
- package/templates/react-app/src/uikit/utils/RequestLogger.ts +0 -37
- package/templates/react-app/src/uikit/utils/datetime.ts +0 -30
- package/templates/react-app/src/uikit/utils/thread.ts +0 -3
- /package/templates/react-app/lib/{tw-root10px/index.js → tailwind/root10px.js} +0 -0
- /package/templates/react-app/lib/{fe-react-theme/tw-generator.js → tailwind/theme-generator.js} +0 -0
- /package/templates/react-app/src/{components → uikit/components}/Loading.tsx +0 -0
- /package/templates/react-app/src/{components → uikit/components}/LocaleLink.tsx +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BootstrapExecutorPlugin } from '@qlover/corekit-bridge';
|
|
2
|
+
import { BootstrapApp } from './BootstrapApp';
|
|
3
|
+
import { UserApiBootstarp } from '@/base/apis/userApi/UserApiBootstarp';
|
|
4
|
+
import { FeApiBootstarp } from '@/base/apis/feApi/FeApiBootstarp';
|
|
5
|
+
import { AiApiBootstarp } from '@/base/apis/AiApi';
|
|
6
|
+
|
|
7
|
+
export const appBootstrapList: BootstrapExecutorPlugin[] = [
|
|
8
|
+
new UserApiBootstarp(),
|
|
9
|
+
new FeApiBootstarp(),
|
|
10
|
+
AiApiBootstarp,
|
|
11
|
+
new BootstrapApp()
|
|
12
|
+
];
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
// ! global variables, don't import any dependencies and don't have side effects
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Logger,
|
|
6
|
-
SyncStorage
|
|
7
|
-
} from '@qlover/fe-utils';
|
|
2
|
+
import { JSONStorage, JSONSerializer, SyncStorage } from '@qlover/fe-corekit';
|
|
3
|
+
import { ColorLogger } from '@qlover/corekit-bridge';
|
|
4
|
+
import { loggerStyles } from '@config/common';
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
export const isProduction = env === 'production';
|
|
6
|
+
const isProduction = import.meta.env.VITE_USER_NODE_ENV === 'production';
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
9
|
* Global logger
|
|
14
10
|
*/
|
|
15
|
-
export const logger = new
|
|
11
|
+
export const logger = new ColorLogger({
|
|
16
12
|
silent: isProduction,
|
|
17
|
-
debug: !isProduction
|
|
13
|
+
debug: !isProduction,
|
|
14
|
+
colorsMaps: loggerStyles
|
|
18
15
|
});
|
|
19
16
|
|
|
20
17
|
/**
|
|
@@ -3,57 +3,6 @@ import type {
|
|
|
3
3
|
InversifyRegisterContainer
|
|
4
4
|
} from '@/base/port/InversifyIocInterface';
|
|
5
5
|
|
|
6
|
-
import { RequestLogger } from '@/uikit/utils/RequestLogger';
|
|
7
|
-
import { localJsonStorage } from '../globals';
|
|
8
|
-
import { FetchAbortPlugin, FetchURLPlugin } from '@qlover/fe-utils';
|
|
9
|
-
import { FeApiMockPlugin } from '@/base/apis/feApi';
|
|
10
|
-
import { OpenAIClient } from '@lib/openAiApi';
|
|
11
|
-
import { FeApi } from '@/base/apis/feApi';
|
|
12
|
-
import { RequestCommonPlugin } from '@lib/request-common-plugin';
|
|
13
|
-
import mockDataJson from '@config/feapi.mock.json';
|
|
14
|
-
import AppConfig from '@/core/AppConfig';
|
|
15
|
-
|
|
16
6
|
export class RegisterApi implements InversifyRegisterInterface {
|
|
17
|
-
register(
|
|
18
|
-
const openAiApi = new OpenAIClient({
|
|
19
|
-
baseURL: AppConfig.openAiBaseUrl,
|
|
20
|
-
models: AppConfig.openAiModels,
|
|
21
|
-
commonPluginConfig: {
|
|
22
|
-
tokenPrefix: AppConfig.openAiTokenPrefix,
|
|
23
|
-
token: AppConfig.openAiToken,
|
|
24
|
-
defaultHeaders: {
|
|
25
|
-
'Content-Type': 'application/json'
|
|
26
|
-
},
|
|
27
|
-
defaultRequestData: {
|
|
28
|
-
model: AppConfig.openAiModels[0],
|
|
29
|
-
stream: true
|
|
30
|
-
},
|
|
31
|
-
requiredToken: true,
|
|
32
|
-
requestDataSerializer: (data) => JSON.stringify(data)
|
|
33
|
-
}
|
|
34
|
-
}).usePlugin(container.get(RequestLogger));
|
|
35
|
-
|
|
36
|
-
const abortPlugin = container.get(FetchAbortPlugin);
|
|
37
|
-
const feApi = new FeApi({
|
|
38
|
-
abortPlugin,
|
|
39
|
-
config: {
|
|
40
|
-
responseType: 'json',
|
|
41
|
-
baseURL: 'https://api.example.com/'
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
.usePlugin(new FetchURLPlugin())
|
|
45
|
-
.usePlugin(
|
|
46
|
-
new RequestCommonPlugin({
|
|
47
|
-
tokenPrefix: AppConfig.openAiTokenPrefix,
|
|
48
|
-
requiredToken: true,
|
|
49
|
-
token: () => localJsonStorage.getItem('fe_user_token')
|
|
50
|
-
})
|
|
51
|
-
)
|
|
52
|
-
.usePlugin(new FeApiMockPlugin(mockDataJson))
|
|
53
|
-
.usePlugin(container.get(RequestLogger))
|
|
54
|
-
.usePlugin(abortPlugin);
|
|
55
|
-
|
|
56
|
-
container.bind(OpenAIClient).toConstantValue(openAiApi);
|
|
57
|
-
container.bind(FeApi).toConstantValue(feApi);
|
|
58
|
-
}
|
|
7
|
+
register(_container: InversifyRegisterContainer): void {}
|
|
59
8
|
}
|
|
@@ -2,20 +2,58 @@ import type {
|
|
|
2
2
|
InversifyRegisterInterface,
|
|
3
3
|
InversifyRegisterContainer
|
|
4
4
|
} from '@/base/port/InversifyIocInterface';
|
|
5
|
-
|
|
6
|
-
import { FetchAbortPlugin, JSONStorage } from '@qlover/fe-utils';
|
|
7
|
-
import { UserToken } from '@/base/cases/UserToken';
|
|
5
|
+
import { FetchAbortPlugin, JSONStorage, Logger } from '@qlover/fe-corekit';
|
|
8
6
|
import AppConfig from '@/core/AppConfig';
|
|
7
|
+
import { IOCIdentifier } from '@/core/IOC';
|
|
8
|
+
import {
|
|
9
|
+
UserToken,
|
|
10
|
+
RequestCommonPlugin,
|
|
11
|
+
ApiMockPlugin,
|
|
12
|
+
ApiCatchPlugin,
|
|
13
|
+
ThemeService
|
|
14
|
+
} from '@qlover/corekit-bridge';
|
|
15
|
+
import mockDataJson from '@config/feapi.mock.json';
|
|
16
|
+
import { RequestStatusCatcher } from '@/base/cases/RequestStatusCatcher';
|
|
17
|
+
import { override as themeOverride } from '@config/theme.json';
|
|
18
|
+
import { localJsonStorage } from '../globals';
|
|
9
19
|
|
|
10
20
|
export class RegisterCommon implements InversifyRegisterInterface {
|
|
11
21
|
register(container: InversifyRegisterContainer): void {
|
|
22
|
+
const userToken = new UserToken(
|
|
23
|
+
AppConfig.userTokenStorageKey,
|
|
24
|
+
container.get(JSONStorage)
|
|
25
|
+
);
|
|
12
26
|
const feApiAbort = new FetchAbortPlugin();
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
const feApiRequestCommonPlugin = new RequestCommonPlugin({
|
|
28
|
+
tokenPrefix: AppConfig.openAiTokenPrefix,
|
|
29
|
+
requiredToken: true,
|
|
30
|
+
token: () => userToken.getToken()
|
|
16
31
|
});
|
|
17
32
|
|
|
18
33
|
container.bind(FetchAbortPlugin).toConstantValue(feApiAbort);
|
|
19
34
|
container.bind(UserToken).toConstantValue(userToken);
|
|
35
|
+
|
|
36
|
+
container.bind(IOCIdentifier.FeApiToken).toConstantValue(userToken);
|
|
37
|
+
container
|
|
38
|
+
.bind(IOCIdentifier.FeApiCommonPlugin)
|
|
39
|
+
.toConstantValue(feApiRequestCommonPlugin);
|
|
40
|
+
container
|
|
41
|
+
.bind(IOCIdentifier.ApiMockPlugin)
|
|
42
|
+
.toConstantValue(new ApiMockPlugin(mockDataJson, container.get(Logger)));
|
|
43
|
+
container
|
|
44
|
+
.bind(IOCIdentifier.ApiCatchPlugin)
|
|
45
|
+
.toConstantValue(
|
|
46
|
+
new ApiCatchPlugin(
|
|
47
|
+
container.get(Logger),
|
|
48
|
+
container.get(RequestStatusCatcher)
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
container.bind(ThemeService).toConstantValue(
|
|
53
|
+
new ThemeService({
|
|
54
|
+
...themeOverride,
|
|
55
|
+
storage: localJsonStorage
|
|
56
|
+
})
|
|
57
|
+
);
|
|
20
58
|
}
|
|
21
59
|
}
|
|
@@ -6,53 +6,24 @@ import type {
|
|
|
6
6
|
import { localJsonStorage, logger } from '../globals';
|
|
7
7
|
import { RouterController } from '@/uikit/controllers/RouterController';
|
|
8
8
|
import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
|
|
9
|
-
import {
|
|
10
|
-
import { ProcesserService } from '@/services/processer/ProcesserService';
|
|
11
|
-
import { ExecutorController } from '@/uikit/controllers/ExecutorController';
|
|
9
|
+
import { ProcesserService } from '@/base/services/ProcesserService';
|
|
12
10
|
import { UserController } from '@/uikit/controllers/UserController';
|
|
13
|
-
import {
|
|
14
|
-
import { RouteConfig } from '@/base/types/Page';
|
|
15
|
-
import { OpenAIClient } from '@lib/openAiApi';
|
|
16
|
-
import { FeApi } from '@/base/apis/feApi';
|
|
17
|
-
import appRouterConfig from '@config/app.router.json';
|
|
18
|
-
import themeConfigJson from '@config/theme.json';
|
|
19
|
-
import { UserToken } from '@/base/cases/UserToken';
|
|
11
|
+
import { base as baseRoutes } from '@config/app.router.json';
|
|
20
12
|
|
|
21
13
|
export class RegisterControllers implements InversifyRegisterInterface {
|
|
22
14
|
register(container: InversifyRegisterContainer): void {
|
|
23
15
|
const routerController = new RouterController({
|
|
24
|
-
config:
|
|
16
|
+
config: baseRoutes,
|
|
25
17
|
logger
|
|
26
18
|
});
|
|
27
19
|
|
|
28
20
|
const jsonStorageController = new JSONStorageController(localJsonStorage);
|
|
29
|
-
const requestController = new RequestController(
|
|
30
|
-
container.get(OpenAIClient),
|
|
31
|
-
container.get(FeApi)
|
|
32
|
-
);
|
|
33
|
-
const executorController = new ExecutorController(container.get(FeApi));
|
|
34
|
-
const userController = new UserController({
|
|
35
|
-
userToken: container.get(UserToken),
|
|
36
|
-
feApi: container.get(FeApi),
|
|
37
|
-
routerController
|
|
38
|
-
});
|
|
39
|
-
const themeController = new ThemeController({
|
|
40
|
-
...themeConfigJson.override,
|
|
41
|
-
storage: localJsonStorage
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const pageProcesser = new ProcesserService({
|
|
45
|
-
logger
|
|
46
|
-
}).usePlugin(userController);
|
|
47
21
|
|
|
48
22
|
container.bind(RouterController).toConstantValue(routerController);
|
|
49
23
|
container
|
|
50
24
|
.bind(JSONStorageController)
|
|
51
25
|
.toConstantValue(jsonStorageController);
|
|
52
|
-
|
|
53
|
-
container.
|
|
54
|
-
container.bind(UserController).toConstantValue(userController);
|
|
55
|
-
container.bind(ThemeController).toConstantValue(themeController);
|
|
56
|
-
container.bind(ProcesserService).toConstantValue(pageProcesser);
|
|
26
|
+
|
|
27
|
+
container.get(ProcesserService).use(container.get(UserController));
|
|
57
28
|
}
|
|
58
29
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { JSONSerializer, JSONStorage, Logger } from '@qlover/fe-corekit';
|
|
2
|
+
import type { EnvConfigInterface } from '@qlover/corekit-bridge';
|
|
1
3
|
import type {
|
|
2
4
|
InversifyRegisterInterface,
|
|
3
5
|
InversifyRegisterContainer
|
|
4
6
|
} from '@/base/port/InversifyIocInterface';
|
|
5
7
|
import { JSON, localJsonStorage, logger } from '../globals';
|
|
6
|
-
import {
|
|
7
|
-
import { IOCIdentifier } from '@/base/consts/IOCIdentifier';
|
|
8
|
+
import { IOCIdentifier } from '@/core/IOC';
|
|
8
9
|
|
|
9
10
|
export class RegisterGlobals implements InversifyRegisterInterface {
|
|
11
|
+
constructor(private appConfig: EnvConfigInterface) {}
|
|
12
|
+
|
|
10
13
|
register(container: InversifyRegisterContainer): void {
|
|
14
|
+
// inject AppConfig to IOC
|
|
15
|
+
container.bind(IOCIdentifier.AppConfig).toConstantValue(this.appConfig);
|
|
16
|
+
|
|
11
17
|
container.bind(JSONSerializer).toConstantValue(JSON);
|
|
12
18
|
container.bind(IOCIdentifier.JSON).toConstantValue(JSON);
|
|
13
19
|
|
|
@@ -3,6 +3,7 @@ import { RegisterGlobals } from './RegisterGlobals';
|
|
|
3
3
|
import { RegisterCommon } from './RegisterCommon';
|
|
4
4
|
import { RegisterApi } from './RegisterApi';
|
|
5
5
|
import { RegisterControllers } from './RegisterControllers';
|
|
6
|
+
import AppConfig from '../AppConfig';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Register List
|
|
@@ -10,7 +11,7 @@ import { RegisterControllers } from './RegisterControllers';
|
|
|
10
11
|
* Register List is used to register dependencies in bootstrap
|
|
11
12
|
*/
|
|
12
13
|
export const registerList: InversifyRegisterInterface[] = [
|
|
13
|
-
new RegisterGlobals(),
|
|
14
|
+
new RegisterGlobals(AppConfig),
|
|
14
15
|
new RegisterCommon(),
|
|
15
16
|
new RegisterApi(),
|
|
16
17
|
new RegisterControllers()
|
|
@@ -5,7 +5,10 @@ import { createRoot } from 'react-dom/client';
|
|
|
5
5
|
import App from './App.tsx';
|
|
6
6
|
import startup from './core/bootstrap';
|
|
7
7
|
|
|
8
|
-
startup(
|
|
8
|
+
startup({
|
|
9
|
+
window: window,
|
|
10
|
+
envSource: import.meta.env
|
|
11
|
+
});
|
|
9
12
|
|
|
10
13
|
createRoot(document.getElementById('root')!).render(
|
|
11
14
|
<StrictMode>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { IOC } from '@/core/IOC';
|
|
2
2
|
import { UserController } from '@/uikit/controllers/UserController';
|
|
3
|
-
import { useController } from '@lib/fe-react-controller';
|
|
4
3
|
import { Navigate, Outlet } from 'react-router-dom';
|
|
4
|
+
import { useSliceStore } from '@qlover/slice-store-react';
|
|
5
5
|
|
|
6
6
|
export default function Layout() {
|
|
7
|
-
const
|
|
7
|
+
const userController = IOC(UserController);
|
|
8
|
+
useSliceStore(userController, (state) => state.success);
|
|
8
9
|
|
|
9
10
|
// If user is authenticated, redirect to home page
|
|
10
|
-
if (
|
|
11
|
+
if (userController.isAuthenticated()) {
|
|
11
12
|
return <Navigate to="/" replace />;
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { useController } from '@lib/fe-react-controller';
|
|
3
2
|
import { IOC } from '@/core/IOC';
|
|
4
3
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
5
4
|
import { RouterController } from '@/uikit/controllers/RouterController';
|
|
6
5
|
import { UserController } from '@/uikit/controllers/UserController';
|
|
7
6
|
import AppConfig from '@/core/AppConfig';
|
|
7
|
+
import { useSliceStore } from '@qlover/slice-store-react';
|
|
8
8
|
|
|
9
9
|
export default function Login() {
|
|
10
10
|
const { t } = useBaseRoutePage();
|
|
11
|
-
const
|
|
11
|
+
const userController = IOC(UserController);
|
|
12
|
+
useSliceStore(userController);
|
|
13
|
+
|
|
12
14
|
const [email, setEmail] = useState(AppConfig.loginUser);
|
|
13
15
|
const [password, setPassword] = useState(AppConfig.loginPassword);
|
|
14
16
|
const [loading, setLoading] = useState(false);
|
|
@@ -16,7 +18,7 @@ export default function Login() {
|
|
|
16
18
|
const handleLogin = async () => {
|
|
17
19
|
try {
|
|
18
20
|
setLoading(true);
|
|
19
|
-
await
|
|
21
|
+
await userController.login({ username: email, password });
|
|
20
22
|
// Redirect or show success message
|
|
21
23
|
IOC(RouterController).replaceToHome();
|
|
22
24
|
} catch (error) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
2
|
+
import * as ErrorIdentifierList from '@config/ErrorIdentifier';
|
|
3
|
+
|
|
4
|
+
export default function ErrorIdentifier() {
|
|
5
|
+
const { t } = useBaseRoutePage();
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<div className="min-h-screen bg-gray-100/90 py-8 px-4 sm:px-6 lg:px-8">
|
|
9
|
+
<div className="max-w-3xl mx-auto">
|
|
10
|
+
<div className="bg-white shadow-lg rounded-lg overflow-hidden">
|
|
11
|
+
<div className="bg-gradient-to-r from-blue-500 to-purple-600 px-6 py-4">
|
|
12
|
+
<h1 className="text-2xl font-bold text-white">
|
|
13
|
+
{t('errorIdentifier')}
|
|
14
|
+
</h1>
|
|
15
|
+
<p className="text-blue-100 mt-1">
|
|
16
|
+
Identifier From: '@config/ErrorIdentifier'
|
|
17
|
+
</p>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<div className="divide-y divide-gray-200">
|
|
21
|
+
{Object.entries(ErrorIdentifierList).map(([key, value]) => (
|
|
22
|
+
<div
|
|
23
|
+
key={key}
|
|
24
|
+
className="px-6 py-4 flex flex-col sm:flex-row sm:items-center hover:bg-gray-50"
|
|
25
|
+
>
|
|
26
|
+
<span className="font-medium text-gray-700 mr-3 min-w-[200px]">
|
|
27
|
+
{key}
|
|
28
|
+
</span>
|
|
29
|
+
<span className="mt-1 sm:mt-0 text-gray-600 bg-gray-100 px-3 py-1 rounded-md">
|
|
30
|
+
{t(value)}
|
|
31
|
+
</span>
|
|
32
|
+
</div>
|
|
33
|
+
))}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { IOC } from '@/core/IOC';
|
|
2
|
-
import { useControllerState } from '@lib/fe-react-controller';
|
|
3
2
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
4
3
|
import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
|
|
5
4
|
import { ExecutorController } from '@/uikit/controllers/ExecutorController';
|
|
5
|
+
import { useSliceStore } from '@qlover/slice-store-react';
|
|
6
6
|
|
|
7
7
|
export default function Executor() {
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const executorController = IOC(ExecutorController);
|
|
9
|
+
const jSONStorageController = IOC(JSONStorageController);
|
|
10
|
+
const requestTimeout = useSliceStore(
|
|
11
|
+
jSONStorageController,
|
|
12
|
+
jSONStorageController.selector.requestTimeout
|
|
10
13
|
);
|
|
14
|
+
|
|
15
|
+
const helloState = useSliceStore(
|
|
16
|
+
executorController,
|
|
17
|
+
executorController.selector.helloState
|
|
18
|
+
);
|
|
19
|
+
|
|
11
20
|
const { t } = useBaseRoutePage();
|
|
12
21
|
|
|
13
22
|
return (
|
|
@@ -20,7 +29,7 @@ export default function Executor() {
|
|
|
20
29
|
</div>
|
|
21
30
|
|
|
22
31
|
<div className="bg-white shadow-lg rounded-lg px-8 py-6">
|
|
23
|
-
{t('requestTimeout')}: {
|
|
32
|
+
{t('requestTimeout')}: {requestTimeout}
|
|
24
33
|
</div>
|
|
25
34
|
<div className="space-y-6">
|
|
26
35
|
<div className="p-6 bg-gray-50 rounded-lg">
|
|
@@ -28,12 +37,24 @@ export default function Executor() {
|
|
|
28
37
|
{t('executorTestPlugin')}
|
|
29
38
|
</h2>
|
|
30
39
|
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
<div className="text-gray-800">
|
|
41
|
+
{helloState.loading ? (
|
|
42
|
+
<div>Loading...</div>
|
|
43
|
+
) : (
|
|
44
|
+
<button
|
|
45
|
+
className="bg-blue-500 px-4 py-2 rounded-md"
|
|
46
|
+
onClick={executorController.onTestPlugins}
|
|
47
|
+
>
|
|
48
|
+
{t('testPlugin')}
|
|
49
|
+
</button>
|
|
50
|
+
)}
|
|
51
|
+
|
|
52
|
+
{helloState.error instanceof Error ? (
|
|
53
|
+
<div>{helloState.error.message}</div>
|
|
54
|
+
) : (
|
|
55
|
+
<div>{IOC('JSON').stringify(helloState.result?.data)}</div>
|
|
56
|
+
)}
|
|
57
|
+
</div>
|
|
37
58
|
</div>
|
|
38
59
|
</div>
|
|
39
60
|
</div>
|
|
@@ -1,6 +1,49 @@
|
|
|
1
|
-
import LocaleLink from '@/components/LocaleLink';
|
|
1
|
+
import LocaleLink from '@/uikit/components/LocaleLink';
|
|
2
2
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
3
3
|
|
|
4
|
+
const navigationItems = [
|
|
5
|
+
{
|
|
6
|
+
href: '/about',
|
|
7
|
+
bgColor: 'bg-blue-50',
|
|
8
|
+
hoverColor: 'hover:bg-blue-100',
|
|
9
|
+
titleColor: 'text-blue-700',
|
|
10
|
+
titleKey: 'about',
|
|
11
|
+
descriptionKey: 'about_description'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
href: '/jsonstorage',
|
|
15
|
+
bgColor: 'bg-green-50',
|
|
16
|
+
hoverColor: 'hover:bg-green-100',
|
|
17
|
+
titleColor: 'text-green-700',
|
|
18
|
+
titleKey: 'jsonstorage',
|
|
19
|
+
descriptionKey: 'jsonstorage_description'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
href: '/request',
|
|
23
|
+
bgColor: 'bg-red-50',
|
|
24
|
+
hoverColor: 'hover:bg-red-100',
|
|
25
|
+
titleColor: 'text-red-700',
|
|
26
|
+
titleKey: 'request',
|
|
27
|
+
descriptionKey: 'request_description'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
href: '/executor',
|
|
31
|
+
bgColor: 'bg-purple-50',
|
|
32
|
+
hoverColor: 'hover:bg-purple-100',
|
|
33
|
+
titleColor: 'text-purple-700',
|
|
34
|
+
titleKey: 'executor',
|
|
35
|
+
descriptionKey: 'executor_description'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
href: '/errorIdentifier',
|
|
39
|
+
bgColor: 'bg-amber-50',
|
|
40
|
+
hoverColor: 'hover:bg-amber-100',
|
|
41
|
+
titleColor: 'text-amber-700',
|
|
42
|
+
titleKey: 'errorIdentifier',
|
|
43
|
+
descriptionKey: 'errorIdentifier_description'
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
|
|
4
47
|
export default function Home() {
|
|
5
48
|
const { t } = useBaseRoutePage();
|
|
6
49
|
|
|
@@ -18,35 +61,20 @@ export default function Home() {
|
|
|
18
61
|
</div>
|
|
19
62
|
|
|
20
63
|
<div className="grid gap-4">
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<h2 className="text-xl font-semibold text-green-700 mb-2">
|
|
36
|
-
{t('jsonstorage')}
|
|
37
|
-
</h2>
|
|
38
|
-
<p className="text-gray-600">{t('jsonstorage_description')}</p>
|
|
39
|
-
</LocaleLink>
|
|
40
|
-
|
|
41
|
-
<LocaleLink
|
|
42
|
-
href="/request"
|
|
43
|
-
className="block p-4 bg-red-50 rounded-lg hover:bg-red-100 transition-colors duration-200"
|
|
44
|
-
>
|
|
45
|
-
<h2 className="text-xl font-semibold text-red-700 mb-2">
|
|
46
|
-
{t('request')}
|
|
47
|
-
</h2>
|
|
48
|
-
<p className="text-gray-600">{t('request_description')}</p>
|
|
49
|
-
</LocaleLink>
|
|
64
|
+
{navigationItems.map((item, index) => (
|
|
65
|
+
<LocaleLink
|
|
66
|
+
key={index}
|
|
67
|
+
href={item.href}
|
|
68
|
+
className={`block p-4 ${item.bgColor} rounded-lg ${item.hoverColor} transition-colors duration-200`}
|
|
69
|
+
>
|
|
70
|
+
<h2
|
|
71
|
+
className={`text-xl font-semibold ${item.titleColor} mb-2`}
|
|
72
|
+
>
|
|
73
|
+
{t(item.titleKey)}
|
|
74
|
+
</h2>
|
|
75
|
+
<p className="text-gray-600">{t(item.descriptionKey)}</p>
|
|
76
|
+
</LocaleLink>
|
|
77
|
+
))}
|
|
50
78
|
</div>
|
|
51
79
|
|
|
52
80
|
<div className="mt-8 text-center">
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { IOC } from '@/core/IOC';
|
|
2
|
-
import { useController, useControllerState } from '@lib/fe-react-controller';
|
|
3
2
|
import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
|
|
4
3
|
import template from 'lodash/template';
|
|
5
4
|
import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
|
|
5
|
+
import { useSliceStore } from '@qlover/slice-store-react';
|
|
6
6
|
|
|
7
7
|
export default function JSONStorage() {
|
|
8
8
|
const jsonStorageController = IOC(JSONStorageController);
|
|
9
|
-
const controllerState =
|
|
10
|
-
useController(jsonStorageController)
|
|
11
|
-
);
|
|
9
|
+
const controllerState = useSliceStore(jsonStorageController);
|
|
12
10
|
|
|
13
11
|
const { t } = useBaseRoutePage();
|
|
14
12
|
|