Skip to content

Commit

Permalink
perf: 可设置是否展示steam头像
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Nov 25, 2024
1 parent 1e7f90d commit a002998
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/info.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import moment from 'moment'
import { segment } from '#lib'
import { App } from '#components'
import { App, Config } from '#components'
import { db, utils, api } from '#models'

const app = {
Expand All @@ -26,7 +26,7 @@ export const rule = {
return true
}
const info = data.pop()
const avatarBuffer = await utils.getImgUrlBuffer(info.avatarfull)
const avatarBuffer = Config.other.steamAvatar ? await utils.getImgUrlBuffer(info.avatarfull) : ''
const msg = []
avatarBuffer && msg.push(segment.image(avatarBuffer))
msg.push([
Expand Down
4 changes: 3 additions & 1 deletion components/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ class Config {
* 获取其他配置
* @returns {{
* renderScale: number,
* hiddenLength: number
* hiddenLength: number,
* itemLength: number,
* steamAvatar: boolean,
* }}
*/
get other () {
Expand Down
2 changes: 1 addition & 1 deletion components/Render.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Render = {
Math.max(1, Number(Config.other.itemLength) || 1)
)
const size = params.data.findIndex(i => i.size === 'large') >= 0 ? 370 : 300
const len = minLength === 1 ? (size === 370 ? 1 : 1.4) : minLength
const len = minLength === 1 ? 1.4 : minLength
data.style = `<style>\n#container,.games{\nwidth: ${len * size}px;\n}\n</style>`
}
return await puppeteer.screenshot(path, data)
Expand Down
3 changes: 3 additions & 0 deletions config/default_config/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ hiddenLength: 99

# 截图时每行显示的最大数量
itemLength: 3

# 是否显示Steam头像 可能会有18+的头像
steamAvatar: false
7 changes: 7 additions & 0 deletions models/setting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ export const cfgSchema = {
def: 3,
input: (n) => Math.max(1, n * 1 || 3),
desc: '截图时每行最多显示的数量'
},
steamAvatar: {
title: '展示steam头像',
key: '展示头像',
type: 'boolean',
def: false,
desc: '是否展示steam头像, 可能会有18+头像'
}
}
},
Expand Down

0 comments on commit a002998

Please sign in to comment.