From 3845b57e08ace548a3bd00f0ce3116f5f7f30237 Mon Sep 17 00:00:00 2001
From: leiyilu <1509167646@qq.com>
Date: Wed, 29 Jun 2022 07:30:07 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BD=93=E5=8A=9B=E8=83=8C?=
=?UTF-8?q?=E6=99=AF=E9=9A=8F=E6=9C=BA=EF=BC=8C=E5=AE=8C=E5=96=84=E5=B8=AE?=
=?UTF-8?q?=E5=8A=A9=E5=8F=AF=E8=87=AA=E5=AE=9A=E4=B9=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
apps/help.js | 116 ++++++++++++------
components/Common.js | 2 +-
resources/dailyNote/xiaoyao_Note.html | 2 +-
.../{help-list.js => help-cfg_default.js} | 12 +-
resources/help/index.css | 33 ++---
resources/help/index.html | 12 +-
resources/help/index.less | 114 +++++++++++++++++
7 files changed, 220 insertions(+), 71 deletions(-)
rename resources/help/{help-list.js => help-cfg_default.js} (75%)
create mode 100644 resources/help/index.less
diff --git a/apps/help.js b/apps/help.js
index c9b35ab..7792a06 100644
--- a/apps/help.js
+++ b/apps/help.js
@@ -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_)
}
diff --git a/components/Common.js b/components/Common.js
index 0bfdefb..901736e 100644
--- a/components/Common.js
+++ b/components/Common.js
@@ -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",
diff --git a/resources/dailyNote/xiaoyao_Note.html b/resources/dailyNote/xiaoyao_Note.html
index b86be1f..3583b55 100644
--- a/resources/dailyNote/xiaoyao_Note.html
+++ b/resources/dailyNote/xiaoyao_Note.html
@@ -9,7 +9,7 @@
-
+
diff --git a/resources/help/help-list.js b/resources/help/help-cfg_default.js
similarity index 75%
rename from resources/help/help-list.js
rename to resources/help/help-cfg_default.js
index 828d493..62b9f80 100644
--- a/resources/help/help-list.js
+++ b/resources/help/help-cfg_default.js
@@ -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,
diff --git a/resources/help/index.css b/resources/help/index.css
index e052415..b4ff828 100644
--- a/resources/help/index.css
+++ b/resources/help/index.css
@@ -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 */
\ No newline at end of file
diff --git a/resources/help/index.html b/resources/help/index.html
index cce18ae..e163407 100644
--- a/resources/help/index.html
+++ b/resources/help/index.html
@@ -7,16 +7,16 @@
{{block 'main'}}
-
使用帮助
-
Yunzai-Bot & xiaoyao-cvs-Plugin
+
{{helpCfg.title||"使用帮助"}}
+
{{helpCfg.subTitle || "Yunzai-Bot & Miao-Plugin"}}
-{{each helpCfg helpGroup}}
+{{each helpGroup group}}
-
{{helpGroup.group}}
+
{{group.group}}
- {{each helpGroup.list help idx}}
+ {{each group.list help idx}}
{{if idx%3 == 0}}
{{/if}}
@@ -25,7 +25,7 @@
{{help.title}}
{{help.desc}}
- {{if idx%3 ==2 || idx == helpGroup.list.length -1}}
+ {{if idx%3 ==2 || idx == group.list.length -1}}
{{/if}}
{{/each}}
diff --git a/resources/help/index.less b/resources/help/index.less
new file mode 100644
index 0000000..0af07ea
--- /dev/null
+++ b/resources/help/index.less
@@ -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;
+}
+