Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update api and puppeteer plugin config #49

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,34 @@

可以通过 `ctx.puppeteer` 访问。

### puppeteer.launch()
### browser

- 返回值: `Promise<void>`
- 类型: `Browser`

启动并连接浏览器
浏览器实例

### puppeteer.close()
### puppeteer.stop()

- 返回值: `Promise<void>`

关闭浏览器并取消连接。

::: tip
在使用远程浏览器时,关闭浏览器不会关闭远程浏览器进程。
:::

### puppeteer.page()

- 返回值: `Promise<Page>`

创建一个新页面。

### puppeteer.svg(options?)

- 返回值: `SVG`

创建一个 SVG 实例。

### puppeteer.render(content, callback?)

- **content:** `string` 要渲染的 HTML
Expand Down
37 changes: 32 additions & 5 deletions docs/plugins/puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,32 @@

## 配置项

### executablePath
### 连接配置

#### remote

- 类型:`boolean`

是否使用远程浏览器。

#### endpoint

- 类型:`string`

远程浏览器的地址。

::: tip
支持 HTTP 或 WebSocket 协议。请在启动浏览器时指定 `--remote-debugging-port` 参数以开启远程调试和确定其端口。

- HTTP 协议:`http(s)://{host}:{port}`
- WebSocket 协议:`ws(s)://{host}:{port}/devtools/browser/{id}`
:::

#### headers

- 类型:`Record<string, string>`

#### executablePath

- 类型:`string`

Expand All @@ -14,28 +39,30 @@
目前仅支持 Chrome 和 Edge 的寻找。Firefox 用户请手动配置此项或者欢迎 pull request。
:::

### headless
#### headless

- 类型:`boolean`
- 默认值:`true`

是否开启[无头模式](https://developer.chrome.com/blog/headless-chrome/)。

### args
#### args

- 类型:`string[]`

额外的浏览器参数。Chromium 参数可以参考[这个页面](https://peter.sh/experiments/chromium-command-line-switches/)。

### defaultViewport
### 浏览器配置

#### defaultViewport

默认的设备缩放比率。有以下属性:

- width: `number` 视图宽度,默认为 800
- height: `number` 视图高度,默认为 600
- deviceScaleFactor: `number` 设备缩放比率,默认为 2

### ignoreHTTPSErrors
#### ignoreHTTPSErrors

- 类型:`boolean`
- 默认值:`false`
Expand Down
Loading