2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 11:40:51 +08:00
xiaoyao-cvs-plugin/apps/help.js

53 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-06-24 08:06:43 +08:00
import { Cfg } from "../components/index.js";
2022-06-20 21:43:24 +08:00
import { segment } from "oicq";
2022-06-24 08:06:43 +08:00
import lodash from "lodash";
import { currentVersion, changelogs } from "../components/Changelog.js";
import Common from "../components/Common.js";
2022-06-20 21:43:24 +08:00
const _path = process.cwd();
2022-06-24 08:06:43 +08:00
const helpFilePath = `${_path}/plugins/xiaoyao-cvs-plugin/resources/help/help-list.js`;
const path_=`/plugins/xiaoyao-cvs-plugin/resources/common/layout/`;
export async function help(e, { render }) {
if (!/图鉴/.test(e.msg) && !Cfg.get("sys.help", false)) {
return false;
}
let helpFile = {};
helpFile = await import(`file://${helpFilePath}?version=${new Date().getTime()}`);
const { helpCfg } = helpFile;
let helpGroup = [];
lodash.forEach(helpCfg, (group) => {
if (group.auth && group.auth === "master" && !e.isMaster) {
return;
}
lodash.forEach(group.list, (help) => {
let icon = help.icon * 1;
if (!icon) {
help.css = `display:none`;
} else {
let x = (icon - 1) % 10, y = (icon - x - 1) / 10;
help.css = `background-position:-${x * 50}px -${y * 50}px`;
}
});
helpGroup.push(group);
});
return await Common.render_path("help/index", {
helpCfg: helpGroup,
element: 'default'
}, { e, render, scale: 1.2 },path_)
2022-06-20 21:43:24 +08:00
}
2022-06-24 08:06:43 +08:00
export async function versionInfo(e, { render }) {
return await Common.render_path("help/version-info", {
currentVersion,
changelogs,
elem: "cryo",
}, { e, render, scale: 1.2 },path_)
2022-06-23 23:06:30 +08:00
}