@qlover/create-app 0.3.2 → 0.3.4
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 +139 -0
- package/package.json +4 -4
- package/templates/react-app/README.md +311 -120
- package/templates/react-app/config/Identifier.I18n.ts +1048 -0
- package/templates/react-app/config/app.router.json +7 -7
- package/templates/react-app/config/common.ts +13 -0
- package/templates/react-app/config/theme.json +7 -88
- package/templates/react-app/package.json +11 -5
- package/templates/react-app/postcss.config.js +1 -2
- package/templates/react-app/public/locales/en/common.json +142 -1
- package/templates/react-app/public/locales/zh/common.json +142 -1
- package/templates/react-app/src/App.tsx +16 -3
- package/templates/react-app/src/base/apis/AiApi.ts +4 -4
- package/templates/react-app/src/base/apis/feApi/FeApiAdapter.ts +2 -2
- package/templates/react-app/src/base/apis/userApi/UserApiAdapter.ts +2 -2
- package/templates/react-app/src/base/cases/AppConfig.ts +103 -0
- package/templates/react-app/src/base/cases/{appError/AppError.ts → AppError.ts} +0 -3
- package/templates/react-app/src/base/cases/DialogHandler.ts +86 -0
- package/templates/react-app/src/base/cases/RequestLogger.ts +1 -1
- package/templates/react-app/src/base/cases/RouterLoader.ts +166 -0
- package/templates/react-app/src/base/port/InteractionHubInterface.ts +94 -0
- package/templates/react-app/src/base/services/I18nService.ts +50 -3
- package/templates/react-app/src/base/services/ProcesserService.ts +0 -1
- package/templates/react-app/src/base/types/deprecated-antd.d.ts +60 -0
- package/templates/react-app/src/core/IOC.ts +18 -8
- package/templates/react-app/src/core/bootstrap.ts +41 -62
- package/templates/react-app/src/core/bootstraps/PrintBootstrap.ts +14 -0
- package/templates/react-app/src/core/bootstraps/index.ts +36 -7
- package/templates/react-app/src/core/globals.ts +8 -1
- package/templates/react-app/src/core/registers/RegisterApi.ts +2 -5
- package/templates/react-app/src/core/registers/RegisterCommon.ts +38 -29
- package/templates/react-app/src/core/registers/RegisterControllers.ts +5 -10
- package/templates/react-app/src/core/registers/RegisterGlobals.ts +21 -17
- package/templates/react-app/src/core/registers/index.ts +27 -13
- package/templates/react-app/src/main.tsx +1 -1
- package/templates/react-app/src/pages/404.tsx +1 -1
- package/templates/react-app/src/pages/500.tsx +1 -1
- package/templates/react-app/src/pages/auth/Login.tsx +128 -36
- package/templates/react-app/src/pages/base/About.tsx +118 -2
- package/templates/react-app/src/pages/base/ErrorIdentifier.tsx +38 -19
- package/templates/react-app/src/pages/base/Executor.tsx +442 -29
- package/templates/react-app/src/pages/base/Home.tsx +99 -93
- package/templates/react-app/src/pages/base/JSONStorage.tsx +47 -38
- package/templates/react-app/src/pages/base/Layout.tsx +5 -2
- package/templates/react-app/src/pages/base/Request.tsx +90 -208
- package/templates/react-app/src/pages/base/components/BaseHeader.tsx +13 -5
- package/templates/react-app/src/styles/css/antd-themes/_default.css +239 -0
- package/templates/react-app/src/styles/css/antd-themes/dark.css +176 -0
- package/templates/react-app/src/styles/css/antd-themes/index.css +3 -0
- package/templates/react-app/src/styles/css/antd-themes/no-context.css +34 -0
- package/templates/react-app/src/styles/css/antd-themes/pink.css +199 -0
- package/templates/react-app/src/{uikit/styles → styles}/css/index.css +3 -0
- package/templates/react-app/src/styles/css/page.css +11 -0
- package/templates/react-app/src/styles/css/tailwind.css +5 -0
- package/templates/react-app/src/styles/css/themes/_default.css +29 -0
- package/templates/react-app/src/styles/css/themes/dark.css +29 -0
- package/templates/react-app/src/styles/css/themes/index.css +3 -0
- package/templates/react-app/src/styles/css/themes/pink.css +29 -0
- package/templates/react-app/src/uikit/components/LanguageSwitcher.tsx +56 -0
- package/templates/react-app/src/uikit/components/Loading.tsx +27 -21
- package/templates/react-app/src/uikit/components/RouterRenderComponent.tsx +1 -1
- package/templates/react-app/src/uikit/components/ThemeSwitcher.tsx +63 -13
- package/templates/react-app/src/uikit/contexts/BaseRouteContext.ts +1 -1
- package/templates/react-app/src/uikit/controllers/RouterController.ts +1 -1
- package/templates/react-app/src/uikit/controllers/UserController.ts +2 -2
- package/templates/react-app/tailwind.config.js +1 -15
- package/templates/react-app/tsconfig.json +3 -2
- package/templates/react-app/tsconfig.node.json +2 -1
- package/templates/react-app/vite.config.ts +15 -3
- package/templates/react-app/lib/tailwind/root10px.js +0 -178
- package/templates/react-app/lib/tailwind/theme-generator.js +0 -238
- package/templates/react-app/public/locales/en/about.json +0 -3
- package/templates/react-app/public/locales/en/executor.json +0 -6
- package/templates/react-app/public/locales/en/home.json +0 -10
- package/templates/react-app/public/locales/en/jsonStorage.json +0 -11
- package/templates/react-app/public/locales/en/login.json +0 -7
- package/templates/react-app/public/locales/en/request.json +0 -15
- package/templates/react-app/public/locales/zh/about.json +0 -3
- package/templates/react-app/public/locales/zh/executor.json +0 -6
- package/templates/react-app/public/locales/zh/home.json +0 -10
- package/templates/react-app/public/locales/zh/jsonStorage.json +0 -11
- package/templates/react-app/public/locales/zh/login.json +0 -7
- package/templates/react-app/public/locales/zh/request.json +0 -15
- package/templates/react-app/src/base/cases/router-loader/index.ts +0 -90
- package/templates/react-app/src/base/port/InversifyIocInterface.ts +0 -9
- package/templates/react-app/src/core/AppConfig.ts +0 -36
- package/templates/react-app/src/uikit/styles/css/page.css +0 -3
- package/templates/react-app/src/uikit/styles/css/tailwind.css +0 -3
- /package/templates/react-app/config/{ErrorIdentifier.ts → Identifier.Error.ts} +0 -0
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import plugin from 'tailwindcss/plugin';
|
|
2
|
-
import template from 'lodash/template';
|
|
3
|
-
import isPlainObject from 'lodash/isPlainObject';
|
|
4
|
-
import isString from 'lodash/isString';
|
|
5
|
-
|
|
6
|
-
class KeyTemplate {
|
|
7
|
-
constructor(options) {
|
|
8
|
-
/**
|
|
9
|
-
* @type {import('./type').ThemeConfig}
|
|
10
|
-
*/
|
|
11
|
-
this.options = options;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Get the colors value
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```
|
|
19
|
-
* colors: {
|
|
20
|
-
* primary: {
|
|
21
|
-
* "500": getColorsValue()
|
|
22
|
-
* },
|
|
23
|
-
* secondary: getColorsValue()
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @param {string} colorKey - The color key
|
|
28
|
-
* @param {string} value - The color value
|
|
29
|
-
* @returns {string} - The colors value
|
|
30
|
-
*/
|
|
31
|
-
getColorsValue({ key, parentKey = '', value }) {
|
|
32
|
-
const { colorsValueTemplate, ...rest } = this.options;
|
|
33
|
-
|
|
34
|
-
let colorKey = key;
|
|
35
|
-
if (parentKey) {
|
|
36
|
-
colorKey = this.composeKey(key, parentKey);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// if colorsValueTemplate is provided, use it to generate the colors value
|
|
40
|
-
if (colorsValueTemplate) {
|
|
41
|
-
const styleKey = this.getStyleKey(colorKey);
|
|
42
|
-
return template(colorsValueTemplate)({
|
|
43
|
-
...rest,
|
|
44
|
-
styleKey,
|
|
45
|
-
key,
|
|
46
|
-
parentKey,
|
|
47
|
-
value
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Get the style theme key
|
|
56
|
-
*
|
|
57
|
-
* ```
|
|
58
|
-
* <style>
|
|
59
|
-
* [getStyleThemeKey()] {
|
|
60
|
-
* primary: #000;
|
|
61
|
-
* }
|
|
62
|
-
* </style>
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @param {string} theme - The theme name
|
|
66
|
-
* @returns {string} - The style theme key
|
|
67
|
-
*/
|
|
68
|
-
getStyleThemeKey(theme) {
|
|
69
|
-
const { styleThemeKeyTemplate, target, ...rest } = this.options;
|
|
70
|
-
|
|
71
|
-
// if styleThemeKeyTemplate is provided, use it to generate the style theme key
|
|
72
|
-
if (styleThemeKeyTemplate) {
|
|
73
|
-
return template(styleThemeKeyTemplate)({ ...rest, theme, target });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return `${target}.${theme}`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Get the style key template
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
*
|
|
84
|
-
* ```
|
|
85
|
-
* <style>
|
|
86
|
-
* [getStyleThemeKey()] {
|
|
87
|
-
* [getStyleKeyTemplate()]: #000;
|
|
88
|
-
* }
|
|
89
|
-
* </style>
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* @param {string} key - The key name
|
|
93
|
-
* @param {string | undefined} parentKey - The parent key name
|
|
94
|
-
* @returns {string} - The style key template
|
|
95
|
-
*/
|
|
96
|
-
getStyleKey(key, parentKey) {
|
|
97
|
-
const { styleKeyTemplate, ...rest } = this.options;
|
|
98
|
-
|
|
99
|
-
// if parentKey is provided, compose the key
|
|
100
|
-
let colorKey = key;
|
|
101
|
-
if (parentKey) {
|
|
102
|
-
colorKey = this.composeKey(key, parentKey);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// if styleKeyTemplate is provided, use it to generate the style key
|
|
106
|
-
if (styleKeyTemplate) {
|
|
107
|
-
return template(styleKeyTemplate)({ ...rest, colorKey, parentKey });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return key;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
composeKey(key, parentKey) {
|
|
114
|
-
return parentKey ? `${parentKey}-${key}` : key;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
class Generator {
|
|
119
|
-
constructor(options) {
|
|
120
|
-
this.options = options;
|
|
121
|
-
this.keyTemplate = new KeyTemplate(options);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
generateBaseStyles() {
|
|
125
|
-
const { colors } = this.options;
|
|
126
|
-
|
|
127
|
-
const baseStyles = {};
|
|
128
|
-
|
|
129
|
-
Object.entries(colors).forEach(([theme, themeColors]) => {
|
|
130
|
-
const styleThemeKey = this.keyTemplate.getStyleThemeKey(theme);
|
|
131
|
-
|
|
132
|
-
baseStyles[styleThemeKey] = {};
|
|
133
|
-
|
|
134
|
-
Object.entries(themeColors).forEach(([colorKey, value]) => {
|
|
135
|
-
if (isPlainObject(value)) {
|
|
136
|
-
Object.entries(value).forEach(([key, colorValue]) => {
|
|
137
|
-
baseStyles[styleThemeKey][
|
|
138
|
-
this.keyTemplate.getStyleKey(key, colorKey)
|
|
139
|
-
] = colorValue;
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
// if value is string, it means it's a color value
|
|
143
|
-
else if (isString(value)) {
|
|
144
|
-
baseStyles[styleThemeKey][this.keyTemplate.getStyleKey(colorKey)] =
|
|
145
|
-
value;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
return this.setDefaultStyleThemeKey(baseStyles);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
setDefaultStyleThemeKey(baseStyles) {
|
|
154
|
-
const { defaultTheme, colors } = this.options;
|
|
155
|
-
|
|
156
|
-
// set default style theme key
|
|
157
|
-
let _defaultTheme = defaultTheme;
|
|
158
|
-
if (
|
|
159
|
-
// if default theme is not provided, set it to the first theme
|
|
160
|
-
!defaultTheme ||
|
|
161
|
-
// if default theme is system, set it to the first theme
|
|
162
|
-
defaultTheme === 'system' ||
|
|
163
|
-
// if default theme is not in colors, set it to the first theme
|
|
164
|
-
!Object.keys(colors).includes(defaultTheme)
|
|
165
|
-
) {
|
|
166
|
-
_defaultTheme = Object.keys(colors)?.[0];
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const defaultStyleThemeKey =
|
|
170
|
-
this.keyTemplate.getStyleThemeKey(_defaultTheme);
|
|
171
|
-
|
|
172
|
-
const result = {};
|
|
173
|
-
Object.entries(baseStyles).forEach(([key, value]) => {
|
|
174
|
-
if (key === defaultStyleThemeKey) {
|
|
175
|
-
result[':root'] = value;
|
|
176
|
-
} else {
|
|
177
|
-
result[key] = value;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
return result;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
generateThemeColors() {
|
|
185
|
-
const { colors } = this.options;
|
|
186
|
-
|
|
187
|
-
const themeResultColors = {};
|
|
188
|
-
|
|
189
|
-
Object.entries(colors).forEach(([, themeColors]) => {
|
|
190
|
-
Object.entries(themeColors).forEach(([colorKey, value]) => {
|
|
191
|
-
themeResultColors[colorKey] = {};
|
|
192
|
-
|
|
193
|
-
if (isPlainObject(value)) {
|
|
194
|
-
Object.entries(value).forEach(([key, colorValue]) => {
|
|
195
|
-
const numberKey = Number(key);
|
|
196
|
-
themeResultColors[colorKey][numberKey] =
|
|
197
|
-
this.keyTemplate.getColorsValue({
|
|
198
|
-
key,
|
|
199
|
-
parentKey: colorKey,
|
|
200
|
-
value: colorValue
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
// if value is string, it means it's a color value
|
|
205
|
-
else if (isString(value)) {
|
|
206
|
-
themeResultColors[colorKey] = this.keyTemplate.getColorsValue({
|
|
207
|
-
key: colorKey,
|
|
208
|
-
value
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
return themeResultColors;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function create(options) {
|
|
219
|
-
const generator = new Generator(options);
|
|
220
|
-
|
|
221
|
-
const baseStyles = generator.generateBaseStyles();
|
|
222
|
-
const themeColors = generator.generateThemeColors();
|
|
223
|
-
|
|
224
|
-
const result = {
|
|
225
|
-
baseStyles,
|
|
226
|
-
colors: themeColors
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
if (Object.keys(baseStyles).length > 0) {
|
|
230
|
-
result.plugin = plugin(({ addBase }) => {
|
|
231
|
-
addBase(baseStyles);
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export default create;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"welcome": "Welcome to the home page",
|
|
3
|
-
"description": "A modern frontend utility library collection providing various practical tools and components",
|
|
4
|
-
"about": "About Us",
|
|
5
|
-
"about_description": "Learn more about our project and team information",
|
|
6
|
-
"jsonstorage": "JSONStorage",
|
|
7
|
-
"jsonstorage_description": "Efficient JSON data storage solution",
|
|
8
|
-
"request": "Request",
|
|
9
|
-
"request_description": "A modern frontend utility library collection providing various practical tools and components"
|
|
10
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "JSONStorage Demo",
|
|
3
|
-
"title2": "Permanent storage test",
|
|
4
|
-
"title3": "Expire time test",
|
|
5
|
-
"title4": "Request Timeout",
|
|
6
|
-
"format.title": "Test key: ${key}, Random value range: ${min}~${max}",
|
|
7
|
-
"setRandomValue": "Set random value",
|
|
8
|
-
"currentValue": "Current value",
|
|
9
|
-
"ms": "ms",
|
|
10
|
-
"setExpireTime": "Set random value(with expire time)"
|
|
11
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"requestTimeout": "Request Timeout",
|
|
3
|
-
"helloResult": "Hello result is",
|
|
4
|
-
"helloError": "Hello error is",
|
|
5
|
-
"ipInfoResult": "IpInfo result is",
|
|
6
|
-
"ipInfo": "IpInfo",
|
|
7
|
-
"randomUser": "RandomUser",
|
|
8
|
-
"loading": "Loading...",
|
|
9
|
-
"randomUserResult": "RandomUser result is",
|
|
10
|
-
"randomUserError": "RandomUser error is",
|
|
11
|
-
"triggerAbortRequest": "Trigger Abort Request",
|
|
12
|
-
"stopAbortRequest": "Stop Abort Request",
|
|
13
|
-
"abortRequestResult": "Abort Request Result",
|
|
14
|
-
"abortRequestError": "Abort Request Error"
|
|
15
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"welcome": "欢迎来到主页",
|
|
3
|
-
"description": "一个现代前端实用库集合,提供各种实用工具和组件",
|
|
4
|
-
"about": "关于我们",
|
|
5
|
-
"about_description": "了解更多关于我们的项目和团队信息",
|
|
6
|
-
"jsonstorage": "JSON存储",
|
|
7
|
-
"jsonstorage_description": "高效的JSON数据存储解决方案",
|
|
8
|
-
"request": "请求",
|
|
9
|
-
"request_description": "一个现代前端实用库集合,提供各种实用工具和组件"
|
|
10
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "JSONStorage Demo",
|
|
3
|
-
"title2": "永久存储测试",
|
|
4
|
-
"title3": "过期时间测试",
|
|
5
|
-
"title4": "请求超时时间设置",
|
|
6
|
-
"format.title": "测试 key: ${key}, 随机值范围: ${min}~${max}",
|
|
7
|
-
"setRandomValue": "设置随机值",
|
|
8
|
-
"currentValue": "当前值",
|
|
9
|
-
"ms": "毫秒",
|
|
10
|
-
"setExpireTime": "设置随机值(带过期时间)"
|
|
11
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"requestTimeout": "请求超时",
|
|
3
|
-
"helloResult": "Hello 结果是",
|
|
4
|
-
"helloError": "Hello 错误是",
|
|
5
|
-
"ipInfoResult": "IpInfo 结果是",
|
|
6
|
-
"ipInfo": "IpInfo",
|
|
7
|
-
"randomUser": "随机用户",
|
|
8
|
-
"loading": "加载中...",
|
|
9
|
-
"randomUserResult": "随机用户 结果是",
|
|
10
|
-
"randomUserError": "随机用户 错误是",
|
|
11
|
-
"triggerAbortRequest": "触发中止请求",
|
|
12
|
-
"stopAbortRequest": "停止中止请求",
|
|
13
|
-
"abortRequestResult": "中止请求 结果是",
|
|
14
|
-
"abortRequestError": "中止请求 错误是"
|
|
15
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { RouteObject } from 'react-router-dom';
|
|
2
|
-
import isString from 'lodash/isString';
|
|
3
|
-
import type { ComponentType, LazyExoticComponent, ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
export type ComponentValue = Record<string, () => unknown>;
|
|
6
|
-
|
|
7
|
-
type RouteComponentType<T = unknown> =
|
|
8
|
-
| ComponentType<T>
|
|
9
|
-
| LazyExoticComponent<ComponentType<T>>;
|
|
10
|
-
|
|
11
|
-
export type RouteConfigValue = Omit<RouteObject, 'element' | 'children'> & {
|
|
12
|
-
/**
|
|
13
|
-
* 路径
|
|
14
|
-
*
|
|
15
|
-
* FIXME: support `ReactNode`
|
|
16
|
-
*/
|
|
17
|
-
element?: string;
|
|
18
|
-
children?: RouteConfigValue[];
|
|
19
|
-
meta?: Record<string, unknown>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type RouterLoaderRender = (
|
|
23
|
-
route: Omit<RouteConfigValue, 'element'> & {
|
|
24
|
-
element: () => RouteComponentType;
|
|
25
|
-
}
|
|
26
|
-
) => ReactNode;
|
|
27
|
-
|
|
28
|
-
export type RouterLoaderOptions = {
|
|
29
|
-
/**
|
|
30
|
-
* 路由配置
|
|
31
|
-
*/
|
|
32
|
-
routes?: RouteConfigValue[];
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 组件映射表
|
|
36
|
-
*/
|
|
37
|
-
componentMaps?: ComponentValue;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 渲染路由
|
|
41
|
-
*/
|
|
42
|
-
render: RouterLoaderRender;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export class RouterLoader {
|
|
46
|
-
constructor(private readonly options: RouterLoaderOptions) {
|
|
47
|
-
if (!options.render) {
|
|
48
|
-
throw new Error('RouterLoader render is required');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
getComponentMaps(): ComponentValue {
|
|
53
|
-
const { componentMaps = {} } = this.options;
|
|
54
|
-
|
|
55
|
-
return componentMaps;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getComponent(element: string): () => RouteComponentType {
|
|
59
|
-
const maps = this.getComponentMaps();
|
|
60
|
-
|
|
61
|
-
const component = maps[element];
|
|
62
|
-
|
|
63
|
-
if (!component) {
|
|
64
|
-
throw new Error(`Component not found: ${element}`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return component as () => RouteComponentType;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
toRoute(route: RouteConfigValue): RouteObject {
|
|
71
|
-
const { render } = this.options;
|
|
72
|
-
const { element, children, ...rest } = route;
|
|
73
|
-
|
|
74
|
-
if (!element || !isString(element)) {
|
|
75
|
-
console.warn(
|
|
76
|
-
`Invalid route, path is: ${route.path}, element is: ${element}`
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const componet = this.getComponent(element || '404');
|
|
81
|
-
const Element = render({ ...rest, element: componet });
|
|
82
|
-
|
|
83
|
-
// @ts-expect-error
|
|
84
|
-
return {
|
|
85
|
-
...rest,
|
|
86
|
-
element: Element,
|
|
87
|
-
children: children?.map((child) => this.toRoute(child))
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IOCRegisterInterface } from '@qlover/corekit-bridge';
|
|
2
|
-
import type { Container } from 'inversify';
|
|
3
|
-
|
|
4
|
-
export type InversifyRegisterContainer = Container;
|
|
5
|
-
/**
|
|
6
|
-
* Inversify register interface.
|
|
7
|
-
*/
|
|
8
|
-
export interface InversifyRegisterInterface
|
|
9
|
-
extends IOCRegisterInterface<InversifyRegisterContainer> {}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { EnvConfigInterface } from '@qlover/corekit-bridge';
|
|
2
|
-
|
|
3
|
-
export class AppConfigImpl implements EnvConfigInterface {
|
|
4
|
-
readonly appName = '';
|
|
5
|
-
readonly appVersion = '';
|
|
6
|
-
/**
|
|
7
|
-
* vite mode
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
readonly env: string = '';
|
|
11
|
-
|
|
12
|
-
readonly userTokenStorageKey = '';
|
|
13
|
-
readonly openAiModels = [
|
|
14
|
-
'gpt-4o-mini',
|
|
15
|
-
'gpt-3.5-turbo',
|
|
16
|
-
'gpt-3.5-turbo-2',
|
|
17
|
-
'gpt-4',
|
|
18
|
-
'gpt-4-32k'
|
|
19
|
-
];
|
|
20
|
-
readonly openAiBaseUrl = '';
|
|
21
|
-
readonly openAiToken = '';
|
|
22
|
-
readonly openAiTokenPrefix = '';
|
|
23
|
-
readonly openAiRequireToken = true;
|
|
24
|
-
readonly loginUser = '';
|
|
25
|
-
readonly loginPassword = '';
|
|
26
|
-
|
|
27
|
-
readonly feApiBaseUrl = '';
|
|
28
|
-
readonly userApiBaseUrl = '';
|
|
29
|
-
|
|
30
|
-
readonly aiApiBaseUrl = 'https://api.openai.com/v1';
|
|
31
|
-
readonly aiApiToken = '';
|
|
32
|
-
readonly aiApiTokenPrefix = 'Bearer';
|
|
33
|
-
readonly aiApiRequireToken = true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default new AppConfigImpl();
|
|
File without changes
|