vscode下的egg用户片段
{
// 控制器
"egg.Controller": {
"prefix": "eggco",
"body": [
"'use strict';",
"const Controller = require('egg').Controller;",
"/** @description $2 */",
"class ${1:Demo}Controller extends Controller {",
" $0",
"}",
"module.exports = ${1:Demo}Controller;"
],
"description": "Egg Controlelr"
},
// 控制器方法
"egg.Controller.method":{
"prefix": "eggcom",
"body": [
"/** @description $2 */",
"async $1() {",
" const { ctx } = this;",
" $0",
" ctx.body = '';",
"}"
],
"description": "Egg Controlelr Method"
},
// 服务
"egg.Service": {
"prefix": "eggse",
"body": [
"'use strict';",
"const Service = require('egg').Service;",
"/** @description $2 */",
"class ${1:Demo}Service extends Service {",
" $0",
"}",
"module.exports = ${1:Demo}Service;"
],
"description": "Egg Service"
},
// 服务方法
"egg.Service.Method": {
"prefix": "eggsem",
"body": [
"/** @description $2 */",
"async $1() {",
" const { app } = this;",
" $0",
" return {};",
"}"
],
"description": "Egg Service Method"
},
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
上次更新: 2023/09/22, 16:54:32