fix chromium分片截图未导入common (#57)

Co-authored-by: Kokomi <102026640+yoimiya-kokomi@users.noreply.github.com>
This commit is contained in:
story-x 2023-04-11 01:51:43 +08:00 committed by GitHub
parent b22b70e9e1
commit 85b9d03877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 14 deletions

View File

@ -4,6 +4,7 @@ import lodash from 'lodash'
import template from 'art-template'
import chokidar from 'chokidar'
import cfg from '../config/config.js'
import common from '../common/common.js'
const _path = process.cwd()
@ -101,7 +102,6 @@ class Puppeteer {
logger.error('puppeteer Chromium 尝试连接已有实例失败')
}
if (!this.browser || !connectFlag) {
// 如果没有实例初始化puppeteer
this.browser = await puppeteer.launch(this.config).catch((err, trace) => {
@ -282,19 +282,19 @@ class Puppeteer {
quality: 90
}
if (i != 1 && i == num) {
if (i !== 1 && i === num) {
await page.setViewport({
width: boundingBox.width,
height: parseInt(boundingBox.height) - pageHeight * (num - 1)
})
}
if (i != 1 && i <= num) {
if (i !== 1 && i <= num) {
await page.evaluate(() => window.scrollBy(0, 7000))
}
let buff
if (num == 1) {
if (num === 1) {
buff = await body.screenshot(randData)
} else {
buff = await page.screenshot(randData)