diff --git a/core/app/api/v2/setting.go b/core/app/api/v2/setting.go index e1ff0f952..c63ce270c 100644 --- a/core/app/api/v2/setting.go +++ b/core/app/api/v2/setting.go @@ -71,16 +71,19 @@ func (b *BaseApi) UpdateSetting(c *gin.Context) { if err := helper.CheckBindAndValidate(&req, c); err != nil { return } + if req.Key == "SecurityEntrance" { + if !checkEntrancePattern(req.Value) { + helper.ErrorWithDetail(c, http.StatusBadRequest, "ErrInvalidParams", fmt.Errorf("the format of the security entrance %s is incorrect.", req.Value)) + return + } + } + if err := settingService.Update(req.Key, req.Value); err != nil { helper.InternalServer(c, err) return } if req.Key == "SecurityEntrance" { entranceValue := base64.StdEncoding.EncodeToString([]byte(req.Value)) - if !checkEntrancePattern(entranceValue) { - helper.ErrorWithDetail(c, http.StatusBadRequest, "ErrInvalidParams", fmt.Errorf("the format of the security entrance %s is incorrect.", entranceValue)) - return - } c.SetCookie("SecurityEntrance", entranceValue, 0, "", "", false, true) } helper.SuccessWithOutData(c) diff --git a/core/app/service/command.go b/core/app/service/command.go index 1d50a624c..d99d28e5a 100644 --- a/core/app/service/command.go +++ b/core/app/service/command.go @@ -14,7 +14,7 @@ type ICommandService interface { List(req dto.OperateByType) ([]dto.CommandInfo, error) SearchForTree(req dto.OperateByType) ([]dto.CommandTree, error) SearchWithPage(search dto.SearchCommandWithPage) (int64, interface{}, error) - Create(commandDto dto.CommandOperate) error + Create(req dto.CommandOperate) error Update(id uint, upMap map[string]interface{}) error Delete(ids []uint) error } @@ -98,12 +98,12 @@ func (u *CommandService) SearchWithPage(req dto.SearchCommandWithPage) (int64, i return total, dtoCommands, err } -func (u *CommandService) Create(commandDto dto.CommandOperate) error { - command, _ := commandRepo.Get(repo.WithByName(commandDto.Name)) +func (u *CommandService) Create(req dto.CommandOperate) error { + command, _ := commandRepo.Get(repo.WithByName(req.Name), repo.WithByType(req.Type)) if command.ID != 0 { return buserr.New("ErrRecordExist") } - if err := copier.Copy(&command, &commandDto); err != nil { + if err := copier.Copy(&command, &req); err != nil { return buserr.WithDetail("ErrStructTransform", err.Error(), nil) } if err := commandRepo.Create(&command); err != nil { diff --git a/core/app/service/host.go b/core/app/service/host.go index b8dd29b09..1dfc63758 100644 --- a/core/app/service/host.go +++ b/core/app/service/host.go @@ -23,7 +23,7 @@ type IHostService interface { GetHostByID(id uint) (*dto.HostInfo, error) SearchForTree(search dto.SearchForTree) ([]dto.HostTree, error) SearchWithPage(search dto.SearchPageWithGroup) (int64, interface{}, error) - Create(hostDto dto.HostOperate) (*dto.HostInfo, error) + Create(req dto.HostOperate) (*dto.HostInfo, error) Update(id uint, upMap map[string]interface{}) (*dto.HostInfo, error) Delete(id []uint) error @@ -300,16 +300,19 @@ func (u *HostService) Create(req dto.HostOperate) (*dto.HostInfo, error) { } func (u *HostService) Delete(ids []uint) error { - hosts, _ := hostRepo.GetList(repo.WithByIDs(ids)) - for _, host := range hosts { + for _, id := range ids { + host, _ := hostRepo.Get(repo.WithByID(id)) if host.ID == 0 { return buserr.New("ErrRecordNotFound") } - if host.Addr == "127.0.0.1" { + if host.Name == "local" { return errors.New("the local connection information cannot be deleted!") } + if err := hostRepo.Delete(repo.WithByID(id)); err != nil { + return err + } } - return hostRepo.Delete(repo.WithByIDs(ids)) + return nil } func (u *HostService) Update(id uint, upMap map[string]interface{}) (*dto.HostInfo, error) { diff --git a/core/init/router/router.go b/core/init/router/router.go index d70d6ad23..4fb335075 100644 --- a/core/init/router/router.go +++ b/core/init/router/router.go @@ -218,6 +218,9 @@ func Routers() *gin.Engine { if global.CONF.Base.IsDemo { Router.Use(middleware.DemoHandle()) } + Router.Use(middleware.JwtAuth()) + Router.Use(middleware.SessionAuth()) + Router.Use(middleware.PasswordExpired()) Router.Use(middleware.GlobalLoading()) Router.Use(Proxy()) diff --git a/frontend/src/components/file-list/index.vue b/frontend/src/components/file-list/index.vue index fe0c492c4..3d3df2f33 100644 --- a/frontend/src/components/file-list/index.vue +++ b/frontend/src/components/file-list/index.vue @@ -13,11 +13,11 @@
- - /{{ paths[0] }} + + /{{ paths[0] }}
@@ -26,7 +26,7 @@
- + /{{ paths[paths.length - 1] }}
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 39863c041..7290944a2 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1292,6 +1292,7 @@ const message = { databases: 'Database', licenses: 'License', nodes: 'Node', + commands: 'Quick Commands', }, websiteLog: 'Website Logs', runLog: 'Run Log', diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 330da873e..a98888242 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -1229,6 +1229,7 @@ const message = { databases: 'データベース', licenses: 'ライセンス', nodes: 'ノード', + commands: 'クイックコマンド', }, websiteLog: 'ウェブサイトログ', runLog: 'ログを実行します', diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index 53ff63bdc..88dca6c0c 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -1217,6 +1217,7 @@ const message = { databases: '데이터베이스', licenses: '라이선스', nodes: '노드', + commands: '빠른 명령', }, websiteLog: '웹사이트 로그', runLog: '실행 로그', diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index 5ef4421b8..03080fdb7 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -1272,6 +1272,7 @@ const message = { databases: 'Pangkalan', licenses: 'lesen', nodes: 'nod', + commands: 'Perintah Pantas', }, websiteLog: 'Log Laman Web', runLog: 'Log Jalankan', diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index 56a3c5bae..845d1706c 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -1255,6 +1255,7 @@ const message = { databases: 'Bancos de Dados', licenses: 'licenças', nodes: 'nós', + commands: 'Comandos Rápidos', }, websiteLog: 'Logs do website', runLog: 'Logs de execução', diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index 32f7ff95a..4a67ab210 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -1263,6 +1263,7 @@ const message = { databases: 'Базы данных', licenses: 'лицензии', nodes: 'ноды', + commands: 'Быстрые команды', }, websiteLog: 'Логи веб-сайта', runLog: 'Логи выполнения', diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts index 3e56090b1..41b5154be 100644 --- a/frontend/src/lang/modules/zh-Hant.ts +++ b/frontend/src/lang/modules/zh-Hant.ts @@ -1220,6 +1220,7 @@ const message = { databases: '資料庫', licenses: '許可證', nodes: '節點', + commands: '快速命令', }, websiteLog: '網站日誌', runLog: '運行日誌', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 8ff95ac5b..e3c118e49 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1218,6 +1218,7 @@ const message = { databases: '数据库', licenses: '许可证', nodes: '节点', + commands: '快速命令', }, websiteLog: '网站日志', runLog: '运行日志', diff --git a/frontend/src/views/app-store/installed/upgrade/index.vue b/frontend/src/views/app-store/installed/upgrade/index.vue index 1b84a1701..ad4471e17 100644 --- a/frontend/src/views/app-store/installed/upgrade/index.vue +++ b/frontend/src/views/app-store/installed/upgrade/index.vue @@ -57,7 +57,7 @@
{{ $t('app.upgradeWarn') }} - {{ $t('app.showDiff') }} + {{ $t('app.showDiff') }}
diff --git a/frontend/src/views/database/postgresql/conn/index.vue b/frontend/src/views/database/postgresql/conn/index.vue index 23a990c5f..cc8c8345e 100644 --- a/frontend/src/views/database/postgresql/conn/index.vue +++ b/frontend/src/views/database/postgresql/conn/index.vue @@ -53,7 +53,7 @@
- + - - - - - - - -
- - -
-
-
- - - -
- -
+
@@ -132,10 +92,9 @@ diff --git a/frontend/src/views/terminal/host/index.vue b/frontend/src/views/terminal/host/index.vue index db98e9cb5..44356943e 100644 --- a/frontend/src/views/terminal/host/index.vue +++ b/frontend/src/views/terminal/host/index.vue @@ -107,7 +107,7 @@ const acceptParams = () => { }; function selectable(row) { - return row.addr !== '127.0.0.1'; + return row.name !== 'local'; } const dialogRef = ref(); const onOpenDialog = async ( @@ -174,12 +174,12 @@ const buttons = [ }, { label: i18n.global.t('commons.button.delete'), + disabled: (row: any) => { + return row.name === 'local'; + }, click: (row: Host.Host) => { onBatchDelete(row); }, - disabled: (row: any) => { - return row.addr === '127.0.0.1'; - }, }, ]; diff --git a/frontend/src/views/terminal/host/operate/index.vue b/frontend/src/views/terminal/host/operate/index.vue index f289190ef..09c26f500 100644 --- a/frontend/src/views/terminal/host/operate/index.vue +++ b/frontend/src/views/terminal/host/operate/index.vue @@ -60,7 +60,7 @@
- + local diff --git a/frontend/src/views/terminal/terminal/host-create.vue b/frontend/src/views/terminal/terminal/host-create.vue index 159a3fbe7..27bc4d9f2 100644 --- a/frontend/src/views/terminal/terminal/host-create.vue +++ b/frontend/src/views/terminal/terminal/host-create.vue @@ -54,6 +54,10 @@
+ + local + + @@ -112,7 +116,14 @@ const rules = reactive({ authMode: [Rules.requiredSelect], password: [Rules.requiredInput], privateKey: [Rules.requiredInput], + name: [{ validator: checkName, trigger: 'blur' }], }); +function checkName(rule: any, value: any, callback: any) { + if (value === 'local' && !isLocal.value) { + return callback(new Error(i18n.global.t('terminal.localHelper'))); + } + callback(); +} const isLocal = ref(false); interface DialogProps { @@ -166,7 +177,7 @@ const loadLocal = async () => { const setDefault = () => { hostInfo.addr = ''; - hostInfo.name = 'local'; + hostInfo.name = ''; hostInfo.groupID = defaultGroup.value; hostInfo.port = 22; hostInfo.user = ''; @@ -204,7 +215,7 @@ const submitAddHost = (formEl: FormInstance | undefined, ops: string) => { if (res.data.name.length !== 0) { title = res.data.name + '-' + title; } - let isLocal = hostInfo.addr === '127.0.0.1'; + let isLocal = hostInfo.name === 'local'; emit('on-conn-terminal', title, res.data.id, isLocal); emit('load-host-tree'); break; diff --git a/frontend/src/views/terminal/terminal/index.vue b/frontend/src/views/terminal/terminal/index.vue index b56f68196..b371e7bfb 100644 --- a/frontend/src/views/terminal/terminal/index.vue +++ b/frontend/src/views/terminal/terminal/index.vue @@ -1,5 +1,5 @@