Add files via upload

This commit is contained in:
公明
2026-04-10 16:44:49 +08:00
committed by GitHub
parent bb9e3f9477
commit ae3bc41c88

View File

@@ -121,6 +121,13 @@
ws.onopen = function () {
if (tab.term) {
tab.term.focus();
// Send the actual terminal dimensions to the backend immediately
// so the PTY size matches what xterm.js is displaying.
if (tab.term.cols && tab.term.rows) {
try {
ws.send(JSON.stringify({ type: 'resize', cols: tab.term.cols, rows: tab.term.rows }));
} catch (e) {}
}
}
};
@@ -225,6 +232,14 @@
}
}
function sendResize() {
if (tab.ws && tab.ws.readyState === WebSocket.OPEN && term.cols && term.rows) {
try {
tab.ws.send(JSON.stringify({ type: 'resize', cols: term.cols, rows: term.rows }));
} catch (e) {}
}
}
term.onData(function (data) {
// Ctrl+L本地清屏同时把 ^L 也发给后端
if (data === '\x0c') {
@@ -235,6 +250,12 @@
sendToWS(data);
});
// Notify backend when the terminal is resized so the PTY dimensions stay in sync.
// This is critical for full-screen programs like vi/vim/less to render correctly.
term.onResize(function (size) {
sendResize();
});
tab.term = term;
tab.fitAddon = fitAddon;
// 立即建立 WebSocket让后端 PTY/Shell 马上启动并输出提示符;