2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-22 19:10:53 +08:00

更新体力背景随机,完善帮助可自定义

This commit is contained in:
leiyilu 2022-06-29 07:30:07 +08:00
parent 7e5d492281
commit 3845b57e08
7 changed files with 220 additions and 71 deletions

View File

@ -1,52 +1,94 @@
import { Cfg } from "../components/index.js";
import { segment } from "oicq";
import {
Cfg
} from "../components/index.js";
import {
segment
} from "oicq";
import lodash from "lodash";
import { currentVersion, changelogs } from "../components/Changelog.js";
import {
currentVersion,
changelogs
} from "../components/Changelog.js";
import Common from "../components/Common.js";
import fs from "fs"
const _path = process.cwd();
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 helpPath = `${_path}/plugins/xiaoyao-cvs-plugin/resources/help`;
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 custom = {},
help = {};
if (fs.existsSync(`${helpPath}/help-cfg.js`)) {
help = await import(`file://${helpPath}/help-cfg.js?version=${new Date().getTime()}`);
} else if (fs.existsSync(`${helpPath}/help-list.js`)) {
help = await import(`file://${helpPath}/help-list.js?version=${new Date().getTime()}`);
} else {
help = await import(`file://${helpPath}/help-cfg_default.js?version=${new Date().getTime()}`);
}
const { helpCfg } = helpFile;
let helpGroup = [];
// 兼容一下旧字段
if (lodash.isArray(help.helpCfg)) {
custom = {
helpList: help.helpCfg,
helpCfg: {}
};
} else {
custom = help;
}
lodash.forEach(helpCfg, (group) => {
if (group.auth && group.auth === "master" && !e.isMaster) {
return;
}
let def = await import(`file://${helpPath}/help-cfg_default.js?version=${new Date().getTime()}`);
let helpCfg = lodash.defaults(custom.helpCfg, def.helpCfg);
let helpList = custom.helpList || def.helpList;
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`;
}
let helpGroup = [];
});
lodash.forEach(helpList, (group) => {
if (group.auth && group.auth === "master" && !e.isMaster) {
return;
}
helpGroup.push(group);
});
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`;
}
return await Common.render_path("help/index", {
helpCfg: helpGroup,
element: 'default'
}, { e, render, scale: 1.2 },path_)
});
helpGroup.push(group);
});
return await Common.render_path("help/index", {
helpCfg,
helpGroup,
element: 'default'
}, {
e,
render,
scale: 1.2
}, path_)
}
export async function versionInfo(e, { render }) {
export async function versionInfo(e, {
render
}) {
return await Common.render_path("help/version-info", {
currentVersion,
changelogs,
elem: "cryo",
}, { e, render, scale: 1.2 },path_)
currentVersion,
changelogs,
elem: "cryo",
}, {
e,
render,
scale: 1.2
}, path_)
}

View File

@ -7,7 +7,7 @@ export const render = async function (path, params, 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/common/layout/";
let base64 = await render1(paths[0], paths[1], {
let base64 = await render(paths[0], paths[1], {
...params,
_layout_path,
defaultLayout: layout_path + "default.html",

View File

@ -9,7 +9,7 @@
</style>
</head>
<body>
<div class="container" id="container" style=" background-image: url({{_res_path}}/dailyNote/icon/bg/bg.png);">
<div class="container" id="container" style=" background-image: url({{_res_path}}/dailyNote/icon/bg/{{imgs}});">
<div class="left_model">
<div class="list">
<div class="div">

View File

@ -1,4 +1,14 @@
export const helpCfg = [{
/*
* 请勿直接修改此文件可能会导致后续更新冲突
* 如需自定义可将文件复制一份重命名为 help-cfg.js 后编辑
* */
// 帮助配置
export const helpCfg = {
title: "图鉴帮助", // 帮助标题
subTitle: "Yunzai-Bot & xiaoyao-cvs-Plugin" // 帮助副标题
};
export const helpList = [{
"group": "信息查询",
"list": [{
"icon": 61,

View File

@ -1,47 +1,39 @@
body {
transform: scale(1);
width: 800px;
width: 830px;
background: url("../common/theme/bg-01.jpg");
}
.container {
background: url(../common/theme/main-01.png) top left no-repeat;
background-size: 100% auto;
width: 800px;
width: 830px;
}
.label {
font-family: Number, "微软雅黑", sans-serif;
}
.head-box {
margin: 60px 0 0 0;
padding-bottom: 0;
}
.head-box .title {
font-size: 50px;
}
.cont-box {
border-radius: 15px;
margin-top: 20px;
margin-bottom: 20px;
padding: 5px 15px;
overflow: hidden;
box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%);
box-shadow: 0 5px 10px 0 rgba(0, 0, 0, 0.15);
position: relative;
background: rgba(43, 52, 61, 0.8);
}
.help-group {
color: #ceb78b;
font-size: 18px;
font-weight: bold;
padding: 8px 0 5px 10px;
}
.help-table {
text-align: center;
border-collapse: collapse;
@ -52,11 +44,9 @@ body {
width: calc(100% + 30px);
color: #fff;
}
.help-table .tr {
display: table-row;
}
.help-table .td,
.help-table .th {
font-size: 14px;
@ -68,47 +58,40 @@ body {
width: 33.33%;
text-align: left;
}
.help-table .tr:nth-child(odd) {
background: rgba(34, 41, 51, .6)
background: rgba(34, 41, 51, 0.6);
}
.help-table .tr:nth-child(even) {
background: rgba(34, 41, 51, .3)
background: rgba(34, 41, 51, 0.3);
}
.help-table .tr:last-child .td {
padding-bottom: 12px;
}
.help-table .th {
background: rgba(34, 41, 51, .5)
background: rgba(34, 41, 51, 0.5);
}
.help-icon {
width: 40px;
height: 40px;
display: block;
position: absolute;
background: url("icon.png") 0 0 no-repeat;
background-size: 500px 500px;
background-size: 500px auto;
border-radius: 5px;
left: 6px;
top: 12px;
transform: scale(0.85);
}
.help-title {
display: block;
color: #d3bc8e;
font-size: 16px;
line-height: 24px;
}
.help-desc {
display: block;
font-size: 13px;
line-height: 18px;
color: #eee;
}
/*# sourceMappingURL=index.css.map */

View File

@ -7,16 +7,16 @@
{{block 'main'}}
<div class="info_box">
<div class="head-box type{{bgType}}">
<div class="title">使用帮助</div>
<div class="label">Yunzai-Bot & xiaoyao-cvs-Plugin</div>
<div class="title">{{helpCfg.title||"使用帮助"}}</div>
<div class="label">{{helpCfg.subTitle || "Yunzai-Bot & Miao-Plugin"}}</div>
</div>
</div>
{{each helpCfg helpGroup}}
{{each helpGroup group}}
<div class="cont-box">
<div class="help-group">{{helpGroup.group}}</div>
<div class="help-group">{{group.group}}</div>
<div class="help-table">
{{each helpGroup.list help idx}}
{{each group.list help idx}}
{{if idx%3 == 0}}
<div class="tr">
{{/if}}
@ -25,7 +25,7 @@
<strong class="help-title">{{help.title}}</strong>
<span class="help-desc">{{help.desc}}</span>
</div>
{{if idx%3 ==2 || idx == helpGroup.list.length -1}}
{{if idx%3 ==2 || idx == group.list.length -1}}
</div>
{{/if}}
{{/each}}

114
resources/help/index.less Normal file
View File

@ -0,0 +1,114 @@
body {
transform: scale(1);
width: 830px;
background: url("../common/theme/bg-01.jpg");
}
.container {
background: url(../common/theme/main-01.png) top left no-repeat;
background-size: 100% auto;
width: 830px;
}
.label {
font-family: Number, "微软雅黑", sans-serif;
}
.head-box {
margin: 60px 0 0 0;
padding-bottom: 0;
}
.head-box .title {
font-size: 50px;
}
.cont-box {
border-radius: 15px;
margin-top: 20px;
margin-bottom: 20px;
padding: 5px 15px;
overflow: hidden;
box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%);
position: relative;
background: rgba(43, 52, 61, 0.8);
}
.help-group {
color: #ceb78b;
font-size: 18px;
font-weight: bold;
padding: 8px 0 5px 10px;
}
.help-table {
text-align: center;
border-collapse: collapse;
margin: 5px -10px -10px -15px;
border-radius: 0 0 10px 10px;
display: table;
overflow: hidden;
width: calc(100% + 30px);
color: #fff;
}
.help-table .tr {
display: table-row;
}
.help-table .td,
.help-table .th {
font-size: 14px;
display: table-cell;
box-shadow: 0 0 1px 0 #888 inset;
padding: 12px 0 12px 50px;
line-height: 24px;
position: relative;
width: 33.33%;
text-align: left;
}
.help-table .tr:nth-child(odd) {
background: rgba(34, 41, 51, .6)
}
.help-table .tr:nth-child(even) {
background: rgba(34, 41, 51, .3)
}
.help-table .tr:last-child .td {
padding-bottom: 12px;
}
.help-table .th {
background: rgba(34, 41, 51, .5)
}
.help-icon {
width: 40px;
height: 40px;
display: block;
position: absolute;
background: url("icon.png") 0 0 no-repeat;
background-size: 500px auto;
border-radius: 5px;
left: 6px;
top: 12px;
transform: scale(0.85);
}
.help-title {
display: block;
color: #d3bc8e;
font-size: 16px;
line-height: 24px;
}
.help-desc {
display: block;
font-size: 13px;
line-height: 18px;
color: #eee;
}