refactor: code rewiew&功能小优化

This commit is contained in:
meilin.huang
2022-08-13 19:31:16 +08:00
parent 64805360d6
commit 0f54d4a472
14 changed files with 308 additions and 273 deletions

View File

@@ -160,21 +160,16 @@ func (m *Machine) WsSSH(g *gin.Context) {
panic(biz.NewBizErr("\033[1;31m您没有权限操作该机器终端,请重新登录后再试~\033[0m"))
}
cols := ginx.QueryInt(g, "cols", 80)
rows := ginx.QueryInt(g, "rows", 40)
cli := m.MachineApp.GetCli(GetMachineId(g))
biz.ErrIsNilAppendErr(m.ProjectApp.CanAccess(rc.LoginAccount.Id, cli.GetMachine().ProjectId), "%s")
sws, err := machine.NewLogicSshWsSession(cols, rows, cli, wsConn)
biz.ErrIsNilAppendErr(err, "\033[1;31m连接失败%s\033[0m")
defer sws.Close()
cols := ginx.QueryInt(g, "cols", 80)
rows := ginx.QueryInt(g, "rows", 40)
quitChan := make(chan bool, 3)
sws.Start(quitChan)
go sws.Wait(quitChan)
<-quitChan
mts, err := machine.NewTerminalSession(utils.RandString(16), wsConn, cli, rows, cols)
biz.ErrIsNilAppendErr(err, "\033[1;31m连接失败: %s\033[0m")
mts.Start()
defer mts.Stop()
}
func GetMachineId(g *gin.Context) uint64 {