From 27482065d3b51739cfe778fdfdba2b4077f81675 Mon Sep 17 00:00:00 2001 From: Kokomi <102026640+yoimiya-kokomi@users.noreply.github.com> Date: Mon, 6 Mar 2023 08:38:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=83=85=E5=86=B5=E4=B8=8Bpu?= =?UTF-8?q?ppeteer=E6=B8=B2=E6=9F=93=E8=A7=A6=E5=8F=91=E7=9A=84=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 29 ++++++++++++++++++++++------- lib/config/log.js | 2 +- lib/puppeteer/puppeteer.js | 14 ++++++++++---- package.json | 1 - 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 399afed..f3febad 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ * 使用icqq登录,防止oicq可能出现的低版本问题(如只需要此特性,可使用[Yunzai-V3](https://gitee.com/yoimiya-kokomi/Yunzai-Bot) ) * 基础功能会保持与Yunzai同步迭代更新,如只需原版Yunzai无需切换 -## Miao-Yunzai后续计划no +## Miao-Yunzai后续计划 先刨坑,但也许会咕咕咕 @@ -18,7 +18,7 @@ * `miao-plugin`的帮助、设置、版本信息会升至`Miao-Yunzai`,以支持更多场景 * 一些底层会与`miao-plugin`做更深层的联动,以支持一些高级功能 * 基于面板信息的uid管理及认证 - * ck切换感知等 + * ck切换感知等 * 逐步实验一些新的特性 * 更完备的plugin基础能力支持 * 第三方 IM / Bot / WebAPI 对接或适配等 @@ -27,19 +27,34 @@ ## 使用方法 -> 环境准备: Windows or Linux,Node.js([版本至少v16以上](http://nodejs.cn/download/)),[Redis](https://redis.io/docs/getting-started/installation/) +> 环境准备: Windows or Linux,Node.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 ``` -2.安装[pnpm](https://pnpm.io/zh/installation),已安装的可以跳过 +``` +#使用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) ,已安装的可以跳过 ``` npm install pnpm -g diff --git a/lib/config/log.js b/lib/config/log.js index 6cf77dd..6d4833e 100644 --- a/lib/config/log.js +++ b/lib/config/log.js @@ -22,7 +22,7 @@ export default function setLog () { type: 'console', layout: { type: 'pattern', - pattern: '%[[YzBot][%d{hh:mm:ss.SSS}][%4.4p]%] %m' + pattern: '%[[MiaoYz][%d{hh:mm:ss.SSS}][%4.4p]%] %m' } }, command: { diff --git a/lib/puppeteer/puppeteer.js b/lib/puppeteer/puppeteer.js index 1bdd1d2..a7eb92d 100644 --- a/lib/puppeteer/puppeteer.js +++ b/lib/puppeteer/puppeteer.js @@ -8,6 +8,7 @@ import cfg from '../config/config.js' const _path = process.cwd() let puppeteer = {} + class Puppeteer { constructor () { this.browser = false @@ -37,7 +38,6 @@ class Puppeteer { this.html = {} this.watcher = {} - this.createDir('./temp') this.createDir('./temp/html') } @@ -51,7 +51,13 @@ class Puppeteer { createDir (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 || '' } - if (data.imgType == 'png') delete randData.quality + if (data.imgType === 'png') delete randData.quality buff = await body.screenshot(randData) @@ -212,7 +218,7 @@ class Puppeteer { /** 重启 */ restart () { /** 截图超过重启数时,自动关闭重启浏览器,避免生成速度越来越慢 */ - if (this.renderNum % this.restartNum == 0) { + if (this.renderNum % this.restartNum === 0) { if (this.shoting.length <= 0) { setTimeout(async () => { if (this.browser) { diff --git a/package.json b/package.json index fdb2482..3c126c2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "type": "module", "scripts": { "app": "node app.js", - "web-debug": "node app.js --web-debug", "dev": "node app.js dev", "web": "node ./lib/tools/web.js", "test": "node ./lib/tools/test.js",