diff --git a/apps/help.js b/apps/help.js
index 222d7b7..2f58f0a 100644
--- a/apps/help.js
+++ b/apps/help.js
@@ -5,7 +5,7 @@ import { segment } from "oicq";
import puppeteer from '../../../lib/puppeteer/puppeteer.js'
import cfg from '../../../lib/config/config.js'
import { Cfg, Common, Data, Version, Plugin_Name, Plugin_Path } from '../components/index.js'
-import Theme from './help/theme.js'
+// import Theme from './help/theme.js'
export class yenai_help extends plugin {
constructor() {
@@ -65,12 +65,26 @@ async function help(e) {
helpGroup.push(group)
})
- let themeData = await Theme.getThemeData(diyCfg.helpCfg || {}, sysCfg.helpCfg || {})
-
+ let bg = await rodom()
+ let colCount = 3;
return await Common.render('help/index', {
helpCfg: helpConfig,
helpGroup,
- ...themeData,
- element: 'default'
- }, { e, scale: 2.0 })
+ bg,
+ colCount,
+ // element: 'default'
+ }, {
+ e,
+ scale: 2.0
+ })
+}
+
+const rodom = async function () {
+ var image = fs.readdirSync(`./plugins/yenai-plugin/resources/help/imgs/`);
+ var list_img = [];
+ for (let val of image) {
+ list_img.push(val)
+ }
+ var imgs = list_img.length == 1 ? list_img[0] : list_img[lodash.random(0, list_img.length - 1)];
+ return imgs;
}
\ No newline at end of file
diff --git a/apps/help/theme.js b/apps/help/theme.js
deleted file mode 100644
index 197372f..0000000
--- a/apps/help/theme.js
+++ /dev/null
@@ -1,67 +0,0 @@
-import lodash from 'lodash'
-import fs from 'fs'
-import { Data , Plugin_Name} from '../../components/index.js'
-let Theme = {
- async getThemeCfg (theme, exclude) {
- let dirPath = `./plugins/${Plugin_Name}/resources/help/theme/`
- let ret = []
- let names = []
- let dirs = fs.readdirSync(dirPath)
- lodash.forEach(dirs, (dir) => {
- if (fs.existsSync(`${dirPath}${dir}/main.png`)) {
- names.push(dir)
- }
- })
- if (lodash.isArray(theme)) {
- ret = lodash.intersection(theme, names)
- } else if (theme === 'all') {
- ret = names
- }
- if (exclude && lodash.isArray(exclude)) {
- ret = lodash.difference(ret, exclude)
- }
- if (ret.length === 0) {
- ret = ['default']
- }
- let name = lodash.sample(ret)
- let resPath = '{{_res_path}}/help/theme/'
- return {
- main: `${resPath}${name}/main.png`,
- bg: fs.existsSync(`${dirPath}${name}/bg.jpg`) ? `${resPath}${name}/bg.jpg` : `${resPath}default/bg.jpg`,
- style: (await Data.importModule(`resources/help/theme/${name}/config.js`)).style || {}
- }
- },
- async getThemeData (diyStyle, sysStyle) {
- let helpConfig = lodash.extend({}, sysStyle, diyStyle)
- let colCount = Math.min(5, Math.max(parseInt(helpConfig?.colCount) || 3, 2))
- let colWidth = Math.min(500, Math.max(100, parseInt(helpConfig?.colWidth) || 265))
- let width = Math.min(2500, Math.max(800, colCount * colWidth + 30))
- let theme = await Theme.getThemeCfg(helpConfig.theme, diyStyle.themeExclude || sysStyle.themeExclude)
- let themeStyle = theme.style || {}
- let ret = [`
- body{background-image:url(${theme.bg});width:${width}px;}
- .container{background-image:url(${theme.main});width:${width}px;}
- .help-table .td,.help-table .th{width:${100 / colCount}%}
- `]
- let css = function (sel, css, key, def, fn) {
- let val = Data.def(themeStyle[key], diyStyle[key], sysStyle[key], def)
- if (fn) {
- val = fn(val)
- }
- ret.push(`${sel}{${css}:${val}}`)
- }
- css('.help-title,.help-group', 'color', 'fontColor', '#ceb78b')
- css('.help-title,.help-group', 'text-shadow', 'fontShadow', 'none')
- css('.help-desc', 'color', 'descColor', '#eee')
- css('.cont-box', 'background', 'contBgColor', 'rgba(43, 52, 61, 0.8)')
- css('.cont-box', 'backdrop-filter', 'contBgBlur', 3, (n) => diyStyle.bgBlur === false ? 'none' : `blur(${n}px)`)
- css('.help-group', 'background', 'headerBgColor', 'rgba(34, 41, 51, .4)')
- css('.help-table .tr:nth-child(odd)', 'background', 'rowBgColor1', 'rgba(34, 41, 51, .2)')
- css('.help-table .tr:nth-child(even)', 'background', 'rowBgColor2', 'rgba(34, 41, 51, .4)')
- return {
- style: ``,
- colCount
- }
- }
-}
-export default Theme
diff --git a/resources/help/imgs/main.png b/resources/help/imgs/main.png
new file mode 100644
index 0000000..6fb9a48
Binary files /dev/null and b/resources/help/imgs/main.png differ
diff --git a/resources/help/index.css b/resources/help/index.css
index 5c8e833..7e437f3 100644
--- a/resources/help/index.css
+++ b/resources/help/index.css
@@ -1,7 +1,7 @@
body {
transform: scale(1);
width: 830px;
- /* background: url("../common/theme/bg-01.jpg"); */
+ background: url("../common/theme/bg-01.jpg");
}
.container {
diff --git a/resources/help/index.html b/resources/help/index.html
index 3350a52..94ae9a4 100644
--- a/resources/help/index.html
+++ b/resources/help/index.html
@@ -2,8 +2,12 @@
{{block 'css'}}
-
-
+
{{/block}}
{{block 'main'}}
diff --git a/resources/help/theme/default/config.js b/resources/help/theme/default/config.js
deleted file mode 100644
index 339b66b..0000000
--- a/resources/help/theme/default/config.js
+++ /dev/null
@@ -1,24 +0,0 @@
-export const style = {
- // 主文字颜色
- fontColor: '#ceb78b',
- // 主文字阴影: 横向距离 垂直距离 阴影大小 阴影颜色
- // fontShadow: '0px 0px 1px rgba( 219,212,246, .9)',
- fontShadow: 'none',
- // 描述文字颜色
- descColor: '#eee',
-
- /* 面板整体底色,会叠加在标题栏及帮助行之下,方便整体帮助有一个基础底色
- * 若无需此项可将rgba最后一位置为0即为完全透明
- * 注意若综合透明度较低,或颜色与主文字颜色过近或太透明可能导致阅读困难 */
- // contBgColor: 'rgba( 255, 255, 255, .5)',
-
- // 面板底图毛玻璃效果,数字越大越模糊,0-10 ,可为小数
- // contBgBlur: 0,
-
- // 板块标题栏底色
- // headerBgColor: 'rgba( 255, 255, 255, .4)',
- // 帮助奇数行底色
- // rowBgColor1: 'rgba( 255, 255, 255, .2)',
- // 帮助偶数行底色
- // rowBgColor2: 'rgba( 255, 255, 255, .35)'
-}