From c74883bde947a502ed204a633068a4ed6d202485 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Fri, 30 Dec 2022 17:36:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=BB=E6=9C=BA=E6=A0=91=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=B0=83=E6=95=B4=E3=80=81=E8=A1=A8=E5=8D=95=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/model/host.go | 2 +- backend/app/service/host.go | 3 + frontend/src/lang/modules/en.ts | 2 + frontend/src/lang/modules/zh.ts | 4 +- .../src/views/host/terminal/command/index.vue | 9 +- .../src/views/host/terminal/host/index.vue | 61 ++- frontend/src/views/host/terminal/index.vue | 455 +---------------- .../host/terminal/terminal/host-create.vue | 130 +++++ .../views/host/terminal/terminal/index.vue | 466 +++++++++++++----- .../views/host/terminal/terminal/terminal.vue | 173 +++++++ frontend/src/views/setting/safe/index.vue | 2 +- 11 files changed, 698 insertions(+), 609 deletions(-) create mode 100644 frontend/src/views/host/terminal/terminal/host-create.vue create mode 100644 frontend/src/views/host/terminal/terminal/terminal.vue diff --git a/backend/app/model/host.go b/backend/app/model/host.go index 9a21ef052..46f52dfaa 100644 --- a/backend/app/model/host.go +++ b/backend/app/model/host.go @@ -3,7 +3,7 @@ package model type Host struct { BaseModel GroupBelong string `gorm:"type:varchar(64);not null" json:"groupBelong"` - Name string `gorm:"type:varchar(64);unique;not null" json:"name"` + Name string `gorm:"type:varchar(64);not null" json:"name"` Addr string `gorm:"type:varchar(16);not null" json:"addr"` Port int `gorm:"type:varchar(5);not null" json:"port"` User string `gorm:"type:varchar(64);not null" json:"user"` diff --git a/backend/app/service/host.go b/backend/app/service/host.go index a2d5ca9c2..bc88dfeba 100644 --- a/backend/app/service/host.go +++ b/backend/app/service/host.go @@ -48,6 +48,9 @@ func (u *HostService) SearchForTree(search dto.SearchForTree) ([]dto.HostTree, e data.Label = group.Name for _, host := range hosts { label := fmt.Sprintf("%s@%s:%d", host.User, host.Addr, host.Port) + if len(host.Name) != 0 { + label = fmt.Sprintf("%s-%s@%s:%d", host.Name, host.User, host.Addr, host.Port) + } if host.GroupBelong == group.Name { data.Children = append(data.Children, dto.TreeChild{ID: host.ID, Label: label}) } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index a2d6e547c..0a0d28ea1 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -57,6 +57,7 @@ export default { message: 'Message', description: 'Description', interval: 'Interval', + title: 'Title', }, msg: { delete: 'This operation cannot be rolled back. Do you want to continue', @@ -555,6 +556,7 @@ export default { }, terminal: { conn: 'connection', + connLocalErr: 'Unable to automatically authenticate, please fill in the local server login information!', testConn: 'Test connection', saveAndConn: 'Save and Connect', connTestOk: 'Connection information available', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 591acfc76..c92e6f4fa 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -50,7 +50,7 @@ export default { statusSuccess: '成功', statusFailed: '失败', records: '任务输出', - group: '组', + group: '分组', createdAt: '创建时间', date: '时间', updatedAt: '更新时间', @@ -58,6 +58,7 @@ export default { message: '信息', description: '描述信息', interval: '耗时', + title: '标题', }, msg: { delete: '删除 操作不可回滚,是否继续', @@ -568,6 +569,7 @@ export default { }, terminal: { conn: '连接', + connLocalErr: '无法自动认证,请填写本地服务器的登录信息!', testConn: '连接测试', saveAndConn: '保存并连接', connTestOk: '连接信息可用', diff --git a/frontend/src/views/host/terminal/command/index.vue b/frontend/src/views/host/terminal/command/index.vue index d60e915d7..8117c301c 100644 --- a/frontend/src/views/host/terminal/command/index.vue +++ b/frontend/src/views/host/terminal/command/index.vue @@ -65,6 +65,10 @@ const rules = reactive({ }); let operate = ref('create'); +const acceptParams = () => { + search(); +}; + let commandInfo = reactive({ id: 0, name: '', @@ -146,10 +150,7 @@ const search = async () => { paginationConfig.total = res.data.total; }; -function onInit() { - search(); -} defineExpose({ - onInit, + acceptParams, }); diff --git a/frontend/src/views/host/terminal/host/index.vue b/frontend/src/views/host/terminal/host/index.vue index 40cc02d80..893314b7c 100644 --- a/frontend/src/views/host/terminal/host/index.vue +++ b/frontend/src/views/host/terminal/host/index.vue @@ -46,7 +46,12 @@ > - diff --git a/frontend/src/views/host/terminal/terminal/terminal.vue b/frontend/src/views/host/terminal/terminal/terminal.vue new file mode 100644 index 000000000..273cafd13 --- /dev/null +++ b/frontend/src/views/host/terminal/terminal/terminal.vue @@ -0,0 +1,173 @@ + + + + diff --git a/frontend/src/views/setting/safe/index.vue b/frontend/src/views/setting/safe/index.vue index 71d7da6f7..1cb31ec98 100644 --- a/frontend/src/views/setting/safe/index.vue +++ b/frontend/src/views/setting/safe/index.vue @@ -127,7 +127,7 @@ import i18n from '@/lang'; import { Rules } from '@/global/form-rules'; import { dateFromat } from '@/utils/util'; -const emit = defineEmits(['on-save', 'search']); +const emit = defineEmits(['search']); const loading = ref(false); const form = reactive({