From 178386dea33852f709b8083a089e4141cc4f0965 Mon Sep 17 00:00:00 2001 From: Suwings Date: Tue, 10 Mar 2020 12:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E7=BB=88=E7=AB=AF?= =?UTF-8?q?=E4=B8=8E=E5=8E=86=E5=8F=B2=E7=AA=97=E5=8F=A3=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper/LogHistory.js | 18 +++++++++++++++--- public/common/css/block.css | 18 +----------------- public/common/css/common.css | 18 ++++++++++++++++++ public/template/component/terminal.html | 2 +- route/websocket/console.js | 2 -- 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/helper/LogHistory.js b/helper/LogHistory.js index 8a4731b4..234267bc 100644 --- a/helper/LogHistory.js +++ b/helper/LogHistory.js @@ -40,6 +40,10 @@ class LogHistory { if (!this.readPoints[demander]) { this.readPoints[demander] = 0; } + if (!fs.existsSync(this.path)) { + callback && callback(''); + return this; + } const demanderPoint = this.readPoints[demander]; const buffer = Buffer.alloc(size); fs.open(this.path, 'r', (err, fd) => { @@ -67,6 +71,7 @@ class LogHistory { fs.close(fd, () => { }); }); }); + return this; } @@ -74,6 +79,10 @@ class LogHistory { if (!this.readPoints[demander]) { this.readPoints[demander] = 0; } + if (!fs.existsSync(this.path)) { + callback && callback(''); + return this; + } const demanderPoint = this.readPoints[demander]; const buffer = Buffer.alloc(size); fs.open(this.path, 'r', (err, fd) => { @@ -102,6 +111,7 @@ class LogHistory { fs.close(fd, () => { }); }); }); + return this; } setPoint(demander, v) { @@ -109,9 +119,11 @@ class LogHistory { } delete() { - fs.unlink(this.path, (err) => { - if (err) MCSERVER.log('实例', this.id, '日志历史记录文件删除错误:', err.message); - }); + if (fs.existsSync(this.path)) { + fs.unlink(this.path, (err) => { + if (err) MCSERVER.log('实例', this.id, '日志历史记录文件删除错误:', err.message); + }); + } return this; } } diff --git a/public/common/css/block.css b/public/common/css/block.css index 9e8b8e26..ab823678 100644 --- a/public/common/css/block.css +++ b/public/common/css/block.css @@ -270,14 +270,6 @@ line-height: 12px; } - /* 手机时的命令输入框 */ - /* .TerminalCommandWapper{ - position: fixed; - bottom: 10px; - left: 10px; - right: 10px; - - } */ } #Terminal a { @@ -296,15 +288,7 @@ bottom: 50px; } -/* 日志历史终端 */ -#LogHistoryTerminal{ - height: 80vh; - width: 100%; - background-color: rgb(0, 0, 0); - overflow-y: scroll; - color: rgb(207, 207, 207); - padding: 4px; -} + /* 黑色屏障 */ diff --git a/public/common/css/common.css b/public/common/css/common.css index ee91c375..28adea5e 100644 --- a/public/common/css/common.css +++ b/public/common/css/common.css @@ -321,6 +321,16 @@ input { .WebTerminalScreen{ overflow-y: auto; } +/* 日志历史终端 */ +#LogHistoryTerminal{ + height: 80vh; + background-color: rgb(0, 0, 0); + overflow-y: scroll; + color: rgb(207, 207, 207); + padding: 4px; + font-size: 11px; + margin: 0; +} @media (max-width:800px) { #HeaderInfo { @@ -379,4 +389,12 @@ input { .WebTerminalScreen{ margin: -10px -12px -9px -12px; } + + #LogHistoryTerminal{ + font-size: 10px; + height: 70vh; + padding: 2px; + margin: -10px -12px -9px -12px; + overflow-x: scroll; + } } \ No newline at end of file diff --git a/public/template/component/terminal.html b/public/template/component/terminal.html index 9ee76a21..4ca125e2 100644 --- a/public/template/component/terminal.html +++ b/public/template/component/terminal.html @@ -64,7 +64,7 @@ var rows = parseInt(clientHeight / 18) - 1; var cols = parseInt(clientWidth / 8) - 4; var fontSize = 14; - if (document.body.clientWidth <= 800) { + if (document.body.clientWidth <= 820) { fontSize = 10; rows = parseInt(clientHeight / 14); cols = parseInt(clientWidth / 3); diff --git a/route/websocket/console.js b/route/websocket/console.js index dd000c51..bd50135a 100644 --- a/route/websocket/console.js +++ b/route/websocket/console.js @@ -9,8 +9,6 @@ const permssion = require('../../helper/Permission'); const { LogHistory } = require('../../helper/LogHistory'); -const BASE_RECORD_DIR = "./server/record_tmp/"; - //日志缓存记录器 MCSERVER.consoleLog = {};