📅  最后修改于: 2022-03-11 15:01:10.246000             🧑  作者: Mango
if (!this.browser) {
this.browser = await puppeteer.launch(this.OPT)
const pages: puppeteer.Page[] = await this.browser.pages()
// close chromium by catching 'targetdestryed'
this.browser.on('targetdestroyed', async () => {
if (this.browser) {
const pages: puppeteer.Page[] = await this.browser.pages()
if (pages.length === 0) {
process.exit(0)
}
}
})
}