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