forked from mirror/MCSManager
优化 终端控制台用户体验
This commit is contained in:
parent
7516c6a6ae
commit
4b1b1f0c84
@ -123,36 +123,43 @@
|
||||
MI.routeCopy('OneUserView', data.obj);
|
||||
});
|
||||
|
||||
//Minecraft 服务器终端插入
|
||||
// Minecraft 服务器终端换行替换符
|
||||
var terminalEncode = function (text) {
|
||||
var consoleSafe = TOOLS.encode(text);
|
||||
consoleSafe = consoleSafe.replace(/\[_b_r_\]/igm, '<br>');
|
||||
return consoleSafe;
|
||||
}
|
||||
|
||||
// 终端控制台界面,实时接受服务端终端日志
|
||||
// 每当控制面板后端发送实时日志,都将第一时间触发此
|
||||
MI.routeListener('server/console/ws', function (data) {
|
||||
// 文本编码成 html 编码方式
|
||||
var consoleSafe = terminalEncode(data.body);
|
||||
// 因子页面生命周期,必须单独获取 dom
|
||||
var MinecraftConsole = document.getElementById('TerminalMinecraft');
|
||||
if (MinecraftConsole == null) {
|
||||
console.error('MinecraftConsole is null');
|
||||
return;
|
||||
}
|
||||
// 终端最长长度限制
|
||||
if (MinecraftConsole.innerHTML.length > 340000) {
|
||||
MinecraftConsole.innerHTML = "<br /><br />[ 控制面板 ]: 日志显示过长,为避免网页卡顿,现已自动清空。<br />[ 控制面板 ]: 若想回看历史日志,请点击右上角刷新按钮,再重新进入点击 [历史] 按钮即可。<br /><br />"
|
||||
}
|
||||
var flag = false;
|
||||
//判断用户是否自己移动了滚轴
|
||||
// 判断用户是否自己移动了滚轴
|
||||
var BUFF_FONTIER_SIZE_DOWN = MinecraftConsole.scrollHeight - MinecraftConsole.clientHeight;
|
||||
flag = (MinecraftConsole.scrollTop + 354 >= BUFF_FONTIER_SIZE_DOWN);
|
||||
//color
|
||||
// 处理控制台颜色与双问号
|
||||
consoleSafe = TOOLS.encodeConsoleColor(consoleSafe);
|
||||
consoleSafe = TOOLS.deletDoubleS(consoleSafe);
|
||||
//add
|
||||
// 插入到页面控制台中
|
||||
MinecraftConsole.innerHTML += consoleSafe;
|
||||
//unblive bt ths is t
|
||||
|
||||
if (flag)
|
||||
MinecraftConsole.scrollTop = MinecraftConsole.scrollHeight;
|
||||
|
||||
});
|
||||
|
||||
//获取控制台历史记录
|
||||
// 获取MC服务端终端日志历史记录
|
||||
MI.routeListener('server/console/history', function (data) {
|
||||
var consoleSafe = terminalEncode(data.body);
|
||||
var MinecraftConsole = document.getElementById('TerminalMinecraft');
|
||||
@ -167,16 +174,17 @@
|
||||
MinecraftConsole.scrollTop = resVTopLac - 999;
|
||||
});
|
||||
|
||||
//普通用户主页
|
||||
// 普通用户主页
|
||||
MI.routeListener('genuser/home', function (data) {
|
||||
MI.routeCopy('GenHome', data.obj);
|
||||
});
|
||||
|
||||
//配置项试图
|
||||
// 配置项试图
|
||||
MI.routeListener('server/properties', function (data) {
|
||||
MI.routeCopy('ServerProperties', data.obj);
|
||||
});
|
||||
|
||||
// 计划任务列表
|
||||
MI.routeListener('schedule/list', function (data) {
|
||||
MI.routeCopy('ServerSchedule', data.obj);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user