m8-mcp-server 1.0.10 → 1.0.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/dist/generator/index.d.ts +1 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +782 -138
- package/dist/generator/vue-template.d.ts.map +1 -1
- package/dist/generator/vue-template.js +45 -45
- package/dist/tools/generate-code.d.ts.map +1 -1
- package/dist/tools/generate-code.js +3 -39
- package/package.json +1 -1
package/dist/generator/index.js
CHANGED
|
@@ -1,64 +1,35 @@
|
|
|
1
|
-
import{generateFileHeader as
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ${n} - API \u63A5\u53E3
|
|
5
|
-
* \u4F7F\u7528 Util.ajax \u53D1\u9001\u8BF7\u6C42\uFF0C\u9075\u5FAA M8 \u89C4\u8303
|
|
6
|
-
*/
|
|
7
|
-
|
|
1
|
+
import{generateFileHeader as x,generateScssFileHeader as D}from"./header.js";import{generateVueTemplate as w,filterValidComponents as T,suggestComponents as j}from"./vue-template.js";export*from"./header.js";export*from"./vue-template.js";const b={login:{suggestedComponents:["em-field","em-button"],apiEndpoints:["login","logout","check-login"],keywords:["\u767B\u5F55","login","\u767B\u9646","\u8D26\u53F7","\u5BC6\u7801"]},form:{suggestedComponents:["em-form","em-field","em-button","em-picker","em-datepicker"],apiEndpoints:["submit","save","detail"],keywords:["\u8868\u5355","form","\u63D0\u4EA4","\u586B\u5199","\u7533\u8BF7","\u65B0\u589E","\u7F16\u8F91","\u4FEE\u6539"]},list:{suggestedComponents:["em-cell","em-minirefresh","em-search","em-empty"],apiEndpoints:["list","search","delete"],keywords:["\u5217\u8868","list","\u8BB0\u5F55","\u6570\u636E","\u67E5\u8BE2"]},detail:{suggestedComponents:["em-cell","em-panel","em-button","em-image"],apiEndpoints:["detail","info"],keywords:["\u8BE6\u60C5","detail","\u67E5\u770B","\u4FE1\u606F"]},message:{suggestedComponents:["em-cell","em-minirefresh","em-badge","em-empty","em-swipecell"],apiEndpoints:["list","read","delete","read-all"],keywords:["\u6D88\u606F","message","\u901A\u77E5","\u516C\u544A","\u63D0\u9192","\u7AD9\u5185\u4FE1","\u672A\u8BFB"]},search:{suggestedComponents:["em-search","em-cell","em-minirefresh","em-empty","em-tag"],apiEndpoints:["search","hot-keywords","history"],keywords:["\u641C\u7D22","search","\u67E5\u627E","\u68C0\u7D22"]},profile:{suggestedComponents:["em-cell","em-image","em-button","em-uploader"],apiEndpoints:["info","update","avatar"],keywords:["\u4E2A\u4EBA","profile","\u6211\u7684","\u7528\u6237\u4E2D\u5FC3","\u8D26\u6237"]},settings:{suggestedComponents:["em-cell","em-switch","em-switchcell","em-dialog"],apiEndpoints:["settings","update"],keywords:["\u8BBE\u7F6E","settings","\u914D\u7F6E","\u504F\u597D"]},dashboard:{suggestedComponents:["em-grid","em-cell","em-chart","em-panel"],apiEndpoints:["statistics","summary","overview"],keywords:["\u9996\u9875","\u5DE5\u4F5C\u53F0","dashboard","\u6982\u89C8","\u7EDF\u8BA1","\u9A7E\u9A76\u8231"]},generic:{suggestedComponents:["em-cell","em-button"],apiEndpoints:["data"],keywords:[]}};function h(o){const t=o.toLowerCase(),e=["login","message","search","profile","settings","dashboard","detail","list","form","generic"];let a="generic",n=0;for(const i of e){const p=b[i];let d=0;for(const u of p.keywords)t.includes(u.toLowerCase())&&(d+=u.length);d>n&&(n=d,a=i)}const{moduleName:s,title:r}=U(o,a),c=b[a];return{type:a,title:r,moduleName:s,suggestedComponents:c.suggestedComponents,apiEndpoints:c.apiEndpoints,keywords:c.keywords}}function U(o,t){const e=[/(?:创建|生成|实现|开发|做一个|帮我做)(.+?)(?:组件|页面|功能|模块)/,/(.+?)(?:页面|列表|表单|详情|管理)/,/(?:参考.+?实现)(.+?)(?:页面|功能)?/];let a="";for(const s of e){const r=o.match(s);if(r&&r[1]){if(a=r[1].trim(),a=a.replace(/截图|图片|设计稿|原型/g,"").replace(/的$/g,"").trim(),a.length>0&&a.length<=10)break;a=""}}return a||(a={login:"\u767B\u5F55",form:"\u8868\u5355",list:"\u5217\u8868",detail:"\u8BE6\u60C5",message:"\u6D88\u606F",search:"\u641C\u7D22",profile:"\u4E2A\u4EBA\u4E2D\u5FC3",settings:"\u8BBE\u7F6E",dashboard:"\u9996\u9875",generic:"\u9875\u9762"}[t]),{moduleName:S(a),title:a}}function S(o){const t={\u6D88\u606F:"message",\u901A\u77E5:"notification",\u516C\u544A:"announcement",\u767B\u5F55:"login",\u6CE8\u518C:"register",\u9996\u9875:"home",\u5217\u8868:"list",\u8BE6\u60C5:"detail",\u8868\u5355:"form",\u641C\u7D22:"search",\u8BBE\u7F6E:"settings",\u4E2A\u4EBA:"profile",\u7528\u6237:"user",\u8BA2\u5355:"order",\u5546\u54C1:"product",\u8D2D\u7269\u8F66:"cart",\u652F\u4ED8:"payment",\u5730\u5740:"address",\u6536\u85CF:"favorite",\u8BC4\u4EF7:"review",\u5BA2\u670D:"service",\u5E2E\u52A9:"help",\u5173\u4E8E:"about",\u53CD\u9988:"feedback",\u5BA1\u6279:"approval",\u7533\u8BF7:"apply",\u5F85\u529E:"todo",\u5DF2\u529E:"done",\u5DE5\u4F5C\u53F0:"workspace",\u7EDF\u8BA1:"statistics",\u62A5\u8868:"report"};if(t[o])return t[o];let e=o;for(const[a,n]of Object.entries(t))e=e.replace(new RegExp(a,"g"),`-${n}-`);return e=e.replace(/[\s_]+/g,"-").replace(/^-+|-+$/g,"").replace(/-+/g,"-").toLowerCase(),/[\u4e00-\u9fa5]/.test(e)?"my-page":e||"my-page"}function C(o){return h(o).moduleName}function H(o){return h(o).title}function z(o,t){const e={login:[{name:"login",description:"\u7528\u6237\u767B\u5F55",endpoint:"/login",params:"{ username, password }",hasDataPath:!0},{name:"logout",description:"\u9000\u51FA\u767B\u5F55",endpoint:"/logout",params:"{}",hasDataPath:!1},{name:"checkLogin",description:"\u68C0\u67E5\u767B\u5F55\u72B6\u6001",endpoint:"/check-login",params:"{}",hasDataPath:!0}],message:[{name:"getMessageList",description:"\u83B7\u53D6\u6D88\u606F\u5217\u8868",endpoint:"/list",params:"{ pageNum = 1, pageSize = 10, type }",hasDataPath:!0},{name:"getMessageDetail",description:"\u83B7\u53D6\u6D88\u606F\u8BE6\u60C5",endpoint:"/detail",params:"{ id }",hasDataPath:!0},{name:"markAsRead",description:"\u6807\u8BB0\u6D88\u606F\u5DF2\u8BFB",endpoint:"/read",params:"{ id }",hasDataPath:!1},{name:"markAllAsRead",description:"\u5168\u90E8\u6807\u8BB0\u5DF2\u8BFB",endpoint:"/read-all",params:"{}",hasDataPath:!1},{name:"deleteMessage",description:"\u5220\u9664\u6D88\u606F",endpoint:"/delete",params:"{ id }",hasDataPath:!1},{name:"getUnreadCount",description:"\u83B7\u53D6\u672A\u8BFB\u6570\u91CF",endpoint:"/unread-count",params:"{}",hasDataPath:!0}],list:[{name:"getList",description:"\u83B7\u53D6\u5217\u8868\u6570\u636E",endpoint:"/list",params:"{ pageNum = 1, pageSize = 10, ...filters }",hasDataPath:!0},{name:"getDetail",description:"\u83B7\u53D6\u8BE6\u60C5",endpoint:"/detail",params:"{ id }",hasDataPath:!0},{name:"deleteItem",description:"\u5220\u9664\u6570\u636E",endpoint:"/delete",params:"{ id }",hasDataPath:!1}],detail:[{name:"getDetail",description:"\u83B7\u53D6\u8BE6\u60C5\u6570\u636E",endpoint:"/detail",params:"{ id }",hasDataPath:!0}],form:[{name:"getDetail",description:"\u83B7\u53D6\u8868\u5355\u6570\u636E\uFF08\u7F16\u8F91\u65F6\uFF09",endpoint:"/detail",params:"{ id }",hasDataPath:!0},{name:"submit",description:"\u63D0\u4EA4\u8868\u5355",endpoint:"/submit",params:"formData",hasDataPath:!1},{name:"saveDraft",description:"\u4FDD\u5B58\u8349\u7A3F",endpoint:"/save-draft",params:"formData",hasDataPath:!1}],search:[{name:"search",description:"\u641C\u7D22",endpoint:"/search",params:"{ keyword, pageNum = 1, pageSize = 10 }",hasDataPath:!0},{name:"getHotKeywords",description:"\u83B7\u53D6\u70ED\u95E8\u641C\u7D22",endpoint:"/hot-keywords",params:"{}",hasDataPath:!0},{name:"getSearchHistory",description:"\u83B7\u53D6\u641C\u7D22\u5386\u53F2",endpoint:"/history",params:"{}",hasDataPath:!0},{name:"clearHistory",description:"\u6E05\u7A7A\u641C\u7D22\u5386\u53F2",endpoint:"/clear-history",params:"{}",hasDataPath:!1}],profile:[{name:"getUserInfo",description:"\u83B7\u53D6\u7528\u6237\u4FE1\u606F",endpoint:"/info",params:"{}",hasDataPath:!0},{name:"updateUserInfo",description:"\u66F4\u65B0\u7528\u6237\u4FE1\u606F",endpoint:"/update",params:"userData",hasDataPath:!1},{name:"uploadAvatar",description:"\u4E0A\u4F20\u5934\u50CF",endpoint:"/avatar",params:"{ file }",hasDataPath:!0}],settings:[{name:"getSettings",description:"\u83B7\u53D6\u8BBE\u7F6E",endpoint:"/settings",params:"{}",hasDataPath:!0},{name:"updateSettings",description:"\u66F4\u65B0\u8BBE\u7F6E",endpoint:"/update",params:"settings",hasDataPath:!1}],dashboard:[{name:"getStatistics",description:"\u83B7\u53D6\u7EDF\u8BA1\u6570\u636E",endpoint:"/statistics",params:"{}",hasDataPath:!0},{name:"getSummary",description:"\u83B7\u53D6\u6982\u89C8\u6570\u636E",endpoint:"/summary",params:"{}",hasDataPath:!0},{name:"getNotices",description:"\u83B7\u53D6\u901A\u77E5\u516C\u544A",endpoint:"/notices",params:"{ limit = 5 }",hasDataPath:!0}],generic:[{name:"getData",description:"\u83B7\u53D6\u6570\u636E",endpoint:"/data",params:"{}",hasDataPath:!0},{name:"submitData",description:"\u63D0\u4EA4\u6570\u636E",endpoint:"/submit",params:"data",hasDataPath:!1}]};return e[o]||e.generic}function _(o,t,e=!0){const a=x({description:o}),n=h(o),s=z(n.type,t),r=e?`/rest/mock/${t}`:`/api/${t}`,c=s.map(p=>{const d=p.hasDataPath?`,
|
|
2
|
+
dataPath: 'data'`:"";return`
|
|
8
3
|
/**
|
|
9
|
-
*
|
|
4
|
+
* ${p.description}
|
|
10
5
|
* @param {Object} params - \u8BF7\u6C42\u53C2\u6570
|
|
11
6
|
* @returns {Promise} \u8BF7\u6C42\u7ED3\u679C
|
|
12
7
|
*/
|
|
13
|
-
export function
|
|
8
|
+
export function ${p.name}(params = ${p.params}) {
|
|
14
9
|
return Util.ajax({
|
|
15
|
-
url: Config.serverUrl + '${
|
|
10
|
+
url: Config.serverUrl + '${r}${p.endpoint}',
|
|
16
11
|
type: 'POST',
|
|
17
12
|
data: {
|
|
18
13
|
params: JSON.stringify(params)
|
|
19
|
-
}
|
|
20
|
-
dataPath: 'data'
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* \u83B7\u53D6\u8BE6\u60C5\u6570\u636E
|
|
26
|
-
* @param {string} id - \u6570\u636E ID
|
|
27
|
-
* @returns {Promise} \u8BF7\u6C42\u7ED3\u679C
|
|
28
|
-
*/
|
|
29
|
-
export function getDetail(id) {
|
|
30
|
-
return Util.ajax({
|
|
31
|
-
url: Config.serverUrl + '${a}/detail',
|
|
32
|
-
type: 'POST',
|
|
33
|
-
data: {
|
|
34
|
-
params: JSON.stringify({ id })
|
|
35
|
-
},
|
|
36
|
-
dataPath: 'data'
|
|
14
|
+
}${d}
|
|
37
15
|
});
|
|
38
|
-
}
|
|
16
|
+
}`}).join(`
|
|
17
|
+
`);return{code:`${a}
|
|
39
18
|
|
|
40
19
|
/**
|
|
41
|
-
* \
|
|
42
|
-
*
|
|
43
|
-
* @returns {Promise} \u8BF7\u6C42\u7ED3\u679C
|
|
20
|
+
* ${n.title} - API \u63A5\u53E3
|
|
21
|
+
* \u4F7F\u7528 Util.ajax \u53D1\u9001\u8BF7\u6C42\uFF0C\u9075\u5FAA M8 \u89C4\u8303
|
|
44
22
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
type: 'POST',
|
|
49
|
-
data: {
|
|
50
|
-
params: JSON.stringify(data)
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
`,language:"javascript",explanation:`\u751F\u6210\u4E86\u7B26\u5408 M8 \u89C4\u8303\u7684 API \u8C03\u7528\u4EE3\u7801\uFF1A
|
|
23
|
+
${c}
|
|
24
|
+
`,language:"javascript",explanation:`\u751F\u6210\u4E86\u7B26\u5408 M8 \u89C4\u8303\u7684 ${n.title} API \u8C03\u7528\u4EE3\u7801\uFF1A
|
|
25
|
+
- \u9875\u9762\u7C7B\u578B: ${n.type}
|
|
55
26
|
- \u4F7F\u7528 Util.ajax \u800C\u975E fetch \u6216 axios
|
|
56
27
|
- \u4F7F\u7528 Config.serverUrl \u4F5C\u4E3A API \u57FA\u7840 URL
|
|
57
|
-
- ${
|
|
58
|
-
- \u5305\u542B\
|
|
28
|
+
- ${e?"\u4F7F\u7528 Mock \u63A5\u53E3\u8DEF\u5F84 /rest/mock/":"\u4F7F\u7528\u6B63\u5F0F\u63A5\u53E3\u8DEF\u5F84 /api/"}
|
|
29
|
+
- \u5305\u542B ${s.length} \u4E2A API \u65B9\u6CD5`}}function $(o){return{code:`${x({description:o})}
|
|
59
30
|
|
|
60
31
|
/**
|
|
61
|
-
* ${
|
|
32
|
+
* ${o}
|
|
62
33
|
*/
|
|
63
34
|
|
|
64
35
|
/**
|
|
@@ -73,48 +44,455 @@ export function processData(options = {}) {
|
|
|
73
44
|
`,language:"javascript",explanation:`\u751F\u6210\u4E86\u57FA\u7840\u7684 JavaScript \u4EE3\u7801\u6846\u67B6\uFF0C\u5305\u542B\uFF1A
|
|
74
45
|
- \u89C4\u8303\u7684\u6587\u4EF6\u5934\u6CE8\u91CA
|
|
75
46
|
- \u51FD\u6570\u6CE8\u91CA\u6A21\u677F
|
|
76
|
-
- \u57FA\u7840\u4EE3\u7801\u7ED3\u6784`}}function M(
|
|
47
|
+
- \u57FA\u7840\u4EE3\u7801\u7ED3\u6784`}}function M(o,t){const e=D({description:o}),a=t.replace(/-/g,"_"),n=h(o),s=I(n.type,a);return{code:`${e}
|
|
48
|
+
/**
|
|
49
|
+
* ${n.title}
|
|
50
|
+
* \u9875\u9762\u7C7B\u578B: ${n.type}
|
|
51
|
+
* \u6837\u5F0F\u6587\u4EF6\u9075\u5FAA BEM \u547D\u540D\u89C4\u8303
|
|
52
|
+
*/
|
|
53
|
+
${s}
|
|
54
|
+
`,language:"scss",explanation:`\u751F\u6210\u4E86\u7B26\u5408 M8 \u89C4\u8303\u7684 ${n.title} SCSS \u4EE3\u7801\uFF1A
|
|
55
|
+
- \u9875\u9762\u7C7B\u578B: ${n.type}
|
|
56
|
+
- \u4F7F\u7528 BEM \u547D\u540D\u89C4\u8303
|
|
57
|
+
- \u4F7F\u7528\u4E0B\u5212\u7EBF\u98CE\u683C\u7684\u7C7B\u540D
|
|
58
|
+
- \u89C4\u8303\u7684\u6587\u4EF6\u5934\u6CE8\u91CA`}}function I(o,t){const e={login:`
|
|
77
59
|
// \u767B\u5F55\u9875\u9762\u6837\u5F0F
|
|
78
|
-
.${
|
|
60
|
+
.${t} {
|
|
79
61
|
min-height: 100vh;
|
|
80
|
-
padding:
|
|
81
|
-
background: #
|
|
62
|
+
padding: 60px 24px 40px;
|
|
63
|
+
background: linear-gradient(180deg, #f0f5ff 0%, #fff 100%);
|
|
64
|
+
|
|
65
|
+
&__logo {
|
|
66
|
+
text-align: center;
|
|
67
|
+
margin-bottom: 40px;
|
|
68
|
+
|
|
69
|
+
img {
|
|
70
|
+
width: 80px;
|
|
71
|
+
height: 80px;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
82
74
|
|
|
83
75
|
&__form {
|
|
84
76
|
padding: 24px;
|
|
85
77
|
background: #fff;
|
|
86
|
-
border-radius:
|
|
87
|
-
box-shadow: 0
|
|
78
|
+
border-radius: 12px;
|
|
79
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
|
88
80
|
}
|
|
89
81
|
|
|
90
82
|
&__actions {
|
|
91
|
-
margin-top:
|
|
83
|
+
margin-top: 32px;
|
|
92
84
|
padding: 0 16px;
|
|
93
85
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
|
|
87
|
+
&__footer {
|
|
88
|
+
margin-top: 24px;
|
|
89
|
+
text-align: center;
|
|
90
|
+
color: #999;
|
|
91
|
+
font-size: 12px;
|
|
92
|
+
}
|
|
93
|
+
}`,message:`
|
|
94
|
+
// \u6D88\u606F\u5217\u8868\u9875\u9762\u6837\u5F0F
|
|
95
|
+
.${t} {
|
|
97
96
|
min-height: 100vh;
|
|
98
|
-
padding: 12px;
|
|
99
97
|
background: #f5f7fa;
|
|
100
98
|
|
|
101
|
-
&
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
&__tabs {
|
|
100
|
+
background: #fff;
|
|
101
|
+
border-bottom: 1px solid #eee;
|
|
104
102
|
}
|
|
105
|
-
|
|
103
|
+
|
|
104
|
+
&__list {
|
|
105
|
+
padding: 12px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&__item {
|
|
109
|
+
margin-bottom: 12px;
|
|
110
|
+
padding: 16px;
|
|
111
|
+
background: #fff;
|
|
112
|
+
border-radius: 8px;
|
|
113
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
|
|
114
|
+
|
|
115
|
+
&--unread {
|
|
116
|
+
position: relative;
|
|
117
|
+
|
|
118
|
+
&::before {
|
|
119
|
+
content: '';
|
|
120
|
+
position: absolute;
|
|
121
|
+
top: 20px;
|
|
122
|
+
left: 8px;
|
|
123
|
+
width: 8px;
|
|
124
|
+
height: 8px;
|
|
125
|
+
background: #f56c6c;
|
|
126
|
+
border-radius: 50%;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&__item-header {
|
|
132
|
+
display: flex;
|
|
133
|
+
justify-content: space-between;
|
|
134
|
+
align-items: center;
|
|
135
|
+
margin-bottom: 8px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&__item-title {
|
|
139
|
+
flex: 1;
|
|
140
|
+
font-size: 16px;
|
|
141
|
+
font-weight: 500;
|
|
142
|
+
color: #333;
|
|
143
|
+
overflow: hidden;
|
|
144
|
+
text-overflow: ellipsis;
|
|
145
|
+
white-space: nowrap;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
&__item-time {
|
|
149
|
+
font-size: 12px;
|
|
150
|
+
color: #999;
|
|
151
|
+
margin-left: 12px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&__item-content {
|
|
155
|
+
font-size: 14px;
|
|
156
|
+
color: #666;
|
|
157
|
+
line-height: 1.5;
|
|
158
|
+
display: -webkit-box;
|
|
159
|
+
-webkit-line-clamp: 2;
|
|
160
|
+
-webkit-box-orient: vertical;
|
|
161
|
+
overflow: hidden;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&__empty {
|
|
165
|
+
padding: 60px 0;
|
|
166
|
+
text-align: center;
|
|
167
|
+
}
|
|
168
|
+
}`,list:`
|
|
106
169
|
// \u5217\u8868\u9875\u9762\u6837\u5F0F
|
|
107
|
-
.${
|
|
170
|
+
.${t} {
|
|
108
171
|
min-height: 100vh;
|
|
109
172
|
background: #f5f7fa;
|
|
110
173
|
|
|
174
|
+
&__search {
|
|
175
|
+
padding: 12px;
|
|
176
|
+
background: #fff;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
&__filter {
|
|
180
|
+
padding: 8px 12px;
|
|
181
|
+
background: #fff;
|
|
182
|
+
border-bottom: 1px solid #eee;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&__list {
|
|
186
|
+
padding: 12px;
|
|
187
|
+
}
|
|
188
|
+
|
|
111
189
|
&__item {
|
|
190
|
+
margin-bottom: 12px;
|
|
191
|
+
background: #fff;
|
|
192
|
+
border-radius: 8px;
|
|
193
|
+
overflow: hidden;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&__empty {
|
|
197
|
+
padding: 60px 0;
|
|
198
|
+
text-align: center;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
&__loading {
|
|
202
|
+
padding: 20px;
|
|
203
|
+
text-align: center;
|
|
204
|
+
color: #999;
|
|
205
|
+
}
|
|
206
|
+
}`,detail:`
|
|
207
|
+
// \u8BE6\u60C5\u9875\u9762\u6837\u5F0F
|
|
208
|
+
.${t} {
|
|
209
|
+
min-height: 100vh;
|
|
210
|
+
padding-bottom: 80px;
|
|
211
|
+
background: #f5f7fa;
|
|
212
|
+
|
|
213
|
+
&__header {
|
|
214
|
+
padding: 20px 16px;
|
|
215
|
+
background: #fff;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&__title {
|
|
219
|
+
font-size: 18px;
|
|
220
|
+
font-weight: 600;
|
|
221
|
+
color: #333;
|
|
222
|
+
line-height: 1.4;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
&__meta {
|
|
226
|
+
margin-top: 12px;
|
|
227
|
+
font-size: 12px;
|
|
228
|
+
color: #999;
|
|
229
|
+
display: flex;
|
|
230
|
+
gap: 16px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
&__content {
|
|
234
|
+
margin-top: 12px;
|
|
235
|
+
padding: 16px;
|
|
236
|
+
background: #fff;
|
|
237
|
+
|
|
238
|
+
p {
|
|
239
|
+
margin-bottom: 12px;
|
|
240
|
+
line-height: 1.8;
|
|
241
|
+
color: #333;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
img {
|
|
245
|
+
max-width: 100%;
|
|
246
|
+
border-radius: 4px;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&__actions {
|
|
251
|
+
position: fixed;
|
|
252
|
+
bottom: 0;
|
|
253
|
+
left: 0;
|
|
254
|
+
right: 0;
|
|
255
|
+
padding: 12px 16px;
|
|
256
|
+
background: #fff;
|
|
257
|
+
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
|
|
258
|
+
display: flex;
|
|
259
|
+
gap: 12px;
|
|
260
|
+
}
|
|
261
|
+
}`,form:`
|
|
262
|
+
// \u8868\u5355\u9875\u9762\u6837\u5F0F
|
|
263
|
+
.${t} {
|
|
264
|
+
min-height: 100vh;
|
|
265
|
+
padding-bottom: 80px;
|
|
266
|
+
background: #f5f7fa;
|
|
267
|
+
|
|
268
|
+
&__section {
|
|
269
|
+
margin-bottom: 12px;
|
|
270
|
+
background: #fff;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
&__section-title {
|
|
274
|
+
padding: 12px 16px;
|
|
275
|
+
font-size: 14px;
|
|
276
|
+
font-weight: 500;
|
|
277
|
+
color: #333;
|
|
278
|
+
border-bottom: 1px solid #f5f5f5;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
&__uploader {
|
|
282
|
+
padding: 12px 16px;
|
|
283
|
+
background: #fff;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
&__uploader-label {
|
|
112
287
|
margin-bottom: 8px;
|
|
288
|
+
font-size: 14px;
|
|
289
|
+
color: #333;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
&__actions {
|
|
293
|
+
position: fixed;
|
|
294
|
+
bottom: 0;
|
|
295
|
+
left: 0;
|
|
296
|
+
right: 0;
|
|
297
|
+
padding: 12px 16px;
|
|
298
|
+
background: #fff;
|
|
299
|
+
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
|
|
300
|
+
display: flex;
|
|
301
|
+
gap: 12px;
|
|
302
|
+
}
|
|
303
|
+
}`,search:`
|
|
304
|
+
// \u641C\u7D22\u9875\u9762\u6837\u5F0F
|
|
305
|
+
.${t} {
|
|
306
|
+
min-height: 100vh;
|
|
307
|
+
background: #f5f7fa;
|
|
308
|
+
|
|
309
|
+
&__header {
|
|
310
|
+
padding: 12px;
|
|
311
|
+
background: #fff;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
&__history {
|
|
315
|
+
padding: 16px;
|
|
316
|
+
background: #fff;
|
|
317
|
+
margin-bottom: 12px;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
&__history-header {
|
|
321
|
+
display: flex;
|
|
322
|
+
justify-content: space-between;
|
|
323
|
+
align-items: center;
|
|
324
|
+
margin-bottom: 12px;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
&__history-title {
|
|
328
|
+
font-size: 14px;
|
|
329
|
+
font-weight: 500;
|
|
330
|
+
color: #333;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
&__history-clear {
|
|
334
|
+
font-size: 12px;
|
|
335
|
+
color: #999;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
&__history-tags {
|
|
339
|
+
display: flex;
|
|
340
|
+
flex-wrap: wrap;
|
|
341
|
+
gap: 8px;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
&__hot {
|
|
345
|
+
padding: 16px;
|
|
346
|
+
background: #fff;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
&__results {
|
|
350
|
+
padding: 12px;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
&__empty {
|
|
354
|
+
padding: 60px 0;
|
|
355
|
+
text-align: center;
|
|
356
|
+
}
|
|
357
|
+
}`,profile:`
|
|
358
|
+
// \u4E2A\u4EBA\u4E2D\u5FC3\u9875\u9762\u6837\u5F0F
|
|
359
|
+
.${t} {
|
|
360
|
+
min-height: 100vh;
|
|
361
|
+
background: #f5f7fa;
|
|
362
|
+
|
|
363
|
+
&__header {
|
|
364
|
+
padding: 30px 20px;
|
|
365
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
366
|
+
text-align: center;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
&__avatar {
|
|
370
|
+
width: 80px;
|
|
371
|
+
height: 80px;
|
|
372
|
+
border-radius: 50%;
|
|
373
|
+
border: 3px solid rgba(255, 255, 255, 0.3);
|
|
374
|
+
margin-bottom: 12px;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
&__name {
|
|
378
|
+
font-size: 18px;
|
|
379
|
+
font-weight: 600;
|
|
380
|
+
color: #fff;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
&__info {
|
|
384
|
+
margin-top: 8px;
|
|
385
|
+
font-size: 14px;
|
|
386
|
+
color: rgba(255, 255, 255, 0.8);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
&__menu {
|
|
390
|
+
margin-top: 12px;
|
|
391
|
+
background: #fff;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
&__logout {
|
|
395
|
+
margin: 24px 16px;
|
|
396
|
+
}
|
|
397
|
+
}`,settings:`
|
|
398
|
+
// \u8BBE\u7F6E\u9875\u9762\u6837\u5F0F
|
|
399
|
+
.${t} {
|
|
400
|
+
min-height: 100vh;
|
|
401
|
+
background: #f5f7fa;
|
|
402
|
+
|
|
403
|
+
&__group {
|
|
404
|
+
margin-bottom: 12px;
|
|
405
|
+
background: #fff;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
&__group-title {
|
|
409
|
+
padding: 12px 16px 8px;
|
|
410
|
+
font-size: 12px;
|
|
411
|
+
color: #999;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
&__version {
|
|
415
|
+
margin-top: 40px;
|
|
416
|
+
text-align: center;
|
|
417
|
+
font-size: 12px;
|
|
418
|
+
color: #999;
|
|
419
|
+
}
|
|
420
|
+
}`,dashboard:`
|
|
421
|
+
// \u9996\u9875/\u5DE5\u4F5C\u53F0\u6837\u5F0F
|
|
422
|
+
.${t} {
|
|
423
|
+
min-height: 100vh;
|
|
424
|
+
background: #f5f7fa;
|
|
425
|
+
|
|
426
|
+
&__header {
|
|
427
|
+
padding: 20px 16px;
|
|
428
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
429
|
+
color: #fff;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
&__welcome {
|
|
433
|
+
font-size: 18px;
|
|
434
|
+
font-weight: 500;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
&__date {
|
|
438
|
+
margin-top: 4px;
|
|
439
|
+
font-size: 12px;
|
|
440
|
+
opacity: 0.8;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
&__stats {
|
|
444
|
+
display: flex;
|
|
445
|
+
margin: -30px 12px 12px;
|
|
446
|
+
padding: 16px;
|
|
447
|
+
background: #fff;
|
|
448
|
+
border-radius: 8px;
|
|
449
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
&__stat-item {
|
|
453
|
+
flex: 1;
|
|
454
|
+
text-align: center;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
&__stat-value {
|
|
458
|
+
font-size: 24px;
|
|
459
|
+
font-weight: 600;
|
|
460
|
+
color: #333;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
&__stat-label {
|
|
464
|
+
margin-top: 4px;
|
|
465
|
+
font-size: 12px;
|
|
466
|
+
color: #999;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
&__section {
|
|
470
|
+
margin: 12px;
|
|
471
|
+
padding: 16px;
|
|
113
472
|
background: #fff;
|
|
473
|
+
border-radius: 8px;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
&__section-header {
|
|
477
|
+
display: flex;
|
|
478
|
+
justify-content: space-between;
|
|
479
|
+
align-items: center;
|
|
480
|
+
margin-bottom: 12px;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
&__section-title {
|
|
484
|
+
font-size: 16px;
|
|
485
|
+
font-weight: 500;
|
|
486
|
+
color: #333;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
&__section-more {
|
|
490
|
+
font-size: 12px;
|
|
491
|
+
color: #999;
|
|
114
492
|
}
|
|
115
|
-
}
|
|
116
|
-
// \u9875\u9762\u6837\u5F0F
|
|
117
|
-
.${
|
|
493
|
+
}`,generic:`
|
|
494
|
+
// \u901A\u7528\u9875\u9762\u6837\u5F0F
|
|
495
|
+
.${t} {
|
|
118
496
|
min-height: 100vh;
|
|
119
497
|
padding: 12px;
|
|
120
498
|
background: #f5f7fa;
|
|
@@ -124,16 +502,12 @@ export function processData(options = {}) {
|
|
|
124
502
|
background: #fff;
|
|
125
503
|
border-radius: 8px;
|
|
126
504
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
`,language:"scss",explanation:`\u751F\u6210\u4E86\u7B26\u5408 M8 \u89C4\u8303\u7684 SCSS \u4EE3\u7801\uFF1A
|
|
134
|
-
- \u4F7F\u7528 BEM \u547D\u540D\u89C4\u8303
|
|
135
|
-
- \u4F7F\u7528\u4E0B\u5212\u7EBF\u98CE\u683C\u7684\u7C7B\u540D
|
|
136
|
-
- \u89C4\u8303\u7684\u6587\u4EF6\u5934\u6CE8\u91CA`}}function S(n,t){return{code:`${m({description:`${t} - \u8DEF\u7531\u914D\u7F6E`})}
|
|
505
|
+
|
|
506
|
+
&__actions {
|
|
507
|
+
margin-top: 24px;
|
|
508
|
+
padding: 0 16px;
|
|
509
|
+
}
|
|
510
|
+
}`};return e[o]||e.generic}function A(o,t){return{code:`${x({description:`${t} - \u8DEF\u7531\u914D\u7F6E`})}
|
|
137
511
|
|
|
138
512
|
/**
|
|
139
513
|
* ${t} \u8DEF\u7531\u914D\u7F6E
|
|
@@ -144,7 +518,8 @@ ${i}
|
|
|
144
518
|
// \u5B9A\u4E49\u8DEF\u7531\u89C4\u5219
|
|
145
519
|
const routes = [
|
|
146
520
|
{
|
|
147
|
-
|
|
521
|
+
// \u4E3B\u9875\u9762
|
|
522
|
+
path: 'pages/${o}/index',
|
|
148
523
|
style: {
|
|
149
524
|
navigationBarTitleText: '${t}',
|
|
150
525
|
navigationStyle: 'custom'
|
|
@@ -154,154 +529,423 @@ const routes = [
|
|
|
154
529
|
|
|
155
530
|
// \u8DEF\u7531\u9009\u9879
|
|
156
531
|
const options = {
|
|
532
|
+
// \u662F\u5426\u81EA\u52A8\u5206\u5305
|
|
157
533
|
autoSubPackages: true,
|
|
534
|
+
// \u662F\u5426\u4E3A\u9996\u9875\u6A21\u5757
|
|
158
535
|
isFirstModule: false
|
|
159
536
|
};
|
|
160
537
|
|
|
161
538
|
// \u5BFC\u51FA\u8DEF\u7531\u914D\u7F6E
|
|
162
539
|
export default { routes, options };
|
|
163
540
|
`,language:"javascript",explanation:`\u751F\u6210\u4E86\u7B26\u5408 M8 \u89C4\u8303\u7684\u8DEF\u7531\u914D\u7F6E\uFF1A
|
|
164
|
-
- \u8DEF\u5F84\
|
|
541
|
+
- \u8DEF\u5F84\u683C\u5F0F: pages/${o}/index
|
|
165
542
|
- \u5305\u542B\u5BFC\u822A\u680F\u6807\u9898\u914D\u7F6E
|
|
166
|
-
- \u4F7F\u7528 custom \u5BFC\u822A\u6837\u5F0F
|
|
543
|
+
- \u4F7F\u7528 custom \u5BFC\u822A\u6837\u5F0F
|
|
544
|
+
- \u652F\u6301\u81EA\u52A8\u5206\u5305\u914D\u7F6E`}}function O(o,t){const e=`/rest/mock/${t}`,a={login:`
|
|
167
545
|
{
|
|
168
546
|
// \u767B\u5F55\u63A5\u53E3
|
|
169
|
-
methodUrl: '
|
|
547
|
+
methodUrl: '${e}/login',
|
|
170
548
|
input: {},
|
|
171
549
|
output: Mock.mock({
|
|
172
|
-
status: {
|
|
173
|
-
code: 1,
|
|
174
|
-
text: '\u767B\u5F55\u6210\u529F'
|
|
175
|
-
},
|
|
550
|
+
status: { code: 1, text: '\u767B\u5F55\u6210\u529F' },
|
|
176
551
|
data: {
|
|
177
552
|
token: '@guid',
|
|
178
553
|
userId: '@id',
|
|
179
|
-
username: '@cname'
|
|
554
|
+
username: '@cname',
|
|
555
|
+
avatar: '@image("100x100")'
|
|
556
|
+
}
|
|
557
|
+
})
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
// \u9000\u51FA\u767B\u5F55
|
|
561
|
+
methodUrl: '${e}/logout',
|
|
562
|
+
input: {},
|
|
563
|
+
output: Mock.mock({
|
|
564
|
+
status: { code: 1, text: '\u9000\u51FA\u6210\u529F' }
|
|
565
|
+
})
|
|
566
|
+
}`,message:`
|
|
567
|
+
{
|
|
568
|
+
// \u6D88\u606F\u5217\u8868
|
|
569
|
+
methodUrl: '${e}/list',
|
|
570
|
+
input: {},
|
|
571
|
+
output: Mock.mock({
|
|
572
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
573
|
+
data: {
|
|
574
|
+
'list|10-20': [{
|
|
575
|
+
'id|+1': 1,
|
|
576
|
+
title: '@ctitle(10, 30)',
|
|
577
|
+
content: '@cparagraph(1, 3)',
|
|
578
|
+
'type|1': ['system', 'notice', 'message'],
|
|
579
|
+
'isRead|1': [true, false],
|
|
580
|
+
sender: '@cname',
|
|
581
|
+
createTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
|
|
582
|
+
}],
|
|
583
|
+
total: '@integer(50, 200)',
|
|
584
|
+
unreadCount: '@integer(0, 20)'
|
|
180
585
|
}
|
|
181
586
|
})
|
|
182
|
-
}
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
// \u6D88\u606F\u8BE6\u60C5
|
|
590
|
+
methodUrl: '${e}/detail',
|
|
591
|
+
input: {},
|
|
592
|
+
output: Mock.mock({
|
|
593
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
594
|
+
data: {
|
|
595
|
+
id: '@id',
|
|
596
|
+
title: '@ctitle(10, 30)',
|
|
597
|
+
content: '@cparagraph(5, 10)',
|
|
598
|
+
type: 'notice',
|
|
599
|
+
sender: '@cname',
|
|
600
|
+
createTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
|
|
601
|
+
'attachments|0-3': [{
|
|
602
|
+
name: '@ctitle(5, 10).pdf',
|
|
603
|
+
url: '@url'
|
|
604
|
+
}]
|
|
605
|
+
}
|
|
606
|
+
})
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
// \u6807\u8BB0\u5DF2\u8BFB
|
|
610
|
+
methodUrl: '${e}/read',
|
|
611
|
+
input: {},
|
|
612
|
+
output: Mock.mock({
|
|
613
|
+
status: { code: 1, text: '\u64CD\u4F5C\u6210\u529F' }
|
|
614
|
+
})
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
// \u5168\u90E8\u5DF2\u8BFB
|
|
618
|
+
methodUrl: '${e}/read-all',
|
|
619
|
+
input: {},
|
|
620
|
+
output: Mock.mock({
|
|
621
|
+
status: { code: 1, text: '\u64CD\u4F5C\u6210\u529F' }
|
|
622
|
+
})
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
// \u5220\u9664\u6D88\u606F
|
|
626
|
+
methodUrl: '${e}/delete',
|
|
627
|
+
input: {},
|
|
628
|
+
output: Mock.mock({
|
|
629
|
+
status: { code: 1, text: '\u5220\u9664\u6210\u529F' }
|
|
630
|
+
})
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
// \u672A\u8BFB\u6570\u91CF
|
|
634
|
+
methodUrl: '${e}/unread-count',
|
|
635
|
+
input: {},
|
|
636
|
+
output: Mock.mock({
|
|
637
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
638
|
+
data: { count: '@integer(0, 99)' }
|
|
639
|
+
})
|
|
640
|
+
}`,list:`
|
|
183
641
|
{
|
|
184
642
|
// \u5217\u8868\u63A5\u53E3
|
|
185
|
-
methodUrl: '
|
|
643
|
+
methodUrl: '${e}/list',
|
|
186
644
|
input: {},
|
|
187
645
|
output: Mock.mock({
|
|
188
|
-
status: {
|
|
189
|
-
code: 1,
|
|
190
|
-
text: '\u6210\u529F'
|
|
191
|
-
},
|
|
646
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
192
647
|
data: {
|
|
193
|
-
'list|10-20': [
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
],
|
|
648
|
+
'list|10-20': [{
|
|
649
|
+
'id|+1': 1,
|
|
650
|
+
title: '@ctitle(5, 15)',
|
|
651
|
+
description: '@cparagraph(1, 2)',
|
|
652
|
+
'status|1': ['pending', 'processing', 'completed'],
|
|
653
|
+
createTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
|
|
654
|
+
creator: '@cname'
|
|
655
|
+
}],
|
|
201
656
|
total: '@integer(50, 200)'
|
|
202
657
|
}
|
|
203
658
|
})
|
|
204
659
|
},
|
|
205
660
|
{
|
|
206
661
|
// \u8BE6\u60C5\u63A5\u53E3
|
|
207
|
-
methodUrl: '
|
|
662
|
+
methodUrl: '${e}/detail',
|
|
208
663
|
input: {},
|
|
209
664
|
output: Mock.mock({
|
|
210
|
-
status: {
|
|
211
|
-
code: 1,
|
|
212
|
-
text: '\u6210\u529F'
|
|
213
|
-
},
|
|
665
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
214
666
|
data: {
|
|
215
667
|
id: '@id',
|
|
216
668
|
title: '@ctitle(10, 20)',
|
|
217
669
|
content: '@cparagraph(5, 10)',
|
|
218
670
|
createTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
|
|
671
|
+
updateTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
|
|
672
|
+
creator: '@cname'
|
|
673
|
+
}
|
|
674
|
+
})
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
// \u5220\u9664\u63A5\u53E3
|
|
678
|
+
methodUrl: '${e}/delete',
|
|
679
|
+
input: {},
|
|
680
|
+
output: Mock.mock({
|
|
681
|
+
status: { code: 1, text: '\u5220\u9664\u6210\u529F' }
|
|
682
|
+
})
|
|
683
|
+
}`,detail:`
|
|
684
|
+
{
|
|
685
|
+
// \u8BE6\u60C5\u63A5\u53E3
|
|
686
|
+
methodUrl: '${e}/detail',
|
|
687
|
+
input: {},
|
|
688
|
+
output: Mock.mock({
|
|
689
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
690
|
+
data: {
|
|
691
|
+
id: '@id',
|
|
692
|
+
title: '@ctitle(10, 20)',
|
|
693
|
+
content: '@cparagraph(5, 10)',
|
|
694
|
+
'images|0-5': ['@image("400x300")'],
|
|
695
|
+
createTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
|
|
696
|
+
updateTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
|
|
219
697
|
author: '@cname'
|
|
220
698
|
}
|
|
221
699
|
})
|
|
222
|
-
}
|
|
700
|
+
}`,form:`
|
|
223
701
|
{
|
|
224
|
-
// \u83B7\u53D6\u6570\u636E\
|
|
225
|
-
methodUrl: '
|
|
702
|
+
// \u83B7\u53D6\u8868\u5355\u6570\u636E\uFF08\u7F16\u8F91\u65F6\uFF09
|
|
703
|
+
methodUrl: '${e}/detail',
|
|
226
704
|
input: {},
|
|
227
705
|
output: Mock.mock({
|
|
228
|
-
status: {
|
|
229
|
-
code: 1,
|
|
230
|
-
text: '\u6210\u529F'
|
|
231
|
-
},
|
|
706
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
232
707
|
data: {
|
|
233
708
|
id: '@id',
|
|
234
709
|
name: '@cname',
|
|
235
|
-
|
|
710
|
+
phone: /^1[3-9]\\d{9}$/,
|
|
711
|
+
email: '@email',
|
|
712
|
+
remark: '@cparagraph(1, 2)'
|
|
713
|
+
}
|
|
714
|
+
})
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
// \u63D0\u4EA4\u8868\u5355
|
|
718
|
+
methodUrl: '${e}/submit',
|
|
719
|
+
input: {},
|
|
720
|
+
output: Mock.mock({
|
|
721
|
+
status: { code: 1, text: '\u63D0\u4EA4\u6210\u529F' },
|
|
722
|
+
data: { id: '@id' }
|
|
723
|
+
})
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
// \u4FDD\u5B58\u8349\u7A3F
|
|
727
|
+
methodUrl: '${e}/save-draft',
|
|
728
|
+
input: {},
|
|
729
|
+
output: Mock.mock({
|
|
730
|
+
status: { code: 1, text: '\u4FDD\u5B58\u6210\u529F' },
|
|
731
|
+
data: { id: '@id' }
|
|
732
|
+
})
|
|
733
|
+
}`,search:`
|
|
734
|
+
{
|
|
735
|
+
// \u641C\u7D22\u63A5\u53E3
|
|
736
|
+
methodUrl: '${e}/search',
|
|
737
|
+
input: {},
|
|
738
|
+
output: Mock.mock({
|
|
739
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
740
|
+
data: {
|
|
741
|
+
'list|0-20': [{
|
|
742
|
+
'id|+1': 1,
|
|
743
|
+
title: '@ctitle(5, 15)',
|
|
744
|
+
description: '@cparagraph(1)',
|
|
745
|
+
'highlight': '@ctitle(3, 8)'
|
|
746
|
+
}],
|
|
747
|
+
total: '@integer(0, 100)'
|
|
748
|
+
}
|
|
749
|
+
})
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
// \u70ED\u95E8\u641C\u7D22
|
|
753
|
+
methodUrl: '${e}/hot-keywords',
|
|
754
|
+
input: {},
|
|
755
|
+
output: Mock.mock({
|
|
756
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
757
|
+
data: {
|
|
758
|
+
'keywords|5-10': ['@ctitle(2, 4)']
|
|
759
|
+
}
|
|
760
|
+
})
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
// \u641C\u7D22\u5386\u53F2
|
|
764
|
+
methodUrl: '${e}/history',
|
|
765
|
+
input: {},
|
|
766
|
+
output: Mock.mock({
|
|
767
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
768
|
+
data: {
|
|
769
|
+
'history|0-10': ['@ctitle(2, 6)']
|
|
770
|
+
}
|
|
771
|
+
})
|
|
772
|
+
}`,profile:`
|
|
773
|
+
{
|
|
774
|
+
// \u83B7\u53D6\u7528\u6237\u4FE1\u606F
|
|
775
|
+
methodUrl: '${e}/info',
|
|
776
|
+
input: {},
|
|
777
|
+
output: Mock.mock({
|
|
778
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
779
|
+
data: {
|
|
780
|
+
id: '@id',
|
|
781
|
+
name: '@cname',
|
|
782
|
+
avatar: '@image("100x100")',
|
|
783
|
+
phone: /^1[3-9]\\d{9}$/,
|
|
784
|
+
email: '@email',
|
|
785
|
+
department: '@ctitle(3, 6)',
|
|
786
|
+
position: '@ctitle(2, 4)'
|
|
787
|
+
}
|
|
788
|
+
})
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
// \u66F4\u65B0\u7528\u6237\u4FE1\u606F
|
|
792
|
+
methodUrl: '${e}/update',
|
|
793
|
+
input: {},
|
|
794
|
+
output: Mock.mock({
|
|
795
|
+
status: { code: 1, text: '\u66F4\u65B0\u6210\u529F' }
|
|
796
|
+
})
|
|
797
|
+
}`,settings:`
|
|
798
|
+
{
|
|
799
|
+
// \u83B7\u53D6\u8BBE\u7F6E
|
|
800
|
+
methodUrl: '${e}/settings',
|
|
801
|
+
input: {},
|
|
802
|
+
output: Mock.mock({
|
|
803
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
804
|
+
data: {
|
|
805
|
+
'notification|1': [true, false],
|
|
806
|
+
'sound|1': [true, false],
|
|
807
|
+
'vibration|1': [true, false],
|
|
808
|
+
language: 'zh-CN',
|
|
809
|
+
theme: 'light'
|
|
810
|
+
}
|
|
811
|
+
})
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
// \u66F4\u65B0\u8BBE\u7F6E
|
|
815
|
+
methodUrl: '${e}/update',
|
|
816
|
+
input: {},
|
|
817
|
+
output: Mock.mock({
|
|
818
|
+
status: { code: 1, text: '\u4FDD\u5B58\u6210\u529F' }
|
|
819
|
+
})
|
|
820
|
+
}`,dashboard:`
|
|
821
|
+
{
|
|
822
|
+
// \u7EDF\u8BA1\u6570\u636E
|
|
823
|
+
methodUrl: '${e}/statistics',
|
|
824
|
+
input: {},
|
|
825
|
+
output: Mock.mock({
|
|
826
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
827
|
+
data: {
|
|
828
|
+
totalCount: '@integer(1000, 9999)',
|
|
829
|
+
todayCount: '@integer(10, 100)',
|
|
830
|
+
pendingCount: '@integer(5, 50)',
|
|
831
|
+
completedCount: '@integer(100, 500)'
|
|
236
832
|
}
|
|
237
833
|
})
|
|
238
834
|
},
|
|
239
835
|
{
|
|
240
|
-
// \
|
|
241
|
-
methodUrl: '
|
|
836
|
+
// \u6982\u89C8\u6570\u636E
|
|
837
|
+
methodUrl: '${e}/summary',
|
|
242
838
|
input: {},
|
|
243
839
|
output: Mock.mock({
|
|
244
|
-
status: {
|
|
245
|
-
code: 1,
|
|
246
|
-
text: '\u63D0\u4EA4\u6210\u529F'
|
|
247
|
-
},
|
|
840
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
248
841
|
data: {
|
|
249
|
-
|
|
842
|
+
'recentItems|5': [{
|
|
843
|
+
'id|+1': 1,
|
|
844
|
+
title: '@ctitle(5, 10)',
|
|
845
|
+
time: '@datetime("MM-dd HH:mm")'
|
|
846
|
+
}]
|
|
250
847
|
}
|
|
251
848
|
})
|
|
252
|
-
}
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
// \u901A\u77E5\u516C\u544A
|
|
852
|
+
methodUrl: '${e}/notices',
|
|
853
|
+
input: {},
|
|
854
|
+
output: Mock.mock({
|
|
855
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
856
|
+
data: {
|
|
857
|
+
'list|3-5': [{
|
|
858
|
+
'id|+1': 1,
|
|
859
|
+
title: '@ctitle(10, 20)',
|
|
860
|
+
time: '@date("yyyy-MM-dd")'
|
|
861
|
+
}]
|
|
862
|
+
}
|
|
863
|
+
})
|
|
864
|
+
}`,generic:`
|
|
865
|
+
{
|
|
866
|
+
// \u83B7\u53D6\u6570\u636E
|
|
867
|
+
methodUrl: '${e}/data',
|
|
868
|
+
input: {},
|
|
869
|
+
output: Mock.mock({
|
|
870
|
+
status: { code: 1, text: '\u6210\u529F' },
|
|
871
|
+
data: {
|
|
872
|
+
id: '@id',
|
|
873
|
+
name: '@cname',
|
|
874
|
+
createTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
|
|
875
|
+
}
|
|
876
|
+
})
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
// \u63D0\u4EA4\u6570\u636E
|
|
880
|
+
methodUrl: '${e}/submit',
|
|
881
|
+
input: {},
|
|
882
|
+
output: Mock.mock({
|
|
883
|
+
status: { code: 1, text: '\u63D0\u4EA4\u6210\u529F' },
|
|
884
|
+
data: { id: '@id' }
|
|
885
|
+
})
|
|
886
|
+
}`};return a[o]||a.generic}function E(o,t){const e=x({description:`${t} - Mock \u6570\u636E`}),a=h(t),n=O(a.type,o);return{code:`${e}
|
|
253
887
|
|
|
254
888
|
/**
|
|
255
|
-
* ${
|
|
889
|
+
* ${a.title} - Mock \u6570\u636E\u914D\u7F6E
|
|
256
890
|
* Mock \u6587\u4EF6\u5B9A\u4E49\u8BF7\u6C42\u672C\u5730\u63A5\u53E3\u65F6\u54CD\u5E94\u7684\u6A21\u62DF\u6570\u636E
|
|
891
|
+
* \u9875\u9762\u7C7B\u578B: ${a.type}
|
|
257
892
|
*/
|
|
258
893
|
import Mock from '@mock';
|
|
259
894
|
|
|
260
|
-
const mockData = [${
|
|
895
|
+
const mockData = [${n}
|
|
261
896
|
];
|
|
262
897
|
|
|
263
898
|
export default mockData;
|
|
264
|
-
`,language:"javascript",explanation:`\u751F\u6210\u4E86\u7B26\u5408 M8 \u89C4\u8303\u7684 Mock \u6570\u636E\u914D\u7F6E\uFF1A
|
|
899
|
+
`,language:"javascript",explanation:`\u751F\u6210\u4E86\u7B26\u5408 M8 \u89C4\u8303\u7684 ${a.title} Mock \u6570\u636E\u914D\u7F6E\uFF1A
|
|
900
|
+
- \u9875\u9762\u7C7B\u578B: ${a.type}
|
|
265
901
|
- \u4F7F\u7528 @mock \u5BFC\u5165 Mock \u5E93
|
|
266
902
|
- \u5B9A\u4E49\u4E86 methodUrl \u5339\u914D\u7684\u63A5\u53E3
|
|
267
|
-
- \u4F7F\u7528 Mock.mock \u751F\u6210\u968F\u673A\u6570\u636E`}}function
|
|
903
|
+
- \u4F7F\u7528 Mock.mock \u751F\u6210\u968F\u673A\u6570\u636E`}}function P(o,t=2,e=[],a=!0){const n=C(o),s=H(o),{valid:r,warnings:c}=T(e),i=r.length>0?r:j(o),d=w({name:n,vueVersion:t,description:o,components:i,includeStyle:!0,useMock:a,pageTitle:s});let f=`\u751F\u6210\u4E86 Vue${t} \u7EC4\u4EF6\u4EE3\u7801\uFF1A
|
|
268
904
|
- \u4F7F\u7528 ${t===3?"Composition API (script setup)":"Options API"} \u8BED\u6CD5
|
|
269
905
|
- \u5305\u542B\u89C4\u8303\u7684\u6587\u4EF6\u5934\u6CE8\u91CA
|
|
270
906
|
- \u6837\u5F0F\u901A\u8FC7 @import \u5F15\u5165\u5916\u90E8 SCSS \u6587\u4EF6
|
|
271
907
|
- \u4F7F\u7528 ejs.ui.toast/showWaiting \u7B49\u539F\u751F API
|
|
272
|
-
- \u4F7F\u7528 Util.ajax + Config.serverUrl \u53D1\u9001\u8BF7\u6C42`;return i.length>0&&(
|
|
273
|
-
- \u4F7F\u7528\u4E86 ${i.join(", ")} \u7EC4\u4EF6`),
|
|
908
|
+
- \u4F7F\u7528 Util.ajax + Config.serverUrl \u53D1\u9001\u8BF7\u6C42`;return i.length>0&&(f+=`
|
|
909
|
+
- \u4F7F\u7528\u4E86 ${i.join(", ")} \u7EC4\u4EF6`),c.length>0&&(f+=`
|
|
274
910
|
|
|
275
911
|
\u26A0\uFE0F \u8B66\u544A:
|
|
276
|
-
${
|
|
277
|
-
`)}`),{code:
|
|
912
|
+
${c.map(y=>`- ${y}`).join(`
|
|
913
|
+
`)}`),{code:d,language:"vue",explanation:f}}class G{generateCode(t){const{type:e,requirement:a,vueVersion:n=2,components:s=[],useMock:r=!0}=t;if(Array.isArray(e)){const i=this.generateMultipleCode({types:e,requirement:a,vueVersion:n,components:s,useMock:r});return{code:i.files.map(p=>p.code).join(`
|
|
278
914
|
|
|
279
|
-
`),language:"text",explanation:i.explanation}}const
|
|
280
|
-
${
|
|
915
|
+
`),language:"text",explanation:i.explanation}}const c=C(a);switch(e){case"vue-component":return P(a,n,s,r);case"javascript":return $(a);case"scss":return M(a,c);case"api-call":return _(a,c,r);case"full-page":const i=this.generateMultipleCode({types:["vue-component","scss","router","mock"],requirement:a,vueVersion:n,components:s,useMock:r});return{code:i.files.map(p=>`// === ${p.relativePath||p.filename} ===
|
|
916
|
+
${p.code}`).join(`
|
|
281
917
|
|
|
282
|
-
`),language:"text",explanation:i.explanation};default:return{code:"",language:"text",explanation:`\u4E0D\u652F\u6301\u7684\u4EE3\u7801\u7C7B\u578B: ${
|
|
283
|
-
`)[0]}`)}const
|
|
918
|
+
`),language:"text",explanation:i.explanation};default:return{code:"",language:"text",explanation:`\u4E0D\u652F\u6301\u7684\u4EE3\u7801\u7C7B\u578B: ${e}`}}}generateMultipleCode(t){const{types:e,requirement:a,vueVersion:n=2,components:s=[],useMock:r=!0}=t,c=h(a),i=c.moduleName,p=c.title,d=t.modulePath||`src/pages/${i}`,u=[],f=[],y=s.length>0?s:c.suggestedComponents;for(const k of e){let m,g,l;switch(k){case"vue-component":m=P(a,n,y,r),g="index.vue",l=`${d}/index.vue`;break;case"javascript":m=$(a),g=`${i}.js`,l=`${d}/${i}.js`;break;case"scss":m=M(a,i),g=`${i}.scss`,l=`${d}/css/${i}.scss`;break;case"api-call":m=_(a,i,r),g="api.js",l=`${d}/api.js`;break;case"router":m=A(i,p),g="router.js",l=`${d}/router.js`;break;case"mock":m=E(i,a),g="mock.js",l=`${d}/mock.js`;break;default:continue}u.push({type:k,code:m.code,language:m.language,filename:g,relativePath:l}),f.push(`**${g}**: ${m.explanation.split(`
|
|
919
|
+
`)[0]}`)}const v=`
|
|
284
920
|
## \u751F\u6210\u7684\u6587\u4EF6\u7ED3\u6784
|
|
285
921
|
|
|
286
922
|
\`\`\`
|
|
287
|
-
${
|
|
288
|
-
\u251C\u2500\u2500 index.vue # Vue \u9875\u9762\u7EC4\u4EF6
|
|
923
|
+
${d}/
|
|
924
|
+
\u251C\u2500\u2500 index.vue # Vue \u9875\u9762\u7EC4\u4EF6 (${n===3?"Composition API":"Options API"})
|
|
289
925
|
\u251C\u2500\u2500 router.js # \u8DEF\u7531\u914D\u7F6E
|
|
290
926
|
\u251C\u2500\u2500 mock.js # Mock \u6570\u636E
|
|
291
927
|
\u2514\u2500\u2500 css/
|
|
292
|
-
\u2514\u2500\u2500 ${
|
|
928
|
+
\u2514\u2500\u2500 ${i}.scss # \u6837\u5F0F\u6587\u4EF6 (BEM \u89C4\u8303)
|
|
293
929
|
\`\`\`
|
|
294
930
|
|
|
931
|
+
## \u9875\u9762\u4FE1\u606F
|
|
932
|
+
|
|
933
|
+
- **\u9875\u9762\u7C7B\u578B**: ${c.type}
|
|
934
|
+
- **\u9875\u9762\u6807\u9898**: ${p}
|
|
935
|
+
- **\u6A21\u5757\u540D\u79F0**: ${i}
|
|
936
|
+
- **\u63A8\u8350\u7EC4\u4EF6**: ${y.join(", ")}
|
|
937
|
+
|
|
295
938
|
## \u6587\u4EF6\u8BF4\u660E
|
|
296
939
|
|
|
297
|
-
${
|
|
940
|
+
${f.join(`
|
|
298
941
|
|
|
299
942
|
`)}
|
|
300
943
|
|
|
301
944
|
## \u4F7F\u7528\u8BF4\u660E
|
|
302
945
|
|
|
303
|
-
1. \u5C06\u751F\u6210\u7684\u6587\u4EF6\u653E\u7F6E\u5230\
|
|
304
|
-
2. Mock \u6570\u636E\u4F1A\u81EA\u52A8\u88AB\u6846\u67B6\u52A0\u8F7D
|
|
946
|
+
1. \u5C06\u751F\u6210\u7684\u6587\u4EF6\u653E\u7F6E\u5230 \`${d}/\` \u76EE\u5F55
|
|
947
|
+
2. Mock \u6570\u636E\u4F1A\u81EA\u52A8\u88AB\u6846\u67B6\u52A0\u8F7D\uFF08\u5F00\u53D1\u73AF\u5883\uFF09
|
|
305
948
|
3. \u8DEF\u7531\u914D\u7F6E\u4F1A\u81EA\u52A8\u5408\u5E76\u5230 pages.json
|
|
306
|
-
4. \u6837\u5F0F\u6587\u4EF6\u901A\u8FC7
|
|
307
|
-
|
|
949
|
+
4. \u6837\u5F0F\u6587\u4EF6\u901A\u8FC7 \`@import './css/${i}.scss'\` \u5728 Vue \u7EC4\u4EF6\u4E2D\u5F15\u5165
|
|
950
|
+
5. \u5982\u9700\u8C03\u6574 API \u63A5\u53E3\uFF0C\u4FEE\u6539 mock.js \u4E2D\u7684 methodUrl \u548C api.js \u4E2D\u7684\u8BF7\u6C42\u8DEF\u5F84
|
|
951
|
+
`;return{files:u,explanation:v,modulePath:d}}generateFileHeader(t){return x(t)}generateVueTemplate(t){return w(t)}}const N=new G;export{G as CodeGenerator,N as codeGenerator};
|