fix: 终端操作col和row初始化问题修复

This commit is contained in:
meilin.huang
2024-02-18 18:42:25 +08:00
parent d711a36749
commit 2133d9b737
4 changed files with 23 additions and 15 deletions

View File

@@ -106,7 +106,6 @@ function init() {
const fitAddon = new FitAddon();
state.addon.fit = fitAddon;
term.loadAddon(fitAddon);
resize();
// 注册搜索组件
const searchAddon = new SearchAddon();
@@ -118,6 +117,7 @@ function init() {
state.addon.weblinks = weblinks;
term.loadAddon(weblinks);
fitTerminal();
// 初始化websocket
initSocket();
}
@@ -159,7 +159,15 @@ const onConnected = () => {
// 自适应终端
const fitTerminal = () => {
resize();
// 获取建议的宽度和高度
const dimensions = state.addon.fit?.proposeDimensions();
if (!dimensions) {
return;
}
if (dimensions?.cols && dimensions?.rows) {
// 调整终端的列数和行数
term.resize(dimensions.cols, dimensions.rows);
}
};
const focus = () => {