fix: ws查看内容cat命令移除showTabs,按下 Ctrl+C补充回车
This commit is contained in:
@@ -14,7 +14,6 @@ func ParseCat(reqData any) (string, error) {
|
||||
var data struct {
|
||||
FilePath string `json:"filePath"` // 文件地址
|
||||
ShowNumber bool `json:"showNumber"` // 显示文件的行号,从 1 开始
|
||||
ShowTabs bool `json:"showTabs"` // 在每行的结尾显示 $ 符号
|
||||
ShowAll bool `json:"showAll"` // 结合 -vET 参数,显示所有特殊字符,包括行尾符、制表符等
|
||||
}
|
||||
if err := json.Unmarshal(msgByte, &data); err != nil {
|
||||
@@ -29,9 +28,6 @@ func ParseCat(reqData any) (string, error) {
|
||||
if data.ShowNumber {
|
||||
command = append(command, "-n")
|
||||
}
|
||||
if data.ShowTabs {
|
||||
command = append(command, "-T")
|
||||
}
|
||||
if data.ShowAll {
|
||||
command = append(command, "-A")
|
||||
}
|
||||
|
||||
@@ -154,8 +154,7 @@ func (s *WSReceiveImpl) ShellView(client *model.WSClient, reqMsg model.WSRequest
|
||||
case "close":
|
||||
s.close(client)
|
||||
return
|
||||
case "cat":
|
||||
case "tail":
|
||||
case "cat", "tail":
|
||||
var command string
|
||||
if reqMsg.Type == "cat" {
|
||||
command, err = processor.ParseCat(reqMsg.Data)
|
||||
@@ -170,7 +169,7 @@ func (s *WSReceiveImpl) ShellView(client *model.WSClient, reqMsg model.WSRequest
|
||||
case "ctrl-c":
|
||||
// 模拟按下 Ctrl+C
|
||||
sshClientSession := client.ChildConn.(*ssh.SSHClientSession)
|
||||
_, err = sshClientSession.Write("\x03")
|
||||
_, err = sshClientSession.Write("\u0003\n")
|
||||
case "resize":
|
||||
// 会话窗口重置
|
||||
msgByte, _ := json.Marshal(reqMsg.Data)
|
||||
|
||||
Reference in New Issue
Block a user