From 4606696a0cc94f0a9672bef5c9170fb6c5ffb388 Mon Sep 17 00:00:00 2001 From: Hui Hui <0w0@loli.pet> Date: Sat, 2 Jun 2018 11:21:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=98=AF=E5=90=A6=E6=98=BE?= =?UTF-8?q?=E7=A4=BADEBUG=E4=BF=A1=E6=81=AF=E8=AE=BE=E7=BD=AE=E9=A1=B9=20(?= =?UTF-8?q?#247)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huihuimoe <0w0@loli.pet> --- config.js | 2 ++ router.js | 8 ++++++++ views/welcome.art | 2 ++ 3 files changed, 12 insertions(+) diff --git a/config.js b/config.js index 876c063918..ca7f77c2fd 100644 --- a/config.js +++ b/config.js @@ -5,6 +5,8 @@ module.exports = { ua: process.env.UA || 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36', listenInaddrAny: process.env.LISTEN_INADDR_ANY || 1, // 是否允许公网连接,取值 0 1 requestRetry: process.env.REQUEST_RETRY || 2, // 请求失败重试次数 + // 是否显示 Debug 信息,取值 boolean 'false' 'key' ,取值为 'false' false 时永远不显示,取值为 'key' 时带上 ?debug=key 显示 + debugInfo: process.env.DEBUG_INFO || true, redis: { url: process.env.REDIS_URL || 'redis://localhost:6379/', options: { diff --git a/router.js b/router.js index 19dda79459..2a0a02b563 100644 --- a/router.js +++ b/router.js @@ -33,7 +33,15 @@ router.get('/', async (ctx) => { hotIPsValue += `${ctx.debug.ips[item]}  ${item}
`; }); + let showDebug; + if (!config.debugInfo || config.debugInfo === 'false') { + showDebug = false; + } else { + showDebug = config.debugInfo === true || config.debugInfo === ctx.query.debug; + } + ctx.body = art(path.resolve(__dirname, './views/welcome.art'), { + showDebug, debug: [ { name: 'git hash', diff --git a/views/welcome.art b/views/welcome.art index 79f3ce8332..a58e934daa 100644 --- a/views/welcome.art +++ b/views/welcome.art @@ -87,6 +87,7 @@ DIYgod

+ {{ if showDebug }}
debug {{ each debug }} @@ -96,6 +97,7 @@ {{ /each }}
+ {{ /if }}