We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
@koishijs/plugin-puppeteer
browser.viewPort
以上是 browser.viewPort 的默认值。
我设置为如下配置:
puppeteer: browser: defaultViewport: width: 1920 height: 1080
但是截图仍然是 800x600 的。
800x600
根据上述描述可以轻易重现。
截图的默认视口大小应为 1920x1080。
1920x1080
No response
koishi/plugins/puppeteer/src/index.ts
Lines 22 to 29 in 1fad834
我查看过相关源代码,问题可能出在 23 行的 viewPort。
viewPort
Lines 47 to 49 in 1fad834
48 行直接拿 config 传入 puppeteer.launch 作为 options 参数。
puppeteer.launch
options
https://github.com/puppeteer/puppeteer/blob/24e1469e15bab88031650dcdd890edf499fb5c25/src/common/BrowserConnector.ts#L31-L50
但是 puppeteer.launch 中 options 对应的设置 viewPort 的参数名应该是 defaultViewport。
defaultViewport
所以其实简单 fix 的话,用以下的 patch 就能修复。
diff --git a/plugins/puppeteer/src/index.ts b/plugins/puppeteer/src/index.ts index cb4cec3..27d189b 100644 --- a/plugins/puppeteer/src/index.ts +++ b/plugins/puppeteer/src/index.ts @@ -21,7 +21,7 @@ type LaunchOptions = Parameters<typeof puppeteer.launch>[0] const LaunchOptions = Schema.object({ executablePath: Schema.string().description('Chromium 可执行文件的路径。缺省时将自动从系统中寻找。'), - viewPort: Schema.object({ + defaultViewport: Schema.object({ width: Schema.natural().description('默认的视图宽度。').default(800), height: Schema.natural().description('默认的视图高度。').default(600), deviceScaleFactor: Schema.number().min(0).description('默认的设备缩放比率。').default(2),
如果认可这个 fix,我可以提一个 PR.
The text was updated successfully, but these errors were encountered:
非常感谢!似乎是因为 puppeteer 更新导致了 API 变更。
Sorry, something went wrong.
868681d
No branches or pull requests
Describe the bug
以上是
browser.viewPort
的默认值。我设置为如下配置:
但是截图仍然是
800x600
的。Steps to reproduce
根据上述描述可以轻易重现。
Expected behavior
截图的默认视口大小应为
1920x1080
。Screenshots
No response
Versions
Additional context
koishi/plugins/puppeteer/src/index.ts
Lines 22 to 29 in 1fad834
我查看过相关源代码,问题可能出在 23 行的
viewPort
。koishi/plugins/puppeteer/src/index.ts
Lines 47 to 49 in 1fad834
48 行直接拿 config 传入
puppeteer.launch
作为options
参数。https://github.com/puppeteer/puppeteer/blob/24e1469e15bab88031650dcdd890edf499fb5c25/src/common/BrowserConnector.ts#L31-L50
但是
puppeteer.launch
中options
对应的设置viewPort
的参数名应该是defaultViewport
。所以其实简单 fix 的话,用以下的 patch 就能修复。
如果认可这个 fix,我可以提一个 PR.
The text was updated successfully, but these errors were encountered: