2022-06-17 15:10:02 +08:00
|
|
|
import { Cfg } from "./index.js";
|
|
|
|
import { segment } from "oicq";
|
|
|
|
import { currentVersion, yunzaiVersion } from "./Changelog.js";
|
2022-06-24 23:07:36 +08:00
|
|
|
import {render1} from "../apps/render.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/";
|
2022-06-29 07:42:43 +08:00
|
|
|
let base64 = await render1(paths[0], paths[1], {
|
2022-06-17 15:10:02 +08:00
|
|
|
...params,
|
|
|
|
_layout_path,
|
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-06-17 15:10:02 +08:00
|
|
|
|
|
|
|
if (base64) {
|
|
|
|
e.reply(segment.image(`base64://${base64}`));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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_;
|
|
|
|
let base64 = await render(paths[0], paths[1], {
|
|
|
|
...params,
|
|
|
|
_layout_path,
|
|
|
|
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>`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (base64) {
|
|
|
|
e.reply(segment.image(`base64://${base64}`));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|