fix chromium分片截图未导入common (#57)
Co-authored-by: Kokomi <102026640+yoimiya-kokomi@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									b22b70e9e1
								
							
						
					
					
						commit
						85b9d03877
					
				| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue