-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
495 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { App, Render, Version } from '#components' | ||
import lodash from 'lodash' | ||
import { help as helpUtil } from '#models' | ||
|
||
const app = { | ||
id: 'help', | ||
name: '帮助' | ||
} | ||
|
||
export const rule = { | ||
help: { | ||
reg: /^#?steam(插件|plugin)?(帮助|菜单|help)$/i, | ||
fnc: help | ||
} | ||
// version: { | ||
// reg: /^#?steam(插件|plugin)?(版本|version)$/i, | ||
// fnc: version | ||
// } | ||
} | ||
|
||
export const helpApp = new App(app, rule).create() | ||
|
||
async function help (e) { | ||
const helpGroup = [] | ||
|
||
lodash.forEach(helpUtil.helpList, (group) => { | ||
if (group.auth && group.auth === 'master' && !e.isMaster) { | ||
return true | ||
} | ||
|
||
lodash.forEach(group.list, (help) => { | ||
const icon = help.icon * 1 | ||
if (!icon) { | ||
help.css = 'display:none' | ||
} else { | ||
const x = (icon - 1) % 10 | ||
const y = (icon - x - 1) / 10 | ||
help.css = `background-position:-${x * 50}px -${y * 50}px` | ||
} | ||
}) | ||
|
||
helpGroup.push(group) | ||
}) | ||
const themeData = await helpUtil.helpTheme.getThemeData(helpUtil.helpCfg) | ||
const img = await Render.render('help/index', { | ||
helpCfg: helpUtil.helpCfg, | ||
helpGroup, | ||
...themeData, | ||
scale: 1.2 | ||
}) | ||
if (img) { | ||
await e.reply(img) | ||
} else { | ||
await e.reply('截图失败辣! 再试一次叭') | ||
} | ||
return true | ||
} | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
async function version (e) { | ||
const img = await Render.render('help/version-info', { | ||
currentVersion: Version.version, | ||
changelogs: Version.changelogs, | ||
scale: 1.2 | ||
}) | ||
return await e.reply(img) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { App, Config, Render } from '#components' | ||
import lodash from 'lodash' | ||
import { setting } from '#models' | ||
|
||
const keys = lodash.map(setting.getCfgSchemaMap(), (i) => i.key) | ||
|
||
const app = { | ||
id: 'setting', | ||
name: '设置' | ||
} | ||
|
||
export const rule = { | ||
setting: { | ||
reg: new RegExp(`^#steam设置\\s*(${keys.join('|')})?\\s*(.*)$`), | ||
fnc: async e => { | ||
const regRet = rule.setting.reg.exec(e.msg) | ||
const cfgSchemaMap = setting.getCfgSchemaMap() | ||
if (!regRet) { | ||
return true | ||
} | ||
|
||
if (regRet[1]) { | ||
// 设置模式 | ||
let val = regRet[2] || '' | ||
|
||
if (regRet[1] == '全部') { | ||
val = !/关闭/.test(val) | ||
for (const i of keys) { | ||
if (typeof cfgSchemaMap[i].def == 'boolean') { | ||
if (cfgSchemaMap[i].key == '全部') { | ||
await redis.set('steam-plugin:set-all', val ? 1 : 0) | ||
} else { | ||
Config.modify(cfgSchemaMap[i].fileName, cfgSchemaMap[i].cfgKey, val) | ||
} | ||
} | ||
} | ||
} else { | ||
const cfgSchema = cfgSchemaMap[regRet[1]] | ||
if (cfgSchema.input) { | ||
val = cfgSchema.input(val) | ||
} else { | ||
if (cfgSchema.type === 'number') { | ||
val = val * 1 || cfgSchema.def | ||
} else if (cfgSchema.type === 'boolean') { | ||
val = !/关闭/.test(val) | ||
} else if (cfgSchema.type === 'string') { | ||
val = val.trim() || cfgSchema.def | ||
} | ||
} | ||
Config.modify(cfgSchema.fileName, cfgSchema.cfgKey, val) | ||
} | ||
} | ||
|
||
const schema = setting.cfgSchema | ||
const cfg = Config.getCfg() | ||
cfg.setAll = (await redis.get('steam-plugin:set-all')) == 1 | ||
|
||
const img = await Render.render('setting/index', { | ||
schema, | ||
cfg | ||
}, { e, scale: 1.4 }) | ||
if (img) { | ||
await e.reply(img) | ||
} else { | ||
await e.reply('截图失败辣! 再试一次叭') | ||
} | ||
return true | ||
} | ||
} | ||
} | ||
|
||
export const settingPlugin = new App(app, rule).create() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export const style = { | ||
// 主文字颜色 | ||
fontColor: '#ceb78b', | ||
// 主文字阴影: 横向距离 垂直距离 阴影大小 阴影颜色 | ||
// fontShadow: '0px 0px 1px rgba(6, 21, 31, .9)', | ||
fontShadow: 'none', | ||
// 描述文字颜色 | ||
descColor: '#eee', | ||
|
||
/* 面板整体底色,会叠加在标题栏及帮助行之下,方便整体帮助有一个基础底色 | ||
* 若无需此项可将rgba最后一位置为0即为完全透明 | ||
* 注意若综合透明度较低,或颜色与主文字颜色过近或太透明可能导致阅读困难 */ | ||
contBgColor: 'rgba(6, 21, 31, .5)', | ||
|
||
// 面板底图毛玻璃效果,数字越大越模糊,0-10 ,可为小数 | ||
contBgBlur: 3, | ||
|
||
// 板块标题栏底色 | ||
headerBgColor: 'rgba(6, 21, 31, .4)', | ||
// 帮助奇数行底色 | ||
rowBgColor1: 'rgba(6, 21, 31, .2)', | ||
// 帮助偶数行底色 | ||
rowBgColor2: 'rgba(6, 21, 31, .35)' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
export const helpCfg = { | ||
themeSet: false, | ||
title: 'steam帮助', | ||
subTitle: '', | ||
colCount: 3, | ||
colWidth: 265, | ||
theme: 'all', | ||
bgBlur: true | ||
} | ||
export const helpList = [ | ||
{ | ||
group: 'steam 信息', | ||
list: [ | ||
{ | ||
icon: 9, | ||
title: '#steam绑定', | ||
desc: '绑定steamid或好友码' | ||
}, | ||
{ | ||
icon: 10, | ||
title: '#steam解除绑定', | ||
desc: '解除绑定steamid或好友码' | ||
}, | ||
{ | ||
icon: 11, | ||
title: '#steam状态', | ||
desc: '查看steam个人状态' | ||
}, | ||
{ | ||
icon: 12, | ||
title: '#steam库存', | ||
desc: '查看steam库存' | ||
}, | ||
{ | ||
icon: 13, | ||
title: '#steam最近游玩', | ||
desc: '查看steam最近游玩' | ||
}, | ||
{ | ||
icon: 14, | ||
title: '#steam愿望单', | ||
desc: '查看steam愿望单' | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import helpTheme from './theme.js' | ||
export { helpCfg, helpList } from './help.js' | ||
|
||
export { | ||
helpTheme | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import lodash from 'lodash' | ||
import { style } from './config.js' | ||
|
||
const helpTheme = { | ||
getThemeCfg () { | ||
const resPath = `{{pluResPath}}help/theme/${lodash.random(1, 5)}.png` | ||
return { | ||
main: resPath, | ||
bg: resPath, | ||
style | ||
} | ||
}, | ||
async getThemeData (diyStyle) { | ||
const helpConfig = lodash.extend({}, diyStyle) | ||
const colCount = Math.min(5, Math.max(parseInt(helpConfig?.colCount) || 3, 2)) | ||
const colWidth = Math.min(500, Math.max(100, parseInt(helpConfig?.colWidth) || 265)) | ||
const width = Math.min(2500, Math.max(800, colCount * colWidth + 30)) | ||
const theme = helpTheme.getThemeCfg() | ||
const themeStyle = theme.style || {} | ||
const 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}%} | ||
`] | ||
const defFnc = (...args) => { | ||
for (const idx in args) { | ||
if (!lodash.isUndefined(args[idx])) { | ||
return args[idx] | ||
} | ||
} | ||
} | ||
const css = function (sel, css, key, def, fn) { | ||
let val = defFnc(themeStyle[key], diyStyle[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: `<style>${ret.join('\n')}</style>`, | ||
colCount | ||
} | ||
} | ||
} | ||
export default helpTheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.