2023-09-15 08:15:25 +08:00
|
|
|
import Renderer from '../renderer/loader.js'
|
2023-04-18 02:37:38 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 暂时保留对手工引用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) => {
|
2023-04-18 02:37:38 +08:00
|
|
|
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) => {
|
2023-04-18 02:37:38 +08:00
|
|
|
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
|
|
|
}
|
2023-04-18 02:37:38 +08:00
|
|
|
return ret.length > 0 ? ret : false
|
2023-04-16 14:42:45 +08:00
|
|
|
}
|
2023-09-15 08:15:25 +08:00
|
|
|
|
|
|
|
export default renderer
|