From 492d49879db42316a945eb58aeed425d497f4606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com> Date: Mon, 2 Dec 2024 19:26:27 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=8F=AF=E5=BC=80=E5=85=B3=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Config.js | 1 + config/default_config/other.yaml | 3 +++ lib/logger.js | 6 ++++-- models/setting/index.js | 7 +++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/components/Config.js b/components/Config.js index c5b675a..450cacb 100644 --- a/components/Config.js +++ b/components/Config.js @@ -109,6 +109,7 @@ class Config { * itemLength: number, * steamAvatar: boolean, * infoMode: number, + * log: boolean * }} */ get other () { diff --git a/config/default_config/other.yaml b/config/default_config/other.yaml index 1ca3345..b2ce2bc 100644 --- a/config/default_config/other.yaml +++ b/config/default_config/other.yaml @@ -15,3 +15,6 @@ steamAvatar: true # 1: 文字 # 2: 图片 (若图片发送时间长可更换为文字模式) infoMode: 2 + +# 是否开启日志 +log: true diff --git a/lib/logger.js b/lib/logger.js index 1a66974..28e038c 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,4 +1,4 @@ -import { Version } from '#components' +import { Config, Version } from '#components' import chalk from 'chalk' const logger = await (async () => { @@ -17,6 +17,8 @@ const getRandomHexColor = () => { export default { ...logger, - info: (...logs) => logger.info(chalk.hex(getRandomHexColor())(`[${Version.pluginName}]`, ...logs)), + info: (...logs) => Config.other.log + ? logger.info(chalk.hex(getRandomHexColor())(`[${Version.pluginName}]`, ...logs)) + : null, error: (...logs) => logger.error(`[${Version.pluginName}]`, ...logs) } diff --git a/models/setting/index.js b/models/setting/index.js index 9825e29..8ac5b97 100644 --- a/models/setting/index.js +++ b/models/setting/index.js @@ -197,6 +197,13 @@ export const cfgSchema = { } }, desc: 'steam状态发送消息的模式 1: 文字 2: 图片 若图片发送时间长可更换为文字' + }, + log: { + title: '日志输出', + key: '日志', + type: 'boolean', + def: true, + desc: '是否输出日志' } } },