Add files via upload

This commit is contained in:
公明
2026-03-06 20:11:22 +08:00
committed by GitHub
parent d9a0178f80
commit 27830d1399
4 changed files with 21 additions and 6 deletions
+2 -2
View File
@@ -96,7 +96,7 @@ func (h *TerminalHandler) RunCommand(c *gin.Context) {
} else {
cmd = exec.CommandContext(ctx, shell, "-c", cmdStr)
// 无 TTY 时设置 COLUMNS/TERM,使 ping 等工具的 usage 排版与真实终端一致
cmd.Env = append(os.Environ(), "COLUMNS=120", "LINES=40", "TERM=xterm-256color")
cmd.Env = append(os.Environ(), "COLUMNS=256", "LINES=40", "TERM=xterm-256color")
}
if req.Cwd != "" {
@@ -218,7 +218,7 @@ func (h *TerminalHandler) RunCommandStream(c *gin.Context) {
cmd = exec.CommandContext(ctx, "cmd", "/c", cmdStr)
} else {
cmd = exec.CommandContext(ctx, shell, "-c", cmdStr)
cmd.Env = append(os.Environ(), "COLUMNS=120", "LINES=40", "TERM=xterm-256color")
cmd.Env = append(os.Environ(), "COLUMNS=256", "LINES=40", "TERM=xterm-256color")
}
if req.Cwd != "" {
absCwd, err := filepath.Abs(req.Cwd)
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"github.com/creack/pty"
)
const ptyCols = 120
const ptyCols = 256
const ptyRows = 40
// runCommandStreamImpl 在 Unix 下用 PTY 执行,使 ping 等命令按终端宽度排版(isatty 为真)
+2 -2
View File
@@ -37,7 +37,7 @@ func (h *TerminalHandler) RunCommandWS(c *gin.Context) {
}
cmd := exec.Command(shell)
cmd.Env = append(os.Environ(),
"COLUMNS=120",
"COLUMNS=256",
"LINES=40",
"TERM=xterm-256color",
)
@@ -55,7 +55,7 @@ func (h *TerminalHandler) RunCommandWS(c *gin.Context) {
for {
n, err := ptmx.Read(buf)
if n > 0 {
_ = conn.WriteMessage(websocket.TextMessage, buf[:n])
_ = conn.WriteMessage(websocket.BinaryMessage, buf[:n])
}
if err != nil {
break