From 16e6037dba52b8382349121e09c705b18968b19f Mon Sep 17 00:00:00 2001 From: W11 Date: Fri, 25 Sep 2026 10:09:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(shell):=20Web=20=E7=BB=88=E7=AB=AF=20resize?= =?UTF-8?q?=20=E5=A4=B1=E6=95=88=E4=BF=AE=E5=A4=8D=E2=80=94=E2=80=94?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=20resize=20=E6=B6=88=E6=81=AF=20Data=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96=E4=B8=BA?= =?UTF-8?q?=20map[string]interface{},=20=E5=AF=B9=20ResizeDataType=20?= =?UTF-8?q?=E7=9A=84=E7=9B=B4=E6=8E=A5=E7=B1=BB=E5=9E=8B=E6=96=AD=E8=A8=80?= =?UTF-8?q?=E6=81=92=E5=A4=B1=E8=B4=A5=E8=A2=AB=E9=9D=99=E9=BB=98=E5=90=9E?= =?UTF-8?q?=E6=8E=89,=20PTY=20=E5=9B=BA=E5=AE=9A=20180x30=20=E4=B8=8E?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E8=84=B1=E8=8A=82;=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=20marshal+unmarshal=20=E8=A7=A3=E7=A0=81?= =?UTF-8?q?=E8=A1=8C=E5=88=97=E5=B9=B6=E6=A0=A1=E9=AA=8C=E6=AD=A3=E5=80=BC?= =?UTF-8?q?=E5=90=8E=20SetSize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/shell_http.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/shell/shell_http.go b/shell/shell_http.go index 350fd09..88a32ad 100644 --- a/shell/shell_http.go +++ b/shell/shell_http.go @@ -176,17 +176,14 @@ func getWebShell(recDir string) gin.HandlerFunc { } } else if opData.Op == "resize" { - fmt.Println("resize") - value, ok := opData.Data.(ResizeDataType) - if ok { - err = proc.SetSize(value.Cols, value.Rows) - if err != nil { - logrus.Errorf("重置大小错误 %d bytes", n) - } else { - fmt.Println("重置大小成功") + // Data 反序列化后是 map[string]interface{}, 不能直接断言 ResizeDataType + // (此前断言恒失败, 前端 resize 被静默吞掉, PTY 固定 180x30) + raw, merr := json.Marshal(opData.Data) + var size ResizeDataType + if merr == nil && json.Unmarshal(raw, &size) == nil && size.Cols > 0 && size.Rows > 0 { + if serr := proc.SetSize(size.Cols, size.Rows); serr != nil { + logrus.Errorf("重置大小错误: %s", serr.Error()) } - } else { - } }