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:
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,34 +1,65 @@
import { Cfg } from "../components/index.js"; import {
import { segment } from "oicq"; Cfg
} from "../components/index.js";
import {
segment
} from "oicq";
import lodash from "lodash"; 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 Common from "../components/Common.js";
import fs from "fs"
const _path = process.cwd(); const _path = process.cwd();
const helpFilePath = `${_path}/plugins/xiaoyao-cvs-plugin/resources/help/help-list.js`; const helpPath = `${_path}/plugins/xiaoyao-cvs-plugin/resources/help`;
const path_=`/plugins/xiaoyao-cvs-plugin/resources/common/layout/`; const path_ = `/plugins/xiaoyao-cvs-plugin/resources/common/layout/`;
export async function help(e, { render }) { export async function help(e, {
render
}) {
if (!/图鉴/.test(e.msg) && !Cfg.get("sys.help", false)) { if (!/图鉴/.test(e.msg) && !Cfg.get("sys.help", false)) {
return false; return false;
} }
let helpFile = {}; let custom = {},
helpFile = await import(`file://${helpFilePath}?version=${new Date().getTime()}`); 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()}`);
}
// 兼容一下旧字段
if (lodash.isArray(help.helpCfg)) {
custom = {
helpList: help.helpCfg,
helpCfg: {}
};
} else {
custom = help;
}
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;
const { helpCfg } = helpFile;
let helpGroup = []; let helpGroup = [];
lodash.forEach(helpCfg, (group) => { lodash.forEach(helpList, (group) => {
if (group.auth && group.auth === "master" && !e.isMaster) { if (group.auth && group.auth === "master" && !e.isMaster) {
return; return;
} }
lodash.forEach(group.list, (help) => { lodash.forEach(group.list, (help) => {
let icon = help.icon * 1; let icon = help.icon * 1;
if (!icon) { if (!icon) {
help.css = `display:none`; help.css = `display:none`;
} else { } else {
let x = (icon - 1) % 10, y = (icon - x - 1) / 10; let x = (icon - 1) % 10,
y = (icon - x - 1) / 10;
help.css = `background-position:-${x * 50}px -${y * 50}px`; help.css = `background-position:-${x * 50}px -${y * 50}px`;
} }
@ -38,15 +69,26 @@ export async function help(e, { render }) {
}); });
return await Common.render_path("help/index", { return await Common.render_path("help/index", {
helpCfg: helpGroup, helpCfg,
helpGroup,
element: 'default' element: 'default'
}, { e, render, scale: 1.2 },path_) }, {
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", { return await Common.render_path("help/version-info", {
currentVersion, currentVersion,
changelogs, changelogs,
elem: "cryo", elem: "cryo",
}, { e, render, scale: 1.2 },path_) }, {
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 { 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,
defaultLayout: layout_path + "default.html", defaultLayout: layout_path + "default.html",

View File

@ -9,7 +9,7 @@
</style> </style>
</head> </head>
<body> <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="left_model">
<div class="list"> <div class="list">
<div class="div"> <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": "信息查询", "group": "信息查询",
"list": [{ "list": [{
"icon": 61, "icon": 61,

View File

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

View File

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