修复图片生成失败 (#258)

This commit is contained in:
戏舞天殇 2023-09-19 03:55:29 +08:00 committed by GitHub
parent 4169d3d23d
commit 4f1f3c2105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import Renderer from '../renderer/loader.js'
* 后期会逐步废弃
* 只提供截图及分片截图功能
*/
let renderer = Renderer.getRenderer('puppeteer')
let renderer = Renderer.getRenderer()
renderer.screenshot = async (name, data) => {
let img = await renderer.render(name, data)
return img ? segment.image(img) : img

View File

@ -5,8 +5,8 @@ import puppeteer from 'puppeteer'
// 暂时保留对原config的兼容
import cfg from '../../../lib/config/config.js'
import { Data } from '#miao'
import path from 'path'
const _path = process.cwd()
// mac地址
let mac = ''
@ -176,7 +176,7 @@ export default class Puppeteer extends Renderer {
try {
const page = await this.browser.newPage()
let pageGotoParams = lodash.extend({ timeout: 120000 }, data.pageGotoParams || {})
await page.goto('file://' + path.resolve(savePath), pageGotoParams)
await page.goto(`file://${_path}${lodash.trim(savePath, '.')}`, pageGotoParams)
let body = await page.$('#container') || await page.$('body')
// 计算页面高度