2022-06-17 15:10:02 +08:00
|
|
|
import { Cfg } from "./index.js";
|
2022-08-17 23:07:34 +08:00
|
|
|
import { currentVersion, yunzaiVersion,isV3 } from "./Changelog.js";
|
2022-06-17 15:10:02 +08:00
|
|
|
export const render = async function (path, params, cfg) {
|
|
|
|
let paths = path.split("/");
|
|
|
|
let { render, e } = cfg;
|
2022-06-23 22:30:41 +08:00
|
|
|
let _layout_path = process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/";
|
2022-06-26 19:31:18 +08:00
|
|
|
let layout_path= process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/common/layout/";
|
2023-06-06 12:41:02 +08:00
|
|
|
if(paths.length>2){
|
|
|
|
paths[0] = `${paths[0]}/${paths[1]}`
|
|
|
|
paths[1] = `${paths[2]}`
|
|
|
|
}
|
2022-08-17 23:07:34 +08:00
|
|
|
let base64 = await render(paths[0], paths[1], {
|
2022-06-17 15:10:02 +08:00
|
|
|
...params,
|
|
|
|
_layout_path,
|
2022-08-17 23:07:34 +08:00
|
|
|
_tpl_path: process.cwd() + '/plugins/xiaoyao-cvs-plugin/resources/common/tpl/',
|
2022-06-26 19:31:18 +08:00
|
|
|
defaultLayout: layout_path + "default.html",
|
|
|
|
elemLayout: layout_path + "elem.html",
|
2022-06-17 15:10:02 +08:00
|
|
|
sys: {
|
|
|
|
scale: Cfg.scale(cfg.scale || 1),
|
2022-06-24 08:06:43 +08:00
|
|
|
copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>`
|
2022-06-17 15:10:02 +08:00
|
|
|
}
|
2022-06-24 22:01:48 +08:00
|
|
|
},"png");
|
2022-08-17 23:07:34 +08:00
|
|
|
let ret = true
|
2022-06-17 15:10:02 +08:00
|
|
|
if (base64) {
|
2022-08-17 23:07:34 +08:00
|
|
|
ret = isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`))
|
2022-06-17 15:10:02 +08:00
|
|
|
}
|
2022-08-17 23:07:34 +08:00
|
|
|
return cfg.retMsgId ? ret : true
|
2022-06-17 15:10:02 +08:00
|
|
|
}
|
|
|
|
|
2022-06-24 08:06:43 +08:00
|
|
|
export const render_path = async function (path, params, cfg,path_) {
|
|
|
|
let paths = path.split("/");
|
|
|
|
let { render, e } = cfg;
|
|
|
|
let _layout_path = process.cwd() + path_;
|
2022-08-17 23:07:34 +08:00
|
|
|
let base64 = await render(paths[0], paths[1], {
|
2022-06-24 08:06:43 +08:00
|
|
|
...params,
|
|
|
|
_layout_path,
|
2022-08-17 23:07:34 +08:00
|
|
|
_tpl_path: process.cwd() + '/plugins/xiaoyao-cvs-plugin/resources/common/tpl/',
|
2022-06-24 08:06:43 +08:00
|
|
|
defaultLayout: _layout_path + "default.html",
|
|
|
|
elemLayout: _layout_path + "elem.html",
|
|
|
|
sys: {
|
|
|
|
scale: Cfg.scale(cfg.scale || 1),
|
|
|
|
copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>`
|
|
|
|
}
|
|
|
|
});
|
2022-08-17 23:07:34 +08:00
|
|
|
let ret = true
|
2022-06-24 08:06:43 +08:00
|
|
|
if (base64) {
|
2022-08-17 23:07:34 +08:00
|
|
|
ret = isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`))
|
2022-06-24 08:06:43 +08:00
|
|
|
}
|
2022-08-17 23:07:34 +08:00
|
|
|
return cfg.retMsgId ? ret : true
|
2022-06-24 08:06:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-17 15:10:02 +08:00
|
|
|
|
|
|
|
export default {
|
2022-06-24 08:06:43 +08:00
|
|
|
render,render_path,
|
2022-06-17 15:10:02 +08:00
|
|
|
cfg: Cfg.get,
|
|
|
|
isDisable: Cfg.isDisable
|
|
|
|
};
|