2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00

兼容浏览器页面截图问题

This commit is contained in:
Ctrlcvs 2022-08-17 23:07:34 +08:00
parent 156db9a23c
commit 832c72da84
2 changed files with 15 additions and 13 deletions

View File

@ -9,10 +9,13 @@ const _path = process.cwd()
export async function render (app = '', tpl = '', data = {}, imgType = 'jpeg') { export async function render (app = '', tpl = '', data = {}, imgType = 'jpeg') {
// 在data中保存plugin信息 // 在data中保存plugin信息
data._plugin = plugin data._plugin = plugin
if (lodash.isUndefined(data._res_path)) { if (lodash.isUndefined(data._res_path)) {
data._res_path = `../../../../../plugins/${plugin}/resources/` data._res_path = `../../../../../plugins/${plugin}/resources/`
} }
if(imgType == "png"){
data.omitBackground=true;
}
data.imgType=imgType;
Data.createDir(_path + '/data/', `html/${plugin}/${app}/${tpl}`) Data.createDir(_path + '/data/', `html/${plugin}/${app}/${tpl}`)
data.saveId = data.saveId || data.save_id || tpl data.saveId = data.saveId || data.save_id || tpl
data.tplFile = `./plugins/${plugin}/resources/${app}/${tpl}.html` data.tplFile = `./plugins/${plugin}/resources/${app}/${tpl}.html`

View File

@ -1,15 +1,15 @@
import { Cfg } from "./index.js"; import { Cfg } from "./index.js";
import { segment } from "oicq"; import { segment } from "oicq";
import { currentVersion, yunzaiVersion } from "./Changelog.js"; import { currentVersion, yunzaiVersion,isV3 } from "./Changelog.js";
import {render1} from "../apps/render.js";
export const render = async function (path, params, cfg) { export const render = async function (path, params, cfg) {
let paths = path.split("/"); let paths = path.split("/");
let { render, e } = cfg; let { render, e } = cfg;
let _layout_path = process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/"; let _layout_path = process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/";
let layout_path= process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/common/layout/"; 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, ...params,
_layout_path, _layout_path,
_tpl_path: process.cwd() + '/plugins/xiaoyao-cvs-plugin/resources/common/tpl/',
defaultLayout: layout_path + "default.html", defaultLayout: layout_path + "default.html",
elemLayout: layout_path + "elem.html", elemLayout: layout_path + "elem.html",
sys: { sys: {
@ -17,21 +17,21 @@ export const render = async function (path, params, cfg) {
copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>` copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>`
} }
},"png"); },"png");
let ret = true
if (base64) { if (base64) {
e.reply(segment.image(`base64://${base64}`)); ret = isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`))
} }
return cfg.retMsgId ? ret : true
return true;
} }
export const render_path = async function (path, params, cfg,path_) { export const render_path = async function (path, params, cfg,path_) {
let paths = path.split("/"); let paths = path.split("/");
let { render, e } = cfg; let { render, e } = cfg;
let _layout_path = process.cwd() + path_; let _layout_path = process.cwd() + path_;
let base64 = await render1(paths[0], paths[1], { let base64 = await render(paths[0], paths[1], {
...params, ...params,
_layout_path, _layout_path,
_tpl_path: process.cwd() + '/plugins/xiaoyao-cvs-plugin/resources/common/tpl/',
defaultLayout: _layout_path + "default.html", defaultLayout: _layout_path + "default.html",
elemLayout: _layout_path + "elem.html", elemLayout: _layout_path + "elem.html",
sys: { sys: {
@ -39,12 +39,11 @@ export const render_path = async function (path, params, cfg,path_) {
copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>` copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>`
} }
}); });
let ret = true
if (base64) { if (base64) {
e.reply(segment.image(`base64://${base64}`)); ret = isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`))
} }
return cfg.retMsgId ? ret : true
return true;
} }