m8-mcp-server 1.0.4 → 1.0.5

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 (74) hide show
  1. package/README.md +184 -14
  2. package/dist/generator/vue-template.d.ts +21 -0
  3. package/dist/generator/vue-template.d.ts.map +1 -1
  4. package/dist/generator/vue-template.js +497 -33
  5. package/dist/generator/vue-template.js.map +1 -1
  6. package/package.json +2 -1
  7. package/resources/components/actionsheet.json +199 -0
  8. package/resources/components/amap.json +66 -0
  9. package/resources/components/area.json +158 -0
  10. package/resources/components/badge.json +93 -0
  11. package/resources/components/button.json +260 -74
  12. package/resources/components/calendar.json +225 -0
  13. package/resources/components/cascader.json +115 -0
  14. package/resources/components/cell.json +85 -69
  15. package/resources/components/chart.json +55 -0
  16. package/resources/components/checkbox.json +158 -0
  17. package/resources/components/circle.json +138 -0
  18. package/resources/components/collapse.json +88 -0
  19. package/resources/components/countdown.json +105 -0
  20. package/resources/components/datepicker.json +216 -0
  21. package/resources/components/dialog.json +250 -0
  22. package/resources/components/divider.json +82 -0
  23. package/resources/components/dragsort.json +67 -0
  24. package/resources/components/dropdownmenu.json +129 -0
  25. package/resources/components/easycalendar.json +84 -0
  26. package/resources/components/empty.json +90 -0
  27. package/resources/components/field.json +423 -88
  28. package/resources/components/form.json +156 -0
  29. package/resources/components/grid.json +131 -0
  30. package/resources/components/header.json +147 -0
  31. package/resources/components/icon.json +104 -0
  32. package/resources/components/image.json +169 -0
  33. package/resources/components/imagepreview.json +150 -0
  34. package/resources/components/imagescale.json +245 -0
  35. package/resources/components/indexbar.json +83 -0
  36. package/resources/components/layout.json +74 -0
  37. package/resources/components/lazyload.json +46 -0
  38. package/resources/components/loading.json +103 -0
  39. package/resources/components/minirefresh.json +341 -0
  40. package/resources/components/noticebar.json +148 -0
  41. package/resources/components/notify.json +60 -0
  42. package/resources/components/numberkeyboard.json +216 -0
  43. package/resources/components/overlay.json +78 -0
  44. package/resources/components/pagination.json +137 -0
  45. package/resources/components/panel.json +87 -0
  46. package/resources/components/passwordinput.json +103 -0
  47. package/resources/components/picker.json +195 -0
  48. package/resources/components/popover.json +161 -0
  49. package/resources/components/popup.json +229 -0
  50. package/resources/components/progress.json +111 -0
  51. package/resources/components/qrcode.json +128 -0
  52. package/resources/components/radio.json +139 -0
  53. package/resources/components/rate.json +157 -0
  54. package/resources/components/rtc.json +35 -0
  55. package/resources/components/search.json +234 -0
  56. package/resources/components/selectperson.json +175 -0
  57. package/resources/components/sidebar.json +74 -0
  58. package/resources/components/skeleton.json +110 -0
  59. package/resources/components/slider.json +159 -0
  60. package/resources/components/stepper.json +241 -0
  61. package/resources/components/steps.json +108 -0
  62. package/resources/components/sticky.json +72 -0
  63. package/resources/components/swipe.json +146 -0
  64. package/resources/components/swipecell.json +118 -0
  65. package/resources/components/switch.json +123 -0
  66. package/resources/components/switchcell.json +123 -0
  67. package/resources/components/tab.json +257 -0
  68. package/resources/components/tabbar.json +137 -0
  69. package/resources/components/table.json +149 -0
  70. package/resources/components/tag.json +149 -0
  71. package/resources/components/toast.json +70 -0
  72. package/resources/components/treeselect.json +106 -0
  73. package/resources/components/uploader.json +283 -0
  74. package/resources/components/verifycode.json +94 -0
package/README.md CHANGED
@@ -58,11 +58,13 @@ npx m8-mcp-server
58
58
  搜索 M8 框架文档。
59
59
 
60
60
  **参数:**
61
+
61
62
  - `query` (必需): 搜索关键词
62
63
  - `category` (可选): 文档分类 (`ejs-api`, `ui-component`, `util-tool`, `typical-case`, `standard`)
63
64
  - `limit` (可选): 最大返回数量,默认 10
64
65
 
65
66
  **示例:**
67
+
66
68
  ```
67
69
  搜索 "button" 相关文档
68
70
  搜索 UI 组件中的 "输入框"
@@ -73,9 +75,11 @@ npx m8-mcp-server
73
75
  获取 UI 组件的详细信息。
74
76
 
75
77
  **参数:**
78
+
76
79
  - `componentName` (必需): 组件名称,如 `em-button`, `button`, `em-field`, `field`
77
80
 
78
81
  **示例:**
82
+
79
83
  ```
80
84
  获取 button 组件信息
81
85
  获取 em-field 组件的 Props 和 Events
@@ -86,10 +90,12 @@ npx m8-mcp-server
86
90
  获取 EJS 原生 API 的详细信息。
87
91
 
88
92
  **参数:**
93
+
89
94
  - `module` (必需): API 模块名称 (`ui`, `page`, `storage`, `device`)
90
95
  - `method` (可选): API 方法名称
91
96
 
92
97
  **示例:**
98
+
93
99
  ```
94
100
  获取 ejs.ui 模块的所有方法
95
101
  获取 ejs.ui.toast 方法的详细信息
@@ -100,10 +106,12 @@ npx m8-mcp-server
100
106
  获取 Util 工具方法的详细信息。
101
107
 
102
108
  **参数:**
109
+
103
110
  - `category` (必需): Util 分类 (`string`, `date`, `ajax`, `common`)
104
111
  - `method` (可选): 方法名称
105
112
 
106
113
  **示例:**
114
+
107
115
  ```
108
116
  获取 Util.ajax 的使用方法
109
117
  获取字符串处理工具
@@ -114,10 +122,12 @@ npx m8-mcp-server
114
122
  获取编码规范。
115
123
 
116
124
  **参数:**
117
- - `type` (必需): 规范类型 (`css`, `javascript`, `vue`, `project-structure`, `all`)
125
+
126
+ - `type` (必需): 规范类型 (`css`, `javascript`, `vue`, `full-page`)
118
127
  - `keyword` (可选): 具体规则关键词
119
128
 
120
129
  **示例:**
130
+
121
131
  ```
122
132
  获取 CSS 编码规范
123
133
  获取 Vue 组件命名规范
@@ -128,40 +138,200 @@ npx m8-mcp-server
128
138
  生成符合 M8 规范的代码。
129
139
 
130
140
  **参数:**
141
+
131
142
  - `type` (必需): 代码类型,支持以下方式:
132
143
  - 单选字符串: `vue-component`, `javascript`, `scss`, `api-call`, `full-page`
133
144
  - 多选数组: `["vue-component", "scss"]` 一次生成多种代码
134
- - `full-page`: 快捷方式,等同于 `["vue-component", "scss"]`
145
+ - `full-page`: 快捷方式,等同于 `["vue-component", "scss", "router", "mock"]`
135
146
  - `requirement` (必需): 需求描述
136
147
  - `vueVersion` (可选): Vue 版本 (2 或 3),默认 2
137
148
  - `components` (可选): 使用的组件列表
138
-
139
- **示例:**
140
- ```json
141
- // 单一类型
142
- { "type": "vue-component", "requirement": "用户列表组件" }
143
-
144
- // 多选类型 - 同时生成 Vue 和 SCSS
145
- { "type": ["vue-component", "scss"], "requirement": "登录页面" }
146
-
147
- // full-page 快捷方式 - 生成完整页面
148
- { "type": "full-page", "requirement": "登录页面,包含用户名、密码输入框和登录按钮", "components": ["em-field", "em-button"] }
149
- ```
149
+ - `modulePath` (可选): 模块路径,默认自动生成
150
+ - `useMock` (可选): 是否使用 Mock 数据,默认 true
150
151
 
151
152
  ### recommend_solution
152
153
 
153
154
  根据需求智能推荐解决方案。
154
155
 
155
156
  **参数:**
157
+
156
158
  - `requirement` (必需): 需求描述
157
159
  - `type` (可选): 需求类型 (`ui`, `data`, `native`, `general`)
158
160
 
159
161
  **示例:**
162
+
160
163
  ```
161
164
  我需要显示一个提示消息
162
165
  我需要实现表单提交功能
163
166
  ```
164
167
 
168
+ ---
169
+
170
+ ## 📝 代码生成提示词示例
171
+
172
+ 以下是各种常见场景的提示词模板,可直接使用或根据需求修改:
173
+
174
+ ### 🔐 登录页面
175
+
176
+ ```json
177
+ {
178
+ "type": "full-page",
179
+ "requirement": "登录页面,包含用户名、密码输入框和登录按钮",
180
+ "vueVersion": 2,
181
+ "components": ["em-field", "em-button"]
182
+ }
183
+ ```
184
+
185
+ **自然语言方式:**
186
+
187
+ ```
188
+ 帮我生成一个登录页面,包含用户名、密码输入框和登录按钮,使用 Vue2
189
+ ```
190
+
191
+ ### 📋 注册表单
192
+
193
+ ```json
194
+ {
195
+ "type": "full-page",
196
+ "requirement": "用户注册表单,包含姓名、手机号(需验证格式)、身份证号(需验证格式)、密码输入框和注册按钮",
197
+ "vueVersion": 2,
198
+ "components": ["em-form", "em-field", "em-button"]
199
+ }
200
+ ```
201
+
202
+ **自然语言方式:**
203
+
204
+ ```
205
+ 生成一个用户注册表单页面,需要填写姓名、手机号、身份证号和密码,手机号和身份证需要格式校验
206
+ ```
207
+
208
+ ### 📝 文件上传表单
209
+
210
+ ```json
211
+ {
212
+ "type": "full-page",
213
+ "requirement": "信息采集表单,包含姓名、手机号输入框和附件上传功能",
214
+ "vueVersion": 2,
215
+ "components": ["em-form", "em-field", "em-uploader", "em-button"]
216
+ }
217
+ ```
218
+
219
+ **自然语言方式:**
220
+
221
+ ```
222
+ 生成一个信息采集页面,需要输入姓名、手机号,还要能上传附件
223
+ ```
224
+
225
+ ### 📃 列表页面
226
+
227
+ ```json
228
+ {
229
+ "type": "full-page",
230
+ "requirement": "待办事项列表页面,包含搜索框和下拉刷新列表,每项显示标题、状态和日期",
231
+ "vueVersion": 2,
232
+ "components": ["em-search", "em-minirefresh", "em-cell"]
233
+ }
234
+ ```
235
+
236
+ **自然语言方式:**
237
+
238
+ ```
239
+ 生成一个待办事项列表页面,需要有搜索功能和下拉刷新
240
+ ```
241
+
242
+ ### 📄 详情页面
243
+
244
+ ```json
245
+ {
246
+ "type": "full-page",
247
+ "requirement": "订单详情页面,显示订单编号、下单时间、商品信息、金额等,底部有确认和取消按钮",
248
+ "vueVersion": 2,
249
+ "components": ["em-cell", "em-panel", "em-button"]
250
+ }
251
+ ```
252
+
253
+ **自然语言方式:**
254
+
255
+ ```
256
+ 生成一个订单详情页面,展示订单编号、时间、商品信息和金额,底部有确认和取消按钮
257
+ ```
258
+
259
+ ### 🗓️ 日期选择表单
260
+
261
+ ```json
262
+ {
263
+ "type": "full-page",
264
+ "requirement": "请假申请表单,包含请假类型选择、开始日期、结束日期选择、请假事由输入和提交按钮",
265
+ "vueVersion": 2,
266
+ "components": [
267
+ "em-form",
268
+ "em-picker",
269
+ "em-datepicker",
270
+ "em-field",
271
+ "em-button"
272
+ ]
273
+ }
274
+ ```
275
+
276
+ **自然语言方式:**
277
+
278
+ ```
279
+ 生成一个请假申请页面,需要选择请假类型、开始和结束日期,填写请假事由
280
+ ```
281
+
282
+ ### 🔧 Vue3 Composition API 示例
283
+
284
+ ```json
285
+ {
286
+ "type": "full-page",
287
+ "requirement": "用户个人中心页面,显示头像、昵称、手机号,包含修改信息和退出登录功能",
288
+ "vueVersion": 3,
289
+ "components": ["em-cell", "em-button"]
290
+ }
291
+ ```
292
+
293
+ **自然语言方式:**
294
+
295
+ ```
296
+ 使用 Vue3 生成一个用户个人中心页面,显示头像、昵称和手机号,可以修改信息和退出登录
297
+ ```
298
+
299
+ ---
300
+
301
+ ## ⚡ 快速使用技巧
302
+
303
+ ### 1. 智能组件推荐
304
+
305
+ 如果不指定 `components`,系统会根据需求描述自动推荐合适的组件:
306
+
307
+ ```json
308
+ {
309
+ "type": "full-page",
310
+ "requirement": "用户注册表单,包含手机号、密码输入框"
311
+ }
312
+ ```
313
+
314
+ 系统会自动使用 `em-form`、`em-field`、`em-button` 组件。
315
+
316
+ ### 2. 文件上传支持
317
+
318
+ 需求中包含"附件"、"上传"等关键词时,自动使用 `em-uploader` 组件。
319
+
320
+ ---
321
+
322
+ ## 📁 生成的文件结构
323
+
324
+ 使用 `full-page` 类型时,会生成以下完整的文件结构:
325
+
326
+ ```
327
+ src/pages/[模块名]/
328
+ ├── index.vue # Vue 页面组件
329
+ ├── router.js # 路由配置
330
+ ├── mock.js # Mock 数据
331
+ └── css/
332
+ └── [模块名].scss # 样式文件
333
+ ```
334
+
165
335
  ## 开发
166
336
 
167
337
  ```bash
@@ -40,6 +40,27 @@ export declare function filterValidComponents(components: string[]): {
40
40
  valid: string[];
41
41
  warnings: string[];
42
42
  };
43
+ /**
44
+ * 表单字段信息
45
+ */
46
+ export interface FormFieldInfo {
47
+ /** 字段名称(中文) */
48
+ name: string;
49
+ /** 字段属性名(英文) */
50
+ propertyName: string;
51
+ /** 字段类型 */
52
+ type: 'text' | 'password' | 'number' | 'tel' | 'idcard' | 'textarea' | 'uploader';
53
+ /** 需要的校验类型 */
54
+ validation?: 'mobile' | 'idcard' | 'email' | 'tel' | 'required';
55
+ /** 对应的 Util.string 校验方法 */
56
+ validationMethod?: string;
57
+ }
58
+ /**
59
+ * 从需求描述中提取表单字段信息
60
+ * @param requirement 需求描述
61
+ * @returns 表单字段列表
62
+ */
63
+ export declare function extractFormFields(requirement: string): FormFieldInfo[];
43
64
  /**
44
65
  * 根据需求智能推荐组件
45
66
  * @param requirement 需求描述
@@ -1 +1 @@
1
- {"version":3,"file":"vue-template.d.ts","sourceRoot":"","sources":["../../src/generator/vue-template.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;IAClB,WAAW;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,sBAAsB;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS;IACT,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkC1E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG;IAC3D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,CA0CA;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CA2C/D;AAGD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAuIxE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAkIxE;AAsGD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GA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