Miao-Yunzai/lib/puppeteer/puppeteer.js

23 lines
641 B
JavaScript
Raw Permalink Normal View History

2023-09-15 08:15:25 +08:00
import Renderer from '../renderer/loader.js'
/**
* 暂时保留对手工引用puppeteer.js的兼容
* 后期会逐步废弃
* 只提供截图及分片截图功能
*/
2023-09-19 03:55:29 +08:00
let renderer = Renderer.getRenderer()
2023-09-15 08:15:25 +08:00
renderer.screenshot = async (name, data) => {
let img = await renderer.render(name, data)
return img ? segment.image(img) : img
2023-09-15 08:15:25 +08:00
}
renderer.screenshots = async (name, data) => {
data.multiPage = true
let imgs = await renderer.render(name, data) || []
let ret = []
for (let img of imgs) {
2023-09-15 08:15:25 +08:00
ret.push(img ? segment.image(img) : img)
2023-03-04 14:30:13 +08:00
}
return ret.length > 0 ? ret : false
}
2023-09-15 08:15:25 +08:00
export default renderer