diff --git a/renderers/puppeteer/config_default.yaml b/renderers/puppeteer/config_default.yaml index 3a2f542..fbc8de3 100644 --- a/renderers/puppeteer/config_default.yaml +++ b/renderers/puppeteer/config_default.yaml @@ -1,13 +1,14 @@ # 如需自定义,复制此文件为 config.yaml 进行配置 # 更新配置后需要重启 -# chromium 地址 +# chromium 地址,可填写系统的edge/chromium路径,例如(根据实际情况调整): +# chromiumPath: C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe chromiumPath: # headless headless: true -# puppeteer启动args +# puppeteer启动args,注意args的--前缀 args: - --disable-gpu - --disable-setuid-sandbox diff --git a/renderers/puppeteer/lib/puppeteer.js b/renderers/puppeteer/lib/puppeteer.js index a485b2e..8ba9eef 100644 --- a/renderers/puppeteer/lib/puppeteer.js +++ b/renderers/puppeteer/lib/puppeteer.js @@ -3,14 +3,13 @@ import os from 'node:os' import lodash from 'lodash' import template from 'art-template' import chokidar from 'chokidar' +import puppeteer from 'puppeteer' // 暂时保留对原config的兼容 -import cfg from '../../lib/config/config.js' +import cfg from '../../../lib/config/config.js' import { Data } from '#miao' const _path = process.cwd() -let puppeteer = {} - // mac地址 let mac = '' @@ -32,9 +31,9 @@ export default class PuppeteerRenderer { '--no-zygote' ]) } - if (cfg?.bot?.chromium_path || config.chromiumPath) { + if (config.chromiumPath || cfg?.bot?.chromium_path) { /** chromium其他路径 */ - this.config.executablePath = cfg.bot?.chromium_path || config.chromiumPath + this.config.executablePath = config.chromiumPath || cfg?.bot?.chromium_path } this.html = {} @@ -42,12 +41,6 @@ export default class PuppeteerRenderer { this.createDir('./temp/html') } - async initPupp () { - if (!lodash.isEmpty(puppeteer)) return puppeteer - puppeteer = (await import('puppeteer')).default - return puppeteer - } - createDir (dir) { if (!fs.existsSync(dir)) { let dirs = dir.split('/') @@ -64,7 +57,6 @@ export default class PuppeteerRenderer { * 初始化chromium */ async browserInit () { - await this.initPupp() if (this.browser) return this.browser if (this.lock) return false this.lock = true