改善北京航空航天大学操作系统实验环境的体验。
- 优化了终端,使得其能够填满整个屏幕;
- 登录页的验证码现已不再自动填充。
【推荐】t123yh提供的课程中心脚本
【关于字体更换】
方法1. 【警告⚠,需要对终端文件进行操作,请小心行事】
更改文件,将其中的字体(例如courier-new
)更换为你想要的字体(例如Consolas
)。
/opt/conda/lib/python3.7/site-packages/notebook/static/components/xterm.js/index.js:
fontFamily: 'courier-new, courier, monospace',
/opt/conda/lib/python3.7/site-packages/notebook/static/components/xterm.js-css/index.css:
font-family: courier-new, courier, monospace;
方法2. 【提示ℹ,可能会引起卡顿】
使用脚本【感谢 @t123yh 提供的脚本】
// ==UserScript==
// @name 北航 OS 换字体
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author t123yh
// @match http://course.educg.net:7001/*/terminals/1
// @grant none
// ==/UserScript==
const fontFamily = "Ubuntu Mono", fontSize = 20; //可以在这里更换你想要的字体和大小
(function() {
'use strict';
window.$(function() {
setTimeout(function() {
window.terminal.term.destroy();
window.define('terminal/js/terminado2', ["xterm", "xtermjs-fit"], function(Terminal, fit) {
"use strict";
function make_terminal(element, ws_url) {
var ws = new WebSocket(ws_url);
Terminal.applyAddon(fit);
var term = new Terminal({fontFamily: fontFamily, fontSize: fontSize});
ws.onopen = function(event) {
term.on('data', function(data) {
ws.send(JSON.stringify(['stdin', data]));
});
term.on('title', function(title) {
document.title = title;
});
term.open(element);
term.fit();
// send the terminal size to the server.
ws.send(JSON.stringify(["set_size", term.rows, term.cols, window.innerHeight, window.innerWidth]));
ws.onmessage = function(event) {
var json_msg = JSON.parse(event.data);
switch (json_msg[0]) {
case "stdout":
term.write(json_msg[1]);
break;
case "disconnect":
term.write("\r\n\r\n[CLOSED]\r\n");
break;
}
}
;
}
;
return {
socket: ws,
term: term
};
}
return {
make_terminal: make_terminal
};
});
window.requirejs(['jquery', 'base/js/utils', 'base/js/page', 'auth/js/loginwidget', 'services/config', 'terminal/js/terminado2', ], function($, utils, page, loginwidget, configmod, terminado) {
"use strict";
requirejs(['custom/custom'], function() {});
page = new page.Page('div#header','div#site');
var common_options = {
base_url: utils.get_body_data("baseUrl"),
};
var config = new configmod.ConfigSection('terminal',common_options);
config.load();
var common_config = new configmod.ConfigSection('common',common_options);
common_config.load();
// This makes the 'logout' button in the top right work.
var login_widget = new loginwidget.LoginWidget('span#login_widget',common_options);
var base_url = utils.get_body_data('baseUrl').replace(/\/?$/, '/');
var ws_path = utils.get_body_data('wsPath');
var ws_url = utils.get_body_data('wsUrl');
if (!ws_url) {
// trailing 's' in https will become wss for secure web sockets
ws_url = location.protocol.replace('http', 'ws') + "//" + location.host;
}
ws_url = ws_url + base_url + ws_path;
page.show_header();
var terminal = terminado.make_terminal($("#terminado-container")[0], ws_url);
page.show_site();
utils.load_extensions_from_config(config);
utils.load_extensions_from_config(common_config);
window.onresize = function() {
terminal.term.fit();
// send the new size to the server so that it can trigger a resize in the running process.
terminal.socket.send(JSON.stringify(["set_size", terminal.term.rows, terminal.term.cols, $(window).height(), $(window).width()]));
}
;
// Expose terminal for fiddling with in the browser
window.terminal = terminal;
});
},1000);
});
})();