修改拼写错误的单词 (#230)

* 优化图标和LOGO

* 修改登录页面动画的速度为3

* 增加对websocket的异常处理

* 修复了用户组和用户名唯一判断错误的问题

* 提示版本号

* 修复readme错别字

* 修复单词拼写错误的问题

* 修复代码格式
This commit is contained in:
dushixiang
2022-03-05 16:43:04 +08:00
committed by GitHub
parent 11daa8bd4e
commit aa3a6af4ea
15 changed files with 41 additions and 14 deletions

View File

@ -47,7 +47,7 @@ func (api SessionApi) SessionPagingEndpoint(c echo.Context) error {
if status == constant.Disconnected && len(items[i].Recording) > 0 {
var recording string
if items[i].Mode == constant.Naive || items[i].Mode == constant.Terminal {
if items[i].Mode == constant.Native || items[i].Mode == constant.Terminal {
recording = items[i].Recording
} else {
recording = items[i].Recording + "/recording"
@ -170,8 +170,8 @@ func (api SessionApi) SessionCreateEndpoint(c echo.Context) error {
assetId := c.QueryParam("assetId")
mode := c.QueryParam("mode")
if mode == constant.Naive {
mode = constant.Naive
if mode == constant.Native {
mode = constant.Native
} else {
mode = constant.Guacd
}
@ -526,7 +526,7 @@ func (api SessionApi) SessionRecordingEndpoint(c echo.Context) error {
}
var recording string
if s.Mode == constant.Naive || s.Mode == constant.Terminal {
if s.Mode == constant.Native || s.Mode == constant.Terminal {
recording = s.Recording
} else {
recording = s.Recording + "/recording"

View File

@ -70,6 +70,14 @@ func (app App) InitDBData() (err error) {
return err
}
// 修复数据
if err := service.AssetService.FixSshMode(); err != nil {
return err
}
if err := service.SessionService.FixSshMode(); err != nil {
return err
}
return nil
}

View File

@ -55,7 +55,7 @@ const (
Disconnected = "disconnected" // 会话状态:已断开连接
Guacd = "guacd" // 接入模式guacd
Naive = "naive" // 接入模式:原生
Native = "native" // 接入模式:原生
Terminal = "terminal" // 接入模式:终端
TypeUser = "user" // 普通用户

View File

@ -345,3 +345,8 @@ func (r assetRepository) FindAssetAttrMapByAssetId(c context.Context, assetId st
}
return attributeMap, nil
}
func (r assetRepository) UpdateAttrs(c context.Context, name, value, newValue string) error {
sql := "update asset_attributes set value = ? where name = ? and value = ?"
return r.GetDB(c).Exec(sql, newValue, name, value).Error
}

View File

@ -168,3 +168,8 @@ func (r sessionRepository) FindAllUnReviewed(c context.Context) (o []model.Sessi
err = r.GetDB(c).Where("reviewed = false or reviewed is null").Find(&o).Error
return
}
func (r sessionRepository) UpdateMode(c context.Context) error {
sql := "update sessions set mode = 'native' where mode = 'naive'"
return r.GetDB(c).Exec(sql).Error
}

View File

@ -6,6 +6,7 @@ import (
"encoding/json"
"next-terminal/server/config"
"next-terminal/server/constant"
"next-terminal/server/env"
"next-terminal/server/model"
"next-terminal/server/repository"
@ -260,3 +261,7 @@ func (s assetService) UpdateById(id string, m echo.Map) error {
})
}
func (s assetService) FixSshMode() error {
return repository.AssetRepository.UpdateAttrs(context.TODO(), "ssh-mode", "naive", constant.Native)
}

View File

@ -118,7 +118,7 @@ func (service sessionService) WriteCloseMessage(ws *websocket.Conn, mode string,
disconnect := guacd.NewInstruction("disconnect")
_ = ws.WriteMessage(websocket.TextMessage, []byte(disconnect.String()))
}
case constant.Naive:
case constant.Native:
if ws != nil {
msg := `0` + reason
_ = ws.WriteMessage(websocket.TextMessage, []byte(msg))
@ -354,3 +354,7 @@ func (service sessionService) Create(clientIp, assetId, mode string, user *model
}
return s, nil
}
func (service sessionService) FixSshMode() error {
return repository.SessionRepository.UpdateMode(context.TODO())
}