diff --git a/adapter/render.js b/adapter/render.js index 4963368..122e97f 100644 --- a/adapter/render.js +++ b/adapter/render.js @@ -22,3 +22,22 @@ export async function render (app = '', tpl = '', data = {}, imgType = 'jpeg') { data.pluResPath = data._res_path return await puppeteer.screenshot(`${plugin}/${app}/${tpl}`, data) } + +export function getRender () { + return async function render (app = '', tpl = '', data = {}, imgType = 'jpeg') { + // 在data中保存plugin信息 + data._plugin = plugin + if (lodash.isUndefined(data._res_path)) { + data._res_path = `../../../../../plugins/${plugin}/resources/` + } + if(imgType == "png"){ + data.omitBackground=true; + } + data.imgType=imgType; + Data.createDir(_path + '/data/', `html/${plugin}/${app}/${tpl}`) + data.saveId = data.saveId || data.save_id || tpl + data.tplFile = `./plugins/${plugin}/resources/${app}/${tpl}.html` + data.pluResPath = data._res_path + return await puppeteer.screenshot(`${plugin}/${app}/${tpl}`, data) +} +} \ No newline at end of file diff --git a/apps/Note.js b/apps/Note.js index 711c83f..7712653 100644 --- a/apps/Note.js +++ b/apps/Note.js @@ -16,6 +16,7 @@ import { import moment from 'moment'; import MysApi from "../model/mys/mysApi.js"; import utils from "../model/mys/utils.js"; +import {getRender} from "../adapter/render.js" const _path = process.cwd(); let role_user = Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/resources/dailyNote/json/`, "dispatch_time"); @@ -352,7 +353,13 @@ export async function DailyNoteTask() { redis.set(sendkey, "1", { EX: sendCD }); - // await Note(e, getPluginRender("xiaoyao-cvs-plugin")); + if(isV3){ + await Note(e, {render:await getRender()}); + }else{ + let {getPluginRender} = await import(`file://${_path}/lib/render.js`); + await Note(e, {render:await getPluginRender()}); + } + } } } @@ -361,6 +368,7 @@ export async function pokeNote(e,{render}) { if (!Cfg.get("note.poke")) { return false; } + // return await Note(e,{render:await getRender()}, "poke"); return await Note(e,{render}, "poke"); }