@qlover/create-app 0.1.14 → 0.1.16
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 +41 -16
- package/bin/create-app.js +0 -0
- package/configs/_common/package.json.template +10 -0
- package/configs/react-app/eslint.config.js +70 -42
- package/dist/index.cjs +1 -3631
- package/dist/index.js +1 -3625
- package/package.json +7 -7
- package/templates/react-app/.env +1 -0
- 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/pnpm-lock.yaml +176 -25
- 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/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
|
@@ -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
|
|