增加是否显示DEBUG信息设置项 (#247)

Signed-off-by: huihuimoe <0w0@loli.pet>
This commit is contained in:
Hui Hui
2018-06-02 11:21:08 +08:00
committed by DIYgod
parent 12a7390e38
commit 4606696a0c
3 changed files with 12 additions and 0 deletions
+2
View File
@@ -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: {
+8
View File
@@ -33,7 +33,15 @@ router.get('/', async (ctx) => {
hotIPsValue += `${ctx.debug.ips[item]}&nbsp;&nbsp;${item}<br>`;
});
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',
+2
View File
@@ -87,6 +87,7 @@
<a href="https://diygod.me" target="_blank">DIYgod</a>
</p>
{{ if showDebug }}
<details>
<summary>debug</summary>
{{ each debug }}
@@ -96,6 +97,7 @@
</div>
{{ /each }}
</details>
{{ /if }}
</div>
</body>