Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
修改拼写错误的单词 (#230)
Browse files Browse the repository at this point in the history
* 优化图标和LOGO

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

* 增加对websocket的异常处理

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

* 提示版本号

* 修复readme错别字

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

* 修复代码格式
  • Loading branch information
dushixiang authored Mar 5, 2022
1 parent 11daa8b commit aa3a6af
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ https://next.typesafe.cn/ 账号:test 密码:test

## License

Next Terminal 使用 [AGPL-3.0](./LICENSE) 开源协议,请自觉准守
Next Terminal 使用 [AGPL-3.0](./LICENSE) 开源协议,请自觉遵守

## 赞助支持

Expand Down
8 changes: 4 additions & 4 deletions server/api/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions server/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion server/constant/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const (
Disconnected = "disconnected" // 会话状态:已断开连接

Guacd = "guacd" // 接入模式:guacd
Naive = "naive" // 接入模式:原生
Native = "native" // 接入模式:原生
Terminal = "terminal" // 接入模式:终端

TypeUser = "user" // 普通用户
Expand Down
5 changes: 5 additions & 0 deletions server/repository/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions server/repository/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions server/service/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
6 changes: 5 additions & 1 deletion server/service/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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())
}
2 changes: 1 addition & 1 deletion web/src/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export const PROTOCOL_COLORS = {

export const MODE_COLORS = {
'guacd': 'green',
'naive': 'orange',
'native': 'orange',
'terminal': 'purple',
}
2 changes: 1 addition & 1 deletion web/src/components/access/BatchCommandTerm.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class BatchCommandTerm extends Component {
}

async createSession(assetsId) {
let result = await request.post(`/sessions?assetId=${assetsId}&mode=naive`);
let result = await request.post(`/sessions?assetId=${assetsId}&mode=native`);
if (result['code'] !== 1) {
this.showMessage(result['message']);
return null;
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/access/Term.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class Term extends Component {
}

async createSession(assetsId) {
let result = await request.post(`/sessions?assetId=${assetsId}&mode=naive`);
let result = await request.post(`/sessions?assetId=${assetsId}&mode=native`);
if (result['code'] !== 1) {
this.showMessage(result['message']);
return undefined;
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/asset/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ class Asset extends Component {
const name = record['name'];
const sshMode = record['sshMode'];
let url = '';
if (protocol === 'ssh' && sshMode === 'naive') {
if (protocol === 'ssh' && sshMode === 'native') {
url = `#/term?assetId=${id}&assetName=${name}`;
} else {
url = `#/access?assetId=${id}&assetName=${name}&protocol=${protocol}`;
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/asset/AssetModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ Windows需要对远程应用程序的名称使用特殊的符号。
setSshMode(value)
}}>
<Option value="">guacd</Option>
<Option value="naive">原生</Option>
<Option value="native">原生</Option>
</Select>
</Form.Item>
</Panel>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/asset/MyAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class MyAsset extends Component {
const name = item['name'];
const sshMode = item['sshMode'];
let url = '';
if (protocol === 'ssh' && sshMode === 'naive') {
if (protocol === 'ssh' && sshMode === 'native') {
url = `#/term?assetId=${id}&assetName=${name}`;
} else {
url = `#/access?assetId=${id}&assetName=${name}&protocol=${protocol}`;
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/session/OfflineSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ class OfflineSession extends Component {
maskClosable={false}
>
{
this.state.selectedRow['mode'] === 'naive' || this.state.selectedRow['mode'] === 'terminal' ?
this.state.selectedRow['mode'] === 'native' || this.state.selectedRow['mode'] === 'terminal' ?
<iframe
title='recording'
style={{
Expand Down

0 comments on commit aa3a6af

Please sign in to comment.