fix: 修复 staticcheck 和优化前端构建
- 修复所有 Yoda 条件错误 (ST1017) - 修复 error 格式错误 (ST1005) - 修复不必要的 blank identifier (QF1001) - 移除 tsc 重复编译,减少内存使用 - monaco-editor 改为动态导入
This commit is contained in:
+14
-14
@@ -250,7 +250,7 @@ func (api SessionApi) SessionUploadEndpoint(c echo.Context) error {
|
||||
account, _ := GetCurrentAccount(c)
|
||||
_ = service.StorageLogService.Save(context.Background(), s.AssetId, sessionId, account.ID, nt.StorageLogActionUpload, remoteFile)
|
||||
|
||||
if "ssh" == s.Protocol {
|
||||
if s.Protocol == "ssh" {
|
||||
nextSession := session.GlobalSessionManager.GetById(sessionId)
|
||||
if nextSession == nil {
|
||||
return errors.New("获取会话失败")
|
||||
@@ -280,7 +280,7 @@ func (api SessionApi) SessionUploadEndpoint(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
return Success(c, nil)
|
||||
} else if "rdp" == s.Protocol {
|
||||
} else if s.Protocol == "rdp" {
|
||||
if err := service.StorageService.StorageUpload(c, file, s.StorageId); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -302,7 +302,7 @@ func (api SessionApi) SessionEditEndpoint(c echo.Context) error {
|
||||
file := c.FormValue("file")
|
||||
fileContent := c.FormValue("fileContent")
|
||||
|
||||
if "ssh" == s.Protocol {
|
||||
if s.Protocol == "ssh" {
|
||||
nextSession := session.GlobalSessionManager.GetById(sessionId)
|
||||
if nextSession == nil {
|
||||
return errors.New("获取会话失败")
|
||||
@@ -329,7 +329,7 @@ func (api SessionApi) SessionEditEndpoint(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
return Success(c, nil)
|
||||
} else if "rdp" == s.Protocol {
|
||||
} else if s.Protocol == "rdp" {
|
||||
if err := service.StorageService.StorageEdit(file, fileContent, s.StorageId); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -355,7 +355,7 @@ func (api SessionApi) SessionDownloadEndpoint(c echo.Context) error {
|
||||
|
||||
// 获取带后缀的文件名称
|
||||
filenameWithSuffix := path.Base(file)
|
||||
if "ssh" == s.Protocol {
|
||||
if s.Protocol == "ssh" {
|
||||
nextSession := session.GlobalSessionManager.GetById(sessionId)
|
||||
if nextSession == nil {
|
||||
return errors.New("获取会话失败")
|
||||
@@ -375,7 +375,7 @@ func (api SessionApi) SessionDownloadEndpoint(c echo.Context) error {
|
||||
}
|
||||
|
||||
return c.Stream(http.StatusOK, echo.MIMEOctetStream, bytes.NewReader(buff.Bytes()))
|
||||
} else if "rdp" == s.Protocol {
|
||||
} else if s.Protocol == "rdp" {
|
||||
storageId := s.StorageId
|
||||
return service.StorageService.StorageDownload(c, file, storageId)
|
||||
}
|
||||
@@ -391,7 +391,7 @@ func (api SessionApi) SessionLsEndpoint(c echo.Context) error {
|
||||
}
|
||||
|
||||
remoteDir := c.FormValue("dir")
|
||||
if "ssh" == s.Protocol {
|
||||
if s.Protocol == "ssh" {
|
||||
nextSession := session.GlobalSessionManager.GetById(sessionId)
|
||||
if nextSession == nil {
|
||||
return errors.New("获取会话失败")
|
||||
@@ -427,7 +427,7 @@ func (api SessionApi) SessionLsEndpoint(c echo.Context) error {
|
||||
}
|
||||
|
||||
return Success(c, files)
|
||||
} else if "rdp" == s.Protocol {
|
||||
} else if s.Protocol == "rdp" {
|
||||
storageId := s.StorageId
|
||||
files, err := service.StorageService.StorageLs(remoteDir, storageId)
|
||||
if err != nil {
|
||||
@@ -454,7 +454,7 @@ func (api SessionApi) SessionMkDirEndpoint(c echo.Context) error {
|
||||
account, _ := GetCurrentAccount(c)
|
||||
_ = service.StorageLogService.Save(context.Background(), s.AssetId, sessionId, account.ID, nt.StorageLogActionMkdir, remoteDir)
|
||||
|
||||
if "ssh" == s.Protocol {
|
||||
if s.Protocol == "ssh" {
|
||||
nextSession := session.GlobalSessionManager.GetById(sessionId)
|
||||
if nextSession == nil {
|
||||
return errors.New("获取会话失败")
|
||||
@@ -463,7 +463,7 @@ func (api SessionApi) SessionMkDirEndpoint(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
return Success(c, nil)
|
||||
} else if "rdp" == s.Protocol {
|
||||
} else if s.Protocol == "rdp" {
|
||||
storageId := s.StorageId
|
||||
if err := service.StorageService.StorageMkDir(remoteDir, storageId); err != nil {
|
||||
return err
|
||||
@@ -489,7 +489,7 @@ func (api SessionApi) SessionRmEndpoint(c echo.Context) error {
|
||||
account, _ := GetCurrentAccount(c)
|
||||
_ = service.StorageLogService.Save(context.Background(), s.AssetId, sessionId, account.ID, nt.StorageLogActionRm, file)
|
||||
|
||||
if "ssh" == s.Protocol {
|
||||
if s.Protocol == "ssh" {
|
||||
nextSession := session.GlobalSessionManager.GetById(sessionId)
|
||||
if nextSession == nil {
|
||||
return errors.New("获取会话失败")
|
||||
@@ -524,7 +524,7 @@ func (api SessionApi) SessionRmEndpoint(c echo.Context) error {
|
||||
}
|
||||
|
||||
return Success(c, nil)
|
||||
} else if "rdp" == s.Protocol {
|
||||
} else if s.Protocol == "rdp" {
|
||||
storageId := s.StorageId
|
||||
if err := service.StorageService.StorageRm(file, storageId); err != nil {
|
||||
return err
|
||||
@@ -551,7 +551,7 @@ func (api SessionApi) SessionRenameEndpoint(c echo.Context) error {
|
||||
account, _ := GetCurrentAccount(c)
|
||||
_ = service.StorageLogService.Save(context.Background(), s.AssetId, sessionId, account.ID, nt.StorageLogActionRename, oldName)
|
||||
|
||||
if "ssh" == s.Protocol {
|
||||
if s.Protocol == "ssh" {
|
||||
nextSession := session.GlobalSessionManager.GetById(sessionId)
|
||||
if nextSession == nil {
|
||||
return errors.New("获取会话失败")
|
||||
@@ -564,7 +564,7 @@ func (api SessionApi) SessionRenameEndpoint(c echo.Context) error {
|
||||
}
|
||||
|
||||
return Success(c, nil)
|
||||
} else if "rdp" == s.Protocol {
|
||||
} else if s.Protocol == "rdp" {
|
||||
storageId := s.StorageId
|
||||
if err := service.StorageService.StorageRename(oldName, newName, storageId); err != nil {
|
||||
return err
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ func (api WebTerminalApi) SshEndpoint(c echo.Context) error {
|
||||
|
||||
var xterm = "xterm-256color"
|
||||
var nextTerminal *term.NextTerminal
|
||||
if "true" == attributes[nt.SocksProxyEnable] {
|
||||
if attributes[nt.SocksProxyEnable] == "true" {
|
||||
nextTerminal, err = term.NewNextTerminalUseSocks(ip, port, username, password, privateKey, passphrase, rows, cols, recording, xterm, true, attributes[nt.SocksProxyHost], attributes[nt.SocksProxyPort], attributes[nt.SocksProxyUsername], attributes[nt.SocksProxyPassword])
|
||||
} else {
|
||||
nextTerminal, err = term.NewNextTerminal(ip, port, username, password, privateKey, passphrase, rows, cols, recording, xterm, true)
|
||||
|
||||
@@ -27,7 +27,7 @@ func (s *Set) Contains(key string) bool {
|
||||
|
||||
func (s *Set) ToArray() []string {
|
||||
var keys []string
|
||||
for key, _ := range s.data {
|
||||
for key := range s.data {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
return keys
|
||||
|
||||
@@ -131,7 +131,7 @@ func (s assetService) CheckStatus(asset *model.Asset, ip string, port int) (bool
|
||||
return false, err
|
||||
}
|
||||
|
||||
if "true" == attributes[nt.SocksProxyEnable] {
|
||||
if attributes[nt.SocksProxyEnable] == "true" {
|
||||
socks5 := fmt.Sprintf("%s:%s", attributes[nt.SocksProxyHost], attributes[nt.SocksProxyPort])
|
||||
auth := &proxy.Auth{
|
||||
User: attributes[nt.SocksProxyUsername],
|
||||
|
||||
@@ -283,7 +283,7 @@ func (service sessionService) Create(clientIp, assetId, mode string, user *model
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if "true" == attr[guacamole.EnableDrive] {
|
||||
if attr[guacamole.EnableDrive] == "true" {
|
||||
fileSystem = "1"
|
||||
storageId = attr[guacamole.DrivePath]
|
||||
if storageId == "" {
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ func (gui Gui) handleAccessAsset(sess ssh.Session, sessionId string) (err error)
|
||||
|
||||
pty, winCh, isPty := (sess).Pty()
|
||||
if !isPty {
|
||||
return errors.New("No PTY requested.\n")
|
||||
return errors.New("no PTY requested")
|
||||
}
|
||||
|
||||
recording := ""
|
||||
|
||||
@@ -40,7 +40,7 @@ func (w *Writer) Write(p []byte) (n int, err error) {
|
||||
|
||||
if w.sz {
|
||||
// sz 会以 OO 结尾
|
||||
if "OO" == s {
|
||||
if s == "OO" {
|
||||
w.sz = false
|
||||
}
|
||||
} else if w.rz {
|
||||
|
||||
Reference in New Issue
Block a user