From 832c72da84ff2f305d84b3e81a60f2c881c04c7c Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Wed, 17 Aug 2022 23:07:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=88=AA=E5=9B=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapter/render.js | 5 ++++- components/Common.js | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/adapter/render.js b/adapter/render.js index 3ee70c2..4963368 100644 --- a/adapter/render.js +++ b/adapter/render.js @@ -9,10 +9,13 @@ const _path = process.cwd() export 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` diff --git a/components/Common.js b/components/Common.js index 55e37a0..c2238e0 100644 --- a/components/Common.js +++ b/components/Common.js @@ -1,15 +1,15 @@ import { Cfg } from "./index.js"; import { segment } from "oicq"; -import { currentVersion, yunzaiVersion } from "./Changelog.js"; -import {render1} from "../apps/render.js"; +import { currentVersion, yunzaiVersion,isV3 } from "./Changelog.js"; export const render = async function (path, params, cfg) { let paths = path.split("/"); let { render, e } = cfg; let _layout_path = process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/"; let layout_path= process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/common/layout/"; - let base64 = await render1(paths[0], paths[1], { + let base64 = await render(paths[0], paths[1], { ...params, _layout_path, + _tpl_path: process.cwd() + '/plugins/xiaoyao-cvs-plugin/resources/common/tpl/', defaultLayout: layout_path + "default.html", elemLayout: layout_path + "elem.html", sys: { @@ -17,21 +17,21 @@ export const render = async function (path, params, cfg) { copyright: `Created By Yunzai-Bot${yunzaiVersion} & xiaoyao-cvs-Plugin${currentVersion}` } },"png"); - + let ret = true if (base64) { - e.reply(segment.image(`base64://${base64}`)); + ret = isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`)) } - - return true; + return cfg.retMsgId ? ret : true } export const render_path = async function (path, params, cfg,path_) { let paths = path.split("/"); let { render, e } = cfg; let _layout_path = process.cwd() + path_; - let base64 = await render1(paths[0], paths[1], { + let base64 = await render(paths[0], paths[1], { ...params, _layout_path, + _tpl_path: process.cwd() + '/plugins/xiaoyao-cvs-plugin/resources/common/tpl/', defaultLayout: _layout_path + "default.html", elemLayout: _layout_path + "elem.html", sys: { @@ -39,12 +39,11 @@ export const render_path = async function (path, params, cfg,path_) { copyright: `Created By Yunzai-Bot${yunzaiVersion} & xiaoyao-cvs-Plugin${currentVersion}` } }); - + let ret = true if (base64) { - e.reply(segment.image(`base64://${base64}`)); + ret = isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`)) } - - return true; + return cfg.retMsgId ? ret : true }