Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Dec 4, 2023
1 parent 28ddd01 commit 03739b2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 6 deletions.
3 changes: 0 additions & 3 deletions docs/dev-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ Another thing to note is that goja natively supports most of the `es6+` syntax,
When an event is triggered, the script file specified in the `entry` field will be executed. The script file in the sample project is as follows:

```js
import gopeed from "gopeed";

gopeed.events.onResolve((ctx) => {
ctx.res = {
name: "example",
Expand All @@ -212,7 +210,6 @@ gopeed.events.onResolve((ctx) => {

Next, let's introduce the meaning of each field one by one:

- `import gopeed from "gopeed"`: Here, the `gopeed` object is imported, but it should be noted that `gopeed` is a built-in global variable. The import here is just for type prompts, and it is also okay not to import.
- `gopeed.events.onResolve`: Here, the `onResolve` event is registered, and the method inside is the specific logic of the extension.
- `ctx`: Event context, which contains some information about the current event. In the `onResolve` event, `ctx` contains the following fields:
- `req`: Request information, including the url and headers of the resource.
Expand Down
3 changes: 0 additions & 3 deletions docs/zh/dev-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ Gopeed 扩展脚本引擎是由[goja](https://github.com/dop251/goja)来实现
每当事件触发时,会运行`entry`字段指定的脚本文件,示例项目中的脚本文件如下:

```js
import gopeed from "gopeed";

gopeed.events.onResolve((ctx) => {
ctx.res = {
name: "example",
Expand All @@ -192,7 +190,6 @@ gopeed.events.onResolve((ctx) => {

接下来,我们逐一介绍一下脚本的内容:

- `import gopeed from "gopeed"`:这里是引入了`gopeed`对象,但是需要说明的一点是`gopeed`是内置的全局变量,这里引入只是为了类型提示,不引入也是没问题的。
- `gopeed.events.onResolve`:这里是注册`onResolve`事件,方法里面就是扩展的具体逻辑了。
- `ctx`:事件上下文,包含了当前事件的一些信息,在`onResolve`事件中,`ctx`包含了以下字段:
- `req`:请求信息,包含了资源的 url、headers 等等。
Expand Down

0 comments on commit 03739b2

Please sign in to comment.