修正情况下puppeteer渲染触发的路径错误

This commit is contained in:
Kokomi 2023-03-06 08:38:31 +08:00
parent fb829b2daf
commit 27482065d3
4 changed files with 33 additions and 13 deletions

View File

@ -9,7 +9,7 @@
* 使用icqq登录防止oicq可能出现的低版本问题如只需要此特性可使用[Yunzai-V3](https://gitee.com/yoimiya-kokomi/Yunzai-Bot) ) * 使用icqq登录防止oicq可能出现的低版本问题如只需要此特性可使用[Yunzai-V3](https://gitee.com/yoimiya-kokomi/Yunzai-Bot) )
* 基础功能会保持与Yunzai同步迭代更新如只需原版Yunzai无需切换 * 基础功能会保持与Yunzai同步迭代更新如只需原版Yunzai无需切换
## Miao-Yunzai后续计划no ## Miao-Yunzai后续计划
先刨坑,但也许会咕咕咕 先刨坑,但也许会咕咕咕
@ -29,14 +29,29 @@
> 环境准备: Windows or LinuxNode.js [版本至少v16以上](http://nodejs.cn/download/) [Redis](https://redis.io/docs/getting-started/installation/ ) > 环境准备: Windows or LinuxNode.js [版本至少v16以上](http://nodejs.cn/download/) [Redis](https://redis.io/docs/getting-started/installation/ )
1.克隆项目 1.克隆项目并安装miao-plugin
请根据网络情况选择Github安装或Gitee安装
``` ```
git clone --depth=1 -b main https://github.com/Le-niao/Yunzai-Bot.git #使用 Github
git clone --depth=1 https://github.com/yoimiya-kokomi/Miao-Yunzai.git
#使用Gitee
git clone --depth=1 https://gitee.com/yoimiya-kokomi/Miao-Yunzai.git
``` ```
``` ```
cd Yunzai-Bot #进入Yunzai目录 #进入Yunzai目录
cd Miao-Yunzai
```
```
#使用Github
git clone --depth=1 https://github.com/yoimiya-kokomi/miao-plugin.git ./plugins/miao-plugin/
#使用Gitee
git clone --depth=1 https://gitee.com/yoimiya-kokomi/miao-plugin.git ./plugins/miao-plugin/
``` ```
2.安装[pnpm](https://pnpm.io/zh/installation) ,已安装的可以跳过 2.安装[pnpm](https://pnpm.io/zh/installation) ,已安装的可以跳过

View File

@ -22,7 +22,7 @@ export default function setLog () {
type: 'console', type: 'console',
layout: { layout: {
type: 'pattern', type: 'pattern',
pattern: '%[[YzBot][%d{hh:mm:ss.SSS}][%4.4p]%] %m' pattern: '%[[MiaoYz][%d{hh:mm:ss.SSS}][%4.4p]%] %m'
} }
}, },
command: { command: {

View File

@ -8,6 +8,7 @@ import cfg from '../config/config.js'
const _path = process.cwd() const _path = process.cwd()
let puppeteer = {} let puppeteer = {}
class Puppeteer { class Puppeteer {
constructor () { constructor () {
this.browser = false this.browser = false
@ -37,7 +38,6 @@ class Puppeteer {
this.html = {} this.html = {}
this.watcher = {} this.watcher = {}
this.createDir('./temp')
this.createDir('./temp/html') this.createDir('./temp/html')
} }
@ -51,7 +51,13 @@ class Puppeteer {
createDir (dir) { createDir (dir) {
if (!fs.existsSync(dir)) { if (!fs.existsSync(dir)) {
fs.mkdirSync(dir) let dirs = dir.split('/')
for (let idx = 1; idx <= dirs.length; idx++) {
let temp = dirs.slice(0, idx).join('/')
if (!fs.existsSync(temp)) {
fs.mkdirSync(temp)
}
}
} }
} }
@ -129,7 +135,7 @@ class Puppeteer {
path: data.path || '' path: data.path || ''
} }
if (data.imgType == 'png') delete randData.quality if (data.imgType === 'png') delete randData.quality
buff = await body.screenshot(randData) buff = await body.screenshot(randData)
@ -212,7 +218,7 @@ class Puppeteer {
/** 重启 */ /** 重启 */
restart () { restart () {
/** 截图超过重启数时,自动关闭重启浏览器,避免生成速度越来越慢 */ /** 截图超过重启数时,自动关闭重启浏览器,避免生成速度越来越慢 */
if (this.renderNum % this.restartNum == 0) { if (this.renderNum % this.restartNum === 0) {
if (this.shoting.length <= 0) { if (this.shoting.length <= 0) {
setTimeout(async () => { setTimeout(async () => {
if (this.browser) { if (this.browser) {

View File

@ -6,7 +6,6 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"app": "node app.js", "app": "node app.js",
"web-debug": "node app.js --web-debug",
"dev": "node app.js dev", "dev": "node app.js dev",
"web": "node ./lib/tools/web.js", "web": "node ./lib/tools/web.js",
"test": "node ./lib/tools/test.js", "test": "node ./lib/tools/test.js",