@qlover/create-app 0.6.1 → 0.6.3

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/templates/react-app/README.en.md +257 -0
  5. package/dist/templates/react-app/README.md +29 -231
  6. package/dist/templates/react-app/config/IOCIdentifier.ts +13 -0
  7. package/dist/templates/react-app/docs/en/bootstrap.md +562 -0
  8. package/dist/templates/react-app/docs/en/development-guide.md +523 -0
  9. package/dist/templates/react-app/docs/en/env.md +482 -0
  10. package/dist/templates/react-app/docs/en/global.md +509 -0
  11. package/dist/templates/react-app/docs/en/i18n.md +268 -0
  12. package/dist/templates/react-app/docs/en/index.md +173 -0
  13. package/dist/templates/react-app/docs/en/ioc.md +424 -0
  14. package/dist/templates/react-app/docs/en/project-structure.md +434 -0
  15. package/dist/templates/react-app/docs/en/request.md +425 -0
  16. package/dist/templates/react-app/docs/en/router.md +404 -0
  17. package/dist/templates/react-app/docs/en/store.md +321 -0
  18. package/dist/templates/react-app/docs/en/theme.md +424 -0
  19. package/dist/templates/react-app/docs/en/typescript-guide.md +473 -0
  20. package/dist/templates/react-app/docs/zh/bootstrap.md +562 -0
  21. package/dist/templates/react-app/docs/zh/development-guide.md +523 -0
  22. package/dist/templates/react-app/docs/zh/env.md +479 -0
  23. package/dist/templates/react-app/docs/zh/global.md +511 -0
  24. package/dist/templates/react-app/docs/zh/i18n.md +268 -0
  25. package/dist/templates/react-app/docs/zh/index.md +173 -0
  26. package/dist/templates/react-app/docs/zh/ioc.md +422 -0
  27. package/dist/templates/react-app/docs/zh/project-structure.md +434 -0
  28. package/dist/templates/react-app/docs/zh/request.md +429 -0
  29. package/dist/templates/react-app/docs/zh/router.md +408 -0
  30. package/dist/templates/react-app/docs/zh/store.md +321 -0
  31. package/dist/templates/react-app/docs/zh/theme.md +424 -0
  32. package/dist/templates/react-app/docs/zh/typescript-guide.md +473 -0
  33. package/dist/templates/react-app/package.json +2 -2
  34. package/dist/templates/react-app/src/base/apis/AiApi.ts +10 -5
  35. package/dist/templates/react-app/src/base/apis/feApi/FeApiAdapter.ts +1 -1
  36. package/dist/templates/react-app/src/base/apis/feApi/FeApiBootstarp.ts +1 -1
  37. package/dist/templates/react-app/src/base/apis/userApi/UserApi.ts +10 -17
  38. package/dist/templates/react-app/src/base/apis/userApi/UserApiAdapter.ts +1 -1
  39. package/dist/templates/react-app/src/base/apis/userApi/UserApiBootstarp.ts +2 -1
  40. package/dist/templates/react-app/src/base/apis/userApi/UserApiType.ts +7 -5
  41. package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +3 -2
  42. package/dist/templates/react-app/src/base/cases/InversifyContainer.ts +33 -0
  43. package/dist/templates/react-app/src/base/cases/RequestLogger.ts +1 -1
  44. package/dist/templates/react-app/src/base/cases/RequestStatusCatcher.ts +2 -2
  45. package/dist/templates/react-app/src/base/services/ProcesserExecutor.ts +1 -1
  46. package/dist/templates/react-app/src/base/services/RouteService.ts +5 -2
  47. package/dist/templates/react-app/src/base/services/UserService.ts +8 -10
  48. package/dist/templates/react-app/src/core/IOC.ts +73 -83
  49. package/dist/templates/react-app/src/core/bootstraps/BootstrapApp.ts +52 -4
  50. package/dist/templates/react-app/src/core/bootstraps/{index.ts → BootstrapsRegistry.ts} +2 -3
  51. package/dist/templates/react-app/src/core/registers/IocRegisterImpl.ts +25 -0
  52. package/dist/templates/react-app/src/core/registers/RegisterCommon.ts +11 -17
  53. package/dist/templates/react-app/src/core/registers/RegisterControllers.ts +10 -4
  54. package/dist/templates/react-app/src/core/registers/RegisterGlobals.ts +6 -15
  55. package/dist/templates/react-app/src/main.tsx +2 -5
  56. package/dist/templates/react-app/src/styles/css/antd-themes/dark.css +3 -1
  57. package/dist/templates/react-app/src/styles/css/antd-themes/index.css +1 -1
  58. package/dist/templates/react-app/src/styles/css/antd-themes/pink.css +6 -1
  59. package/dist/templates/react-app/src/styles/css/page.css +1 -1
  60. package/dist/templates/react-app/src/uikit/controllers/JSONStorageController.ts +1 -1
  61. package/dist/templates/react-app/tsconfig.app.json +2 -1
  62. package/dist/templates/react-app/tsconfig.node.json +2 -1
  63. package/package.json +2 -2
  64. package/dist/templates/react-app/src/base/port/ApiTransactionInterface.ts +0 -7
  65. package/dist/templates/react-app/src/base/port/RequestCatcherInterface.ts +0 -12
  66. package/dist/templates/react-app/src/core/bootstrap.ts +0 -58
  67. package/dist/templates/react-app/src/core/registers/RegisterApi.ts +0 -5
  68. package/dist/templates/react-app/src/core/registers/index.ts +0 -32
@@ -0,0 +1,268 @@
1
+ # Internationalization System
2
+
3
+ ## Overview
4
+
5
+ The internationalization system adopts an identifier-alias based approach, combining i18next and TypeScript comments to implement a type-safe, maintainable internationalization solution. Main features:
6
+
7
+ - **Identifier Aliases**: Use constants instead of strings as translation keys
8
+ - **TypeScript Comments**: Automatically generate translation resources through comments
9
+ - **Type Safety**: Complete type checking and auto-completion
10
+ - **Router Integration**: Support language parameters in URL paths
11
+ - **Auto Generation**: Automatically generate translation files from source code
12
+ - **Developer Friendly**: Complete development tool support
13
+
14
+ ## Core Concepts
15
+
16
+ ### 1. Identifier Aliases
17
+
18
+ Use constants instead of string keys to provide better type safety and maintainability:
19
+
20
+ ```typescript
21
+ // config/Identifier/common.ts
22
+
23
+ /**
24
+ * @description Theme switcher default theme label
25
+ * @localZh 默认主题
26
+ * @localEn Default Theme
27
+ */
28
+ export const HEADER_THEME_DEFAULT = 'header.theme.default';
29
+
30
+ /**
31
+ * @description Theme switcher dark theme label
32
+ * @localZh 暗色主题
33
+ * @localEn Dark Theme
34
+ */
35
+ export const HEADER_THEME_DARK = 'header.theme.dark';
36
+ ```
37
+
38
+ ### 2. Auto Generation Configuration
39
+
40
+ Configure auto generation in `vite.config.ts`:
41
+
42
+ ```typescript
43
+ import ts2Locales from '@brain-toolkit/ts2locales/vite';
44
+
45
+ export default defineConfig({
46
+ plugins: [
47
+ ts2Locales({
48
+ locales: ['en', 'zh'],
49
+ options: [
50
+ {
51
+ source: './config/Identifier/common.ts',
52
+ target: './public/locales/{{lng}}/common.json'
53
+ },
54
+ {
55
+ source: './config/Identifier/error.ts',
56
+ target: './public/locales/{{lng}}/common.json'
57
+ }
58
+ ]
59
+ })
60
+ ]
61
+ });
62
+ ```
63
+
64
+ ### 3. i18n Service Configuration
65
+
66
+ ```typescript
67
+ // config/i18n.ts
68
+ export default {
69
+ fallbackLng: 'en',
70
+ debug: false,
71
+ interpolation: {
72
+ escapeValue: false
73
+ },
74
+ ns: ['common'],
75
+ defaultNS: 'common',
76
+ backend: {
77
+ loadPath: '/locales/{{lng}}/{{ns}}.json'
78
+ },
79
+ supportedLngs: ['en', 'zh']
80
+ } as const;
81
+ ```
82
+
83
+ ## Usage
84
+
85
+ ### 1. Define Translation Keys
86
+
87
+ ```typescript
88
+ // config/Identifier/page.ts
89
+
90
+ /**
91
+ * @description Home page title
92
+ * @localZh 首页
93
+ * @localEn Home
94
+ */
95
+ export const PAGE_HOME_TITLE = 'page.home.title';
96
+
97
+ /**
98
+ * @description Home page welcome message
99
+ * @localZh 欢迎来到我们的应用
100
+ * @localEn Welcome to our application
101
+ */
102
+ export const PAGE_HOME_WELCOME = 'page.home.welcome';
103
+ ```
104
+
105
+ ### 2. Using in Components
106
+
107
+ ```tsx
108
+ import { useTranslation } from 'react-i18next';
109
+ import * as i18nKeys from '@config/Identifier/page';
110
+
111
+ function HomePage() {
112
+ const { t } = useTranslation();
113
+
114
+ return (
115
+ <div>
116
+ <h1>{t(i18nKeys.PAGE_HOME_TITLE)}</h1>
117
+ <p>{t(i18nKeys.PAGE_HOME_WELCOME)}</p>
118
+ </div>
119
+ );
120
+ }
121
+ ```
122
+
123
+ ### 3. Translations with Parameters
124
+
125
+ ```typescript
126
+ /**
127
+ * @description Welcome user message
128
+ * @localZh 欢迎,{{name}}!
129
+ * @localEn Welcome, {{name}}!
130
+ */
131
+ export const USER_WELCOME = 'user.welcome';
132
+
133
+ function Welcome({ username }: { username: string }) {
134
+ const { t } = useTranslation();
135
+ return <h1>{t(i18nKeys.USER_WELCOME, { name: username })}</h1>;
136
+ }
137
+ ```
138
+
139
+ ### 4. Language Switching
140
+
141
+ ```tsx
142
+ import { IOC } from '@/core/IOC';
143
+ import { I18nService } from '@/base/services/I18nService';
144
+
145
+ function LanguageSwitcher() {
146
+ const i18nService = IOC(I18nService);
147
+ const currentLang = i18nService.getCurrentLanguage();
148
+
149
+ const handleChange = (lang: string) => {
150
+ i18nService.changeLanguage(lang);
151
+ };
152
+
153
+ return (
154
+ <select value={currentLang} onChange={(e) => handleChange(e.target.value)}>
155
+ <option value="zh">中文</option>
156
+ <option value="en">English</option>
157
+ </select>
158
+ );
159
+ }
160
+ ```
161
+
162
+ ## Best Practices
163
+
164
+ ### 1. Identifier Organization
165
+
166
+ - **Naming Conventions**:
167
+
168
+ ```typescript
169
+ // Page related
170
+ PAGE_HOME_TITLE;
171
+ PAGE_ABOUT_DESCRIPTION;
172
+
173
+ // Feature module related
174
+ AUTH_LOGIN_BUTTON;
175
+ AUTH_LOGOUT_CONFIRM;
176
+
177
+ // Common component related
178
+ COMMON_SUBMIT_BUTTON;
179
+ COMMON_CANCEL_BUTTON;
180
+ ```
181
+
182
+ - **File Organization**:
183
+ ```
184
+ config/
185
+ ├── Identifier/
186
+ │ ├── common.ts // Common text
187
+ │ ├── page.ts // Page text
188
+ │ ├── error.ts // Error messages
189
+ │ └── auth.ts // Authentication related
190
+ ```
191
+
192
+ ### 2. Comment Standards
193
+
194
+ ```typescript
195
+ /**
196
+ * @description Brief description explaining text usage
197
+ * @localZh Chinese translation text
198
+ * @localEn English translation text
199
+ */
200
+ ```
201
+
202
+ ### 3. Type Safety
203
+
204
+ ```typescript
205
+ // Use type imports to ensure key existence
206
+ import * as i18nKeys from '@config/Identifier';
207
+
208
+ // Type checking catches incorrect keys
209
+ t(i18nKeys.NONEXISTENT_KEY); // TS error
210
+ ```
211
+
212
+ ### 4. Dynamic Content
213
+
214
+ ```typescript
215
+ /**
216
+ * @description File upload progress
217
+ * @localZh 已上传 {{count}} 个文件,共 {{total}} 个
218
+ * @localEn Uploaded {{count}} files out of {{total}}
219
+ */
220
+ export const UPLOAD_PROGRESS = 'upload.progress';
221
+
222
+ // Usage
223
+ t(i18nKeys.UPLOAD_PROGRESS, { count: 3, total: 10 });
224
+ ```
225
+
226
+ ## Workflow
227
+
228
+ 1. **Development Phase**:
229
+ - Define translation keys and comments in Identifier files
230
+ - Reference translations using identifier aliases in code
231
+ - Automatically generate translation files during development server runtime
232
+
233
+ 2. **Build Phase**:
234
+ - Automatically check translation completeness
235
+ - Generate production translation files
236
+ - Optimize translation resource loading
237
+
238
+ 3. **Runtime**:
239
+ - Detect language based on URL
240
+ - Load translation resources on demand
241
+ - Respond to language switch events
242
+
243
+ ## Common Issues
244
+
245
+ ### 1. Translations Not Working
246
+
247
+ Check the following:
248
+
249
+ - Ensure identifiers are correctly exported
250
+ - Check if comment format is correct
251
+ - Verify translation files are generated
252
+ - Confirm language detection is working
253
+
254
+ ### 2. Type Errors
255
+
256
+ Possible solutions:
257
+
258
+ - Check identifier import paths
259
+ - Ensure correct identifier usage
260
+ - Update TypeScript type definitions
261
+
262
+ ### 3. Performance Optimization
263
+
264
+ Development suggestions:
265
+
266
+ - Reasonably split translation files
267
+ - Use translation resource preloading
268
+ - Avoid duplicate translation keys
@@ -0,0 +1,173 @@
1
+ # React Application Development Documentation
2
+
3
+ ## Introduction
4
+
5
+ This is a modern frontend application template based on React 18, integrating a complete development framework and toolchain. This template provides a comprehensive development solution, including state management, routing management, internationalization, theme system, and other core functionalities.
6
+
7
+ ### Key Features
8
+
9
+ - 🚀 **Modern Technology Stack**: Based on React 18, TypeScript, Vite
10
+ - 🎨 **Theme Customization**: Supports dynamic theme switching, dark mode
11
+ - 🌍 **Internationalization**: Built-in multi-language support
12
+ - 📦 **State Management**: Reactive state management based on publish-subscribe pattern
13
+ - 🔑 **Authentication System**: Complete user authentication solution
14
+ - 🛠️ **Development Tools**: ESLint, Prettier, TypeScript
15
+ - 📱 **Responsive Design**: Supports multi-platform adaptation
16
+ - 🧪 **Testing Support**: Integrated unit testing and component testing
17
+
18
+ ## Quick Start
19
+
20
+ ```bash
21
+ # Install dependencies
22
+ npm install
23
+
24
+ # Start development server
25
+ npm run dev
26
+
27
+ # Build production version
28
+ npm run build
29
+ ```
30
+
31
+ ## Documentation Navigation
32
+
33
+ ### Architecture Guide
34
+
35
+ - [Project Structure](./project-structure.md)
36
+ - [Development Guidelines](./development-guide.md)
37
+ - [Build and Deployment Guide](./deployment.md)
38
+
39
+ ### Core Features
40
+
41
+ - [Router Development Guide](./router.md)
42
+ - [State Management Guide](./store.md)
43
+ - [Internationalization Guide](./i18n.md)
44
+ - [Theme Development Guide](./theme.md)
45
+ - [Request System Guide](./request.md)
46
+
47
+ ### Component Development
48
+
49
+ - [Component Development Guide](./component-guide.md)
50
+ - [TypeScript Development Standards](./typescript-guide.md)
51
+ - [Styling Guide](./styling-guide.md)
52
+
53
+ ### Tools and Testing
54
+
55
+ - [Testing Development Guide](./testing.md)
56
+ - [Git Workflow Guide](./git-workflow.md)
57
+ - [Performance Optimization Guide](./performance.md)
58
+
59
+ ### Security and Best Practices
60
+
61
+ - [Security Development Guide](./security.md)
62
+ - [Documentation Writing Guide](./documentation.md)
63
+
64
+ ## Directory Structure
65
+
66
+ ```
67
+ docs/en/
68
+ ├── index.md # This document
69
+ ├── project-structure.md # Project structure explanation
70
+ ├── development-guide.md # Development guidelines
71
+ ├── router.md # Router development guide
72
+ ├── store.md # State management guide
73
+ ├── i18n.md # Internationalization guide
74
+ ├── theme.md # Theme development guide
75
+ └── ...
76
+ ```
77
+
78
+ ## Core Concepts
79
+
80
+ ### 1. Startup Process
81
+
82
+ The application uses a plugin-based startup process:
83
+
84
+ ```
85
+ Bootstrap Initialization → Load Plugins → Initialize Services → Render Application
86
+ ```
87
+
88
+ ### 2. State Management
89
+
90
+ Reactive state management based on publish-subscribe pattern:
91
+
92
+ ```
93
+ Action Trigger → Store Update → Component Re-render
94
+ ```
95
+
96
+ ### 3. Routing System
97
+
98
+ Configuration-based route management:
99
+
100
+ ```
101
+ Route Configuration → Auto-generate Routes → Code Splitting → Lazy Loading
102
+ ```
103
+
104
+ ### 4. Internationalization
105
+
106
+ Automatic internationalization based on TypeScript comments:
107
+
108
+ ```
109
+ Comment Definition → Auto-generate Resources → Dynamic Loading → Language Switching
110
+ ```
111
+
112
+ ## Development Process
113
+
114
+ 1. **Requirement Analysis**
115
+ - Understand business requirements
116
+ - Design technical solutions
117
+ - Evaluate development cycle
118
+
119
+ 2. **Development Phase**
120
+ - Follow development standards
121
+ - Write unit tests
122
+ - Conduct code reviews
123
+
124
+ 3. **Testing Phase**
125
+ - Unit testing
126
+ - Integration testing
127
+ - Performance testing
128
+
129
+ 4. **Deployment**
130
+ - Build optimization
131
+ - Deployment configuration
132
+ - Monitoring and alerts
133
+
134
+ ## Common Issues
135
+
136
+ ### 1. Development Environment Setup
137
+
138
+ - Ensure Node.js version >= 16
139
+ - Use recommended IDE configuration
140
+ - Install necessary development tools
141
+
142
+ ### 2. Build Related
143
+
144
+ - Common build error solutions
145
+ - Performance optimization suggestions
146
+ - Deployment considerations
147
+
148
+ ### 3. Development Related
149
+
150
+ - Code standard issues
151
+ - Type system usage
152
+ - Component development standards
153
+
154
+ ## Contribution Guide
155
+
156
+ 1. Fork the project
157
+ 2. Create feature branch
158
+ 3. Submit changes
159
+ 4. Create Pull Request
160
+
161
+ ## Changelog
162
+
163
+ See [CHANGELOG.md](../../CHANGELOG.md) for detailed update history.
164
+
165
+ ## Support and Help
166
+
167
+ - Submit Issues
168
+ - Check Wiki
169
+ - Participate in discussions
170
+
171
+ ## License
172
+
173
+ This project is open-sourced under the [ISC License](../../LICENSE).