File tree Expand file tree Collapse file tree 5 files changed +12
-8
lines changed Expand file tree Collapse file tree 5 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -35,12 +35,12 @@ import EggCookies = require('egg-cookies');
35
35
import 'egg-onerror' ;
36
36
import 'egg-session' ;
37
37
import 'egg-i18n' ;
38
- import 'egg- watcher' ;
38
+ import '@eggjs/ watcher' ;
39
39
import 'egg-multipart' ;
40
40
import 'egg-security' ;
41
41
import 'egg-development' ;
42
42
import 'egg-logrotator' ;
43
- import 'egg- schedule' ;
43
+ import '@eggjs/ schedule' ;
44
44
import 'egg-static' ;
45
45
import 'egg-jsonp' ;
46
46
import 'egg-view' ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " egg" ,
3
- "version" : " 4.0.0-beta.3 " ,
3
+ "version" : " 4.0.0-beta.5 " ,
4
4
"engines" : {
5
5
"node" : " >= 18.19.0"
6
6
},
24
24
"@eggjs/core" : " ^6.1.0" ,
25
25
"@eggjs/schedule" : " ^5.0.1" ,
26
26
"@eggjs/utils" : " ^4.0.2" ,
27
+ "@eggjs/watcher" : " ^4.0.0" ,
27
28
"@types/accepts" : " ^1.3.5" ,
28
29
"accepts" : " ^1.3.8" ,
29
30
"cache-content-type" : " ^2.0.0" ,
42
43
"egg-session" : " ^3.3.0" ,
43
44
"egg-static" : " ^2.2.0" ,
44
45
"egg-view" : " ^2.1.3" ,
45
- "egg-watcher" : " ^3.1.1" ,
46
46
"extend2" : " ^4.0.0" ,
47
47
"graceful" : " ^1.1.0" ,
48
48
"is-type-of" : " ^2.1.0" ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ order: 9
11
11
- 如何编写一个插件?
12
12
13
13
接下来我们就来逐一讨论。
14
+
14
15
## 为什么要插件
15
16
16
17
我们在使用 Koa 中间件过程中发现了下面一些问题:
@@ -35,12 +36,13 @@ order: 9
35
36
- 当遇到上一节提到的场景时,应用需引入插件。
36
37
- 插件本身可以包含中间件。
37
38
- 多个插件可以包装为一个[ 上层框架] ( ../advanced/framework.md ) 。
39
+
38
40
## 使用插件
39
41
40
42
插件通常通过 npm 模块的方式进行复用:
41
43
42
44
``` bash
43
- $ npm i egg-mysql --save
45
+ npm i egg-mysql --save
44
46
```
45
47
46
48
** 注意:我们推荐通过 ` ^ ` 的方式引入依赖,并且强烈不建议锁定版本。**
@@ -118,7 +120,7 @@ exports.dev = {
118
120
119
121
** 注意:**
120
122
121
- - ` plugin.default.js ` 不存在
123
+ - ` plugin.default.js ` 不存在
122
124
- ** 只能在应用层使用,框架层请勿使用。**
123
125
124
126
### package 和 path
@@ -135,6 +137,7 @@ exports.mysql = {
135
137
path: path .join (__dirname , ' ../lib/plugin/egg-mysql' ),
136
138
};
137
139
```
140
+
138
141
## 插件配置
139
142
140
143
插件一般会包含自己的默认配置。应用开发者可以在 ` config.default.js ` 中覆盖对应的配置:
@@ -153,6 +156,7 @@ exports.mysql = {
153
156
```
154
157
155
158
具体的合并规则可以参见[ 配置] ( ./config.md ) 。
159
+
156
160
## 插件列表
157
161
158
162
- 框架默认内置了企业级应用[ 常用的插件] ( https://eggjs.org/zh-cn/plugins/ ) :
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export default {
41
41
*/
42
42
watcher : {
43
43
enable : true ,
44
- package : 'egg- watcher' ,
44
+ package : '@eggjs/ watcher' ,
45
45
} ,
46
46
47
47
/**
Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ export class EggApplicationCore extends EggCore {
221
221
* - {Number} [maxWaitTime|30000] - leader startup max time, default is 30 seconds
222
222
* @return {ClientWrapper } wrapper
223
223
*/
224
- cluster ( clientClass : unknown , options : object ) {
224
+ cluster ( clientClass : unknown , options ? : object ) {
225
225
const clientClassOptions = {
226
226
...this . config . clusterClient ,
227
227
...options ,
You can’t perform that action at this time.
0 commit comments