From 106defd3804c0a4e26df72e6c67053515a829a5d Mon Sep 17 00:00:00 2001 From: Kokomi <102026640+yoimiya-kokomi@users.noreply.github.com> Date: Fri, 10 Mar 2023 04:38:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`#=E7=89=88=E6=9C=AC`?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 +++++++++++ lib/plugins/runtime.js | 18 +++++++++++++++++- lib/puppeteer/puppeteer.js | 19 ++++++++++++------- plugins/example/进群退群通知.js | 1 - plugins/genshin/apps/gcLog.js | 1 - plugins/genshin/apps/material.js | 1 - plugins/genshin/apps/strategy.js | 1 - plugins/genshin/model/mysNews.js | 1 - plugins/genshin/model/roleDetail.js | 1 - 9 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2ff6b03 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# 3.0.1 + +* 添加`#版本`命令,用于查看更新记录 + +# 3.0.0 + +* 用icqq进行登录 + +# 3.0.0 + +* 我的 \ No newline at end of file diff --git a/lib/plugins/runtime.js b/lib/plugins/runtime.js index f2e4a60..5cf3e76 100644 --- a/lib/plugins/runtime.js +++ b/lib/plugins/runtime.js @@ -12,6 +12,7 @@ import cfg from '../config/config.js' import MysApi from '../../plugins/genshin/model/mys/mysApi.js' import MysInfo from '../../plugins/genshin/model/mys/mysInfo.js' import puppeteer from '../puppeteer/puppeteer.js' +import { Version } from '#miao' /** * 常用的处理方法 @@ -140,16 +141,31 @@ export default class Runtime { mkdir(`html/${plugin}/${path}`) // 自动计算pluResPath let pluResPath = `../../../${lodash.repeat('../', paths.length)}plugins/${plugin}/resources/` + let miaoResPath = `../../../${lodash.repeat('../', paths.length)}plugins/miao-plugin/resources/` + const layoutPath = process.cwd() + '/plugins/miao-plugin/resources/common/layout/' // 渲染data data = { + sys: { + scale: 1 + }, + /** miao 相关参数 **/ + copyright: `Created By Miao-Yunzai${Version.yunzai} `, + _res_path: pluResPath, + _miao_path: miaoResPath, + _tpl_path: process.cwd() + '/plugins/miao-plugin/resources/common/tpl/', + defaultLayout: layoutPath + 'default.html', + elemLayout: layoutPath + 'elem.html', + ...data, + + /** 默认参数 **/ _plugin: plugin, _htmlPath: path, pluResPath, tplFile: `./plugins/${plugin}/resources/${path}.html`, saveId: data.saveId || data.save_id || paths[paths.length - 1], pageGotoParams: { - waitUntil: 'networkidle0' + waitUntil: 'networkidle2' } } // 处理beforeRender diff --git a/lib/puppeteer/puppeteer.js b/lib/puppeteer/puppeteer.js index a7eb92d..382a941 100644 --- a/lib/puppeteer/puppeteer.js +++ b/lib/puppeteer/puppeteer.js @@ -1,7 +1,6 @@ import template from 'art-template' import fs from 'fs' import lodash from 'lodash' -import { segment } from 'icqq' import chokidar from 'chokidar' import cfg from '../config/config.js' @@ -22,9 +21,7 @@ class Puppeteer { headless: true, args: [ '--disable-gpu', - '--disable-dev-shm-usage', '--disable-setuid-sandbox', - '--no-first-run', '--no-sandbox', '--no-zygote', '--single-process' @@ -73,11 +70,19 @@ class Puppeteer { logger.mark('puppeteer Chromium 启动中...') /** 初始化puppeteer */ - this.browser = await puppeteer.launch(this.config).catch((err) => { - logger.error(err.toString()) - if (String(err).includes('correct Chromium')) { - logger.error('没有正确安装Chromium,可以尝试执行安装命令:node ./node_modules/puppeteer/install.js') + this.browser = await puppeteer.launch(this.config).catch((err, trace) => { + let errMsg = err.toString() + (trace ? trace.toString() : '') + if (typeof err == 'object') { + logger.error(JSON.stringify(err)) + } else { + logger.error(err.toString()) + if (errMsg.includes('Could not find Chromium')) { + logger.error('没有正确安装Chromium,可以尝试执行安装命令:node ./node_modules/puppeteer/install.js') + } else if (errMsg.includes('libatk-bridge')) { + logger.error('没有正确安装Chromium,可尝试执行 sudo yum install -y chromium') + } } + console.log(err, trace) }) this.lock = false diff --git a/plugins/example/进群退群通知.js b/plugins/example/进群退群通知.js index 87ac053..8607824 100644 --- a/plugins/example/进群退群通知.js +++ b/plugins/example/进群退群通知.js @@ -1,5 +1,4 @@ import plugin from '../../lib/plugins/plugin.js' -import { segment } from 'icqq' export class newcomer extends plugin { constructor () { super({ diff --git a/plugins/genshin/apps/gcLog.js b/plugins/genshin/apps/gcLog.js index 4f79f97..1f769f8 100644 --- a/plugins/genshin/apps/gcLog.js +++ b/plugins/genshin/apps/gcLog.js @@ -4,7 +4,6 @@ import fs from 'node:fs' import GachaLog from '../model/gachaLog.js' import ExportLog from '../model/exportLog.js' import LogCount from '../model/logCount.js' -import { segment } from 'icqq' const _path = process.cwd() + '/plugins/genshin' diff --git a/plugins/genshin/apps/material.js b/plugins/genshin/apps/material.js index 2b7f87c..64913c7 100644 --- a/plugins/genshin/apps/material.js +++ b/plugins/genshin/apps/material.js @@ -2,7 +2,6 @@ import plugin from '../../../lib/plugins/plugin.js' import gsCfg from '../model/gsCfg.js' import common from '../../../lib/common/common.js' -import { segment } from 'icqq' import fs from 'node:fs' import fetch from 'node-fetch' diff --git a/plugins/genshin/apps/strategy.js b/plugins/genshin/apps/strategy.js index 096dfbe..03d5e72 100644 --- a/plugins/genshin/apps/strategy.js +++ b/plugins/genshin/apps/strategy.js @@ -2,7 +2,6 @@ import plugin from '../../../lib/plugins/plugin.js' import gsCfg from '../model/gsCfg.js' import common from '../../../lib/common/common.js' -import { segment } from 'icqq' import lodash from 'lodash' import fs from 'node:fs' import fetch from 'node-fetch' diff --git a/plugins/genshin/model/mysNews.js b/plugins/genshin/model/mysNews.js index 1d54248..0059f6e 100644 --- a/plugins/genshin/model/mysNews.js +++ b/plugins/genshin/model/mysNews.js @@ -3,7 +3,6 @@ import fetch from 'node-fetch' import lodash from 'lodash' import puppeteer from '../../../lib/puppeteer/puppeteer.js' import common from '../../../lib/common/common.js' -import { segment } from 'icqq' import gsCfg from '../model/gsCfg.js' const _path = process.cwd() diff --git a/plugins/genshin/model/roleDetail.js b/plugins/genshin/model/roleDetail.js index 3744485..7277d57 100644 --- a/plugins/genshin/model/roleDetail.js +++ b/plugins/genshin/model/roleDetail.js @@ -2,7 +2,6 @@ import base from './base.js' import MysInfo from './mys/mysInfo.js' import gsCfg from './gsCfg.js' import lodash from 'lodash' -import { segment } from 'icqq' import fs from 'node:fs' import fetch from 'node-fetch' import common from '../../../lib/common/common.js'