Skip to content

Commit

Permalink
docs: modify the docs to make them better (#5292)
Browse files Browse the repository at this point in the history
Modify the docs to make them easier to understand in Chinese.
  • Loading branch information
ottomao committed Feb 8, 2024
1 parent d771fdf commit 77b5249
Show file tree
Hide file tree
Showing 35 changed files with 2,315 additions and 2,533 deletions.
181 changes: 88 additions & 93 deletions site/docs/advanced/cluster-client.zh-CN.md

Large diffs are not rendered by default.

146 changes: 71 additions & 75 deletions site/docs/advanced/framework.zh-CN.md

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions site/docs/advanced/loader-update.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ order: 6

## beforeStart 函数替代

我们通常在 app.js 中通过 `module.export` 中传入的 `app` 参数进行此函数的操作,一个典型的例子:
我们通常在 `app.js` 中通过 `module.exports` 中传入的 `app` 参数进行此函数的操作,一个典型的例子:

```js
module.exports = (app) => {
Expand All @@ -20,7 +20,7 @@ module.exports = (app) => {
};
```

现在升级之后的写法略有改变 —— 我们可以直接在 `app.js` 中用类方法的形式体现出来对于应用开发而言,我们应该写在 `willReady` 方法中;对于插件则写在 `didLoad` 中。形式如下:
现在升级之后的写法略有改变 —— 我们可以直接在 `app.js` 中用类方法的形式体现出来对于应用开发而言,应该写在 `willReady` 方法中;对于插件则写在 `didLoad` 中。形式如下:

```js
// app.js 或 agent.js 文件:
Expand All @@ -30,17 +30,18 @@ class AppBootHook {
}

async didLoad() {
// 请将你的插件项目中 app.beforeStart 中的代码置于此处
// 请将你的插件项目中 app.beforeStart 中的代码置于此处
}

async willReady() {
// 请将你的应用项目中 app.beforeStart 中的代码置于此处
// 请将你的应用项目中 app.beforeStart 中的代码置于此处
}
}

module.exports = AppBootHook;
```


## ready 函数替代

同样地,我们之前在 `app.ready` 中处理我们的逻辑:
Expand All @@ -63,13 +64,14 @@ class AppBootHook {
}

async didReady() {
// 请将您的 app.ready 中的代码置于此处
// 请将你的 app.ready 中的代码置于此处
}
}

module.exports = AppBootHook;
```


## beforeClose 函数替代

原先的 `app.beforeClose` 如以下形式:
Expand All @@ -92,11 +94,12 @@ class AppBootHook {
}

async beforeClose() {
// 请将您的 app.beforeClose 中的代码置于此处
// 请将你的 app.beforeClose 中的代码置于此处
}
}
module.exports = AppBootHook;
```

## 其它说明

本教程只是一对一地讲了替换方法,便于开发者们快速上手进行替换若想要具体了解整个 Loader 原理以及生命周期的完整函数版本,请参考[加载器](./loader.md)[启动自定义](../basics/app-start.md)两篇文章。
本教程只是一对一地讲了替换方法,便于开发者们快速上手进行替换若想要具体了解整个 Loader 原理以及生命周期的完整函数版本,请参考[加载器](./loader.md)》和《[启动自定义](../basics/app-start.md)两篇文章。
339 changes: 168 additions & 171 deletions site/docs/advanced/loader.zh-CN.md

Large diffs are not rendered by default.

Loading

0 comments on commit 77b5249

Please sign in to comment.