mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-08-27 21:30:25 +02:00
Add files via upload
This commit is contained in:
@@ -121,6 +121,13 @@
|
|||||||
ws.onopen = function () {
|
ws.onopen = function () {
|
||||||
if (tab.term) {
|
if (tab.term) {
|
||||||
tab.term.focus();
|
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) {
|
term.onData(function (data) {
|
||||||
// Ctrl+L:本地清屏,同时把 ^L 也发给后端
|
// Ctrl+L:本地清屏,同时把 ^L 也发给后端
|
||||||
if (data === '\x0c') {
|
if (data === '\x0c') {
|
||||||
@@ -235,6 +250,12 @@
|
|||||||
sendToWS(data);
|
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.term = term;
|
||||||
tab.fitAddon = fitAddon;
|
tab.fitAddon = fitAddon;
|
||||||
// 立即建立 WebSocket,让后端 PTY/Shell 马上启动并输出提示符;
|
// 立即建立 WebSocket,让后端 PTY/Shell 马上启动并输出提示符;
|
||||||
|
|||||||
Reference in New Issue
Block a user