@robsun/create-keystone-app 0.2.11 → 0.2.12

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/package.json CHANGED
@@ -1,23 +1,23 @@
1
- {
2
- "name": "@robsun/create-keystone-app",
3
- "version": "0.2.11",
4
- "scripts": {
5
- "build": "node scripts/build.js",
6
- "prepublishOnly": "node scripts/build.js && node scripts/prune-template-deps.js"
7
- },
8
- "publishConfig": {
9
- "access": "public"
10
- },
11
- "bin": {
12
- "create-keystone-app": "dist/create-keystone-app.js",
13
- "create-keystone-module": "dist/create-module.js"
14
- },
15
- "files": [
16
- "dist",
17
- "template",
18
- "README.md"
19
- ],
20
- "engines": {
21
- "node": ">=18"
22
- }
23
- }
1
+ {
2
+ "name": "@robsun/create-keystone-app",
3
+ "version": "0.2.12",
4
+ "scripts": {
5
+ "build": "node scripts/build.js",
6
+ "prepublishOnly": "node scripts/build.js && node scripts/prune-template-deps.js"
7
+ },
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "bin": {
12
+ "create-keystone-app": "dist/create-keystone-app.js",
13
+ "create-keystone-module": "dist/create-module.js"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "template",
18
+ "README.md"
19
+ ],
20
+ "engines": {
21
+ "node": ">=18"
22
+ }
23
+ }
@@ -1,206 +1,206 @@
1
- # Keystone 包完整能力清单
2
-
3
- ## 一、前端组件 (@robsun/keystone-web-core)
4
-
5
- ### 1. 应用与路由
6
- ```typescript
7
- import { KeystoneApp, createKeystoneRouter } from '@robsun/keystone-web-core'
8
- import { registerModule, registerRoutes, registerMenus, registerPermissions } from '@robsun/keystone-web-core'
9
- ```
10
-
11
- ### 2. 高级 UI 组件
12
- ```typescript
13
- // 高级表格 - 过滤、分页、行选择、导出
14
- import { ProTable } from '@robsun/keystone-web-core'
15
-
16
- // 智能表单 - 自动验证、加载状态
17
- import { ProForm } from '@robsun/keystone-web-core'
18
-
19
- // 文件上传 - 拖拽、预览、多文件
20
- import { FileUpload } from '@robsun/keystone-web-core'
21
-
22
- // 数据导入向导
23
- import { DataImporter, ImportWizard, ColumnMapper, ValidationResult } from '@robsun/keystone-web-core'
24
-
25
- // 数据导出向导
26
- import { DataExporter, ExportWizard } from '@robsun/keystone-web-core'
27
-
28
- // 权限守卫
29
- import { PermissionGuard } from '@robsun/keystone-web-core'
30
- ```
31
-
32
- ### 3. 审批流系统
33
- ```typescript
34
- import {
35
- ApprovalFlowEditor, // 流程编辑器
36
- ApprovalFlowCanvas, // 可视化画布
37
- ApprovalNodeEditor, // 节点编辑
38
- ConditionEditor, // 条件编辑
39
- ApprovalStatus, // 状态展示
40
- ApprovalAction, // 审批按钮
41
- ApprovalHistory // 审批历史
42
- } from '@robsun/keystone-web-core'
43
- ```
44
- 审批流程与接入说明见 [approval.md](approval.md)。
45
-
46
- ### 4. 帮助系统
47
- ```typescript
48
- import {
49
- HelpButton, HelpDrawer, HelpSearch, HelpContent,
50
- useCurrentHelpKey, useHelpSearch
51
- } from '@robsun/keystone-web-core'
52
- ```
53
-
54
- ### 5. 布局与主题
55
- ```typescript
56
- import { MainLayout, antdTheme, useLayoutStore } from '@robsun/keystone-web-core'
57
- ```
58
-
59
- ### 6. 认证授权
60
- ```typescript
61
- import { useAuthStore, useAuth, matchesPermission } from '@robsun/keystone-web-core'
62
- ```
63
-
64
- ### 7. 运行时服务
65
- ```typescript
66
- import { api, setApiBaseUrl } from '@robsun/keystone-web-core'
67
- import { createExportJob, createImportJob } from '@robsun/keystone-web-core'
68
- import { listNotifications, markNotificationRead, fetchUnreadCount } from '@robsun/keystone-web-core'
69
- import { getJob, listJobs } from '@robsun/keystone-web-core'
70
- ```
71
-
72
- ### 8. 多语言 (i18n)
73
- ```typescript
74
- // 翻译 Hook
75
- import { useTranslation } from 'react-i18next'
76
-
77
- // 使用示例
78
- const { t } = useTranslation()
79
- const title = t('module:key') // 命名空间:键
80
- const description = t('common:actions.save')
81
-
82
- // 平台多语言配置
83
- import { getKeystoneConfig } from '@robsun/keystone-web-core'
84
- const locale = getKeystoneConfig().ui?.i18n?.defaultLocale // 'zh-CN' | 'en-US'
85
-
86
- // dayjs 本地化同步(自动完成)
87
- import dayjs from 'dayjs'
88
- dayjs.locale(getKeystoneConfig().ui?.locale?.dayjs ?? 'zh-cn')
89
- ```
90
-
91
- **翻译文件组织**:
92
- ```
93
- src/modules/{module}/locales/
94
- ├── zh-CN/
95
- │ └── {namespace}.json
96
- └── en-US/
97
- └── {namespace}.json
98
- ```
99
-
100
- **命名空间约定**:
101
- - `common` - 通用文案(按钮、操作、状态等)
102
- - `auth` - 认证相关
103
- - `system` - 系统管理
104
- - `{module}` - 业务模块专属翻译
105
-
106
- ### 9. Hooks
107
- ```typescript
108
- import { useListState } from '@robsun/keystone-web-core'
109
- ```
110
-
111
- ### 10. 类型
112
- ```typescript
113
- import type { ApiResponse, PaginatedData, PaginatedResponse } from '@robsun/keystone-web-core'
114
- import type { Permission, ModuleName, Action } from '@robsun/keystone-web-core'
115
- ```
116
-
117
- ## 二、后端能力 (Go)
118
-
119
- ### 1. 模块系统
120
- ```go
121
- type Module interface {
122
- Name() string
123
- RegisterRoutes(r *gin.RouterGroup)
124
- RegisterPermissions() []Permission
125
- Migrate(db *gorm.DB) error
126
- Seed(db *gorm.DB) error
127
- }
128
- ```
129
-
130
- ### 2. 审批引擎
131
- ```go
132
- approvalService.CreateInstance(...)
133
- approvalService.Approve(...)
134
- approvalService.Reject(...)
135
- approvalService.Cancel(...)
136
- ```
137
-
138
- ### 3. Job 队列
139
- ```go
140
- jobService.CreateJob(...)
141
- jobService.GetJob(...)
142
- jobService.ListJobs(...)
143
- ```
144
-
145
- ### 4. 通知服务
146
- ```go
147
- notificationService.SendNotification(...)
148
- notificationService.ListNotifications(...)
149
- notificationService.MarkRead(...)
150
- ```
151
-
152
- ### 5. 权限中间件
153
- ```go
154
- middleware.RequirePermission("module:resource:action")
155
- ```
156
-
157
- ### 6. 存储服务
158
- ```go
159
- storageService.Upload(...)
160
- storageService.Download(...)
161
- storageService.Delete(...)
162
- ```
163
-
164
- ### 7. 多语言 (i18n)
165
- ```go
166
- // 获取当前请求语言环境
167
- import "github.com/robsuncn/keystone/infra/i18n"
168
-
169
- locale := i18n.GetLocale(c) // 从请求头或参数获取
170
-
171
- // 翻译函数
172
- i18n.T(c, "module.key") // 基础翻译
173
- i18n.T(c, "module.greeting", "name", "张三") // 带变量
174
- i18n.Tf(c, "module.count", count) // 复数形式
175
-
176
- // 错误消息翻译
177
- return errors.New(i18n.T(c, "module.errors.notFound"))
178
- ```
179
-
180
- **翻译文件组织**:
181
- ```
182
- internal/modules/{module}/i18n/
183
- ├── i18n.go # 初始化
184
- ├── keys.go # 翻译键常量
185
- └── locales/
186
- ├── zh-CN.json
187
- └── en-US.json
188
- ```
189
-
190
- **翻译键常量定义**:
191
- ```go
192
- package i18n
193
-
194
- const (
195
- KeyItemCreated = "example.item.created"
196
- KeyItemNotFound = "example.item.notFound"
197
- KeyItemInvalid = "example.item.invalid"
198
- )
199
- ```
200
-
201
- **模块初始化**:
202
- ```go
203
- func init() {
204
- i18n.MustLoadModuleTranslations("example", Translations)
205
- }
206
- ```
1
+ # Keystone 包完整能力清单
2
+
3
+ ## 一、前端组件 (@robsun/keystone-web-core)
4
+
5
+ ### 1. 应用与路由
6
+ ```typescript
7
+ import { KeystoneApp, createKeystoneRouter } from '@robsun/keystone-web-core'
8
+ import { registerModule, registerRoutes, registerMenus, registerPermissions } from '@robsun/keystone-web-core'
9
+ ```
10
+
11
+ ### 2. 高级 UI 组件
12
+ ```typescript
13
+ // 高级表格 - 过滤、分页、行选择、导出
14
+ import { ProTable } from '@robsun/keystone-web-core'
15
+
16
+ // 智能表单 - 自动验证、加载状态
17
+ import { ProForm } from '@robsun/keystone-web-core'
18
+
19
+ // 文件上传 - 拖拽、预览、多文件
20
+ import { FileUpload } from '@robsun/keystone-web-core'
21
+
22
+ // 数据导入向导
23
+ import { DataImporter, ImportWizard, ColumnMapper, ValidationResult } from '@robsun/keystone-web-core'
24
+
25
+ // 数据导出向导
26
+ import { DataExporter, ExportWizard } from '@robsun/keystone-web-core'
27
+
28
+ // 权限守卫
29
+ import { PermissionGuard } from '@robsun/keystone-web-core'
30
+ ```
31
+
32
+ ### 3. 审批流系统
33
+ ```typescript
34
+ import {
35
+ ApprovalFlowEditor, // 流程编辑器
36
+ ApprovalFlowCanvas, // 可视化画布
37
+ ApprovalNodeEditor, // 节点编辑
38
+ ConditionEditor, // 条件编辑
39
+ ApprovalStatus, // 状态展示
40
+ ApprovalAction, // 审批按钮
41
+ ApprovalHistory // 审批历史
42
+ } from '@robsun/keystone-web-core'
43
+ ```
44
+ 审批流程与接入说明见 [approval.md](approval.md)。
45
+
46
+ ### 4. 帮助系统
47
+ ```typescript
48
+ import {
49
+ HelpButton, HelpDrawer, HelpSearch, HelpContent,
50
+ useCurrentHelpKey, useHelpSearch
51
+ } from '@robsun/keystone-web-core'
52
+ ```
53
+
54
+ ### 5. 布局与主题
55
+ ```typescript
56
+ import { MainLayout, antdTheme, useLayoutStore } from '@robsun/keystone-web-core'
57
+ ```
58
+
59
+ ### 6. 认证授权
60
+ ```typescript
61
+ import { useAuthStore, useAuth, matchesPermission } from '@robsun/keystone-web-core'
62
+ ```
63
+
64
+ ### 7. 运行时服务
65
+ ```typescript
66
+ import { api, setApiBaseUrl } from '@robsun/keystone-web-core'
67
+ import { createExportJob, createImportJob } from '@robsun/keystone-web-core'
68
+ import { listNotifications, markNotificationRead, fetchUnreadCount } from '@robsun/keystone-web-core'
69
+ import { getJob, listJobs } from '@robsun/keystone-web-core'
70
+ ```
71
+
72
+ ### 8. 多语言 (i18n)
73
+ ```typescript
74
+ // 翻译 Hook
75
+ import { useTranslation } from 'react-i18next'
76
+
77
+ // 使用示例
78
+ const { t } = useTranslation()
79
+ const title = t('module:key') // 命名空间:键
80
+ const description = t('common:actions.save')
81
+
82
+ // 平台多语言配置
83
+ import { getKeystoneConfig } from '@robsun/keystone-web-core'
84
+ const locale = getKeystoneConfig().ui?.i18n?.defaultLocale // 'zh-CN' | 'en-US'
85
+
86
+ // dayjs 本地化同步(自动完成)
87
+ import dayjs from 'dayjs'
88
+ dayjs.locale(getKeystoneConfig().ui?.locale?.dayjs ?? 'zh-cn')
89
+ ```
90
+
91
+ **翻译文件组织**:
92
+ ```
93
+ src/modules/{module}/locales/
94
+ ├── zh-CN/
95
+ │ └── {namespace}.json
96
+ └── en-US/
97
+ └── {namespace}.json
98
+ ```
99
+
100
+ **命名空间约定**:
101
+ - `common` - 通用文案(按钮、操作、状态等)
102
+ - `auth` - 认证相关
103
+ - `system` - 系统管理
104
+ - `{module}` - 业务模块专属翻译
105
+
106
+ ### 9. Hooks
107
+ ```typescript
108
+ import { useListState } from '@robsun/keystone-web-core'
109
+ ```
110
+
111
+ ### 10. 类型
112
+ ```typescript
113
+ import type { ApiResponse, PaginatedData, PaginatedResponse } from '@robsun/keystone-web-core'
114
+ import type { Permission, ModuleName, Action } from '@robsun/keystone-web-core'
115
+ ```
116
+
117
+ ## 二、后端能力 (Go)
118
+
119
+ ### 1. 模块系统
120
+ ```go
121
+ type Module interface {
122
+ Name() string
123
+ RegisterRoutes(r *gin.RouterGroup)
124
+ RegisterPermissions() []Permission
125
+ Migrate(db *gorm.DB) error
126
+ Seed(db *gorm.DB) error
127
+ }
128
+ ```
129
+
130
+ ### 2. 审批引擎
131
+ ```go
132
+ approvalService.CreateInstance(...)
133
+ approvalService.Approve(...)
134
+ approvalService.Reject(...)
135
+ approvalService.Cancel(...)
136
+ ```
137
+
138
+ ### 3. Job 队列
139
+ ```go
140
+ jobService.CreateJob(...)
141
+ jobService.GetJob(...)
142
+ jobService.ListJobs(...)
143
+ ```
144
+
145
+ ### 4. 通知服务
146
+ ```go
147
+ notificationService.SendNotification(...)
148
+ notificationService.ListNotifications(...)
149
+ notificationService.MarkRead(...)
150
+ ```
151
+
152
+ ### 5. 权限中间件
153
+ ```go
154
+ middleware.RequirePermission("module:resource:action")
155
+ ```
156
+
157
+ ### 6. 存储服务
158
+ ```go
159
+ storageService.Upload(...)
160
+ storageService.Download(...)
161
+ storageService.Delete(...)
162
+ ```
163
+
164
+ ### 7. 多语言 (i18n)
165
+ ```go
166
+ // 获取当前请求语言环境
167
+ import "github.com/robsuncn/keystone/infra/i18n"
168
+
169
+ locale := i18n.GetLocale(c) // 从请求头或参数获取
170
+
171
+ // 翻译函数
172
+ i18n.T(c, "module.key") // 基础翻译
173
+ i18n.T(c, "module.greeting", "name", "张三") // 带变量
174
+ i18n.Tf(c, "module.count", count) // 复数形式
175
+
176
+ // 错误消息翻译
177
+ return errors.New(i18n.T(c, "module.errors.notFound"))
178
+ ```
179
+
180
+ **翻译文件组织**:
181
+ ```
182
+ internal/modules/{module}/i18n/
183
+ ├── i18n.go # 初始化
184
+ ├── keys.go # 翻译键常量
185
+ └── locales/
186
+ ├── zh-CN.json
187
+ └── en-US.json
188
+ ```
189
+
190
+ **翻译键常量定义**:
191
+ ```go
192
+ package i18n
193
+
194
+ const (
195
+ KeyItemCreated = "example.item.created"
196
+ KeyItemNotFound = "example.item.notFound"
197
+ KeyItemInvalid = "example.item.invalid"
198
+ )
199
+ ```
200
+
201
+ **模块初始化**:
202
+ ```go
203
+ func init() {
204
+ i18n.MustLoadModuleTranslations("example", Translations)
205
+ }
206
+ ```