From b00261475908d70167acf0ed60d746b397aead22 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Thu, 9 Feb 2023 14:31:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/file.go | 7 +++- backend/constant/errs.go | 5 +++ backend/i18n/lang/en.yaml | 2 +- backend/i18n/lang/zh.yaml | 1 + frontend/components.d.ts | 1 + .../app-store/installed/update/index.vue | 2 +- .../views/container/compose/create/index.vue | 3 +- .../container/container/reName/index.vue | 2 +- .../src/views/container/image/build/index.vue | 2 +- .../src/views/container/image/load/index.vue | 6 +-- .../src/views/container/image/save/index.vue | 4 +- frontend/src/views/cronjob/operate/index.vue | 4 +- .../src/views/database/mysql/remote/index.vue | 2 +- .../database/mysql/root-password/index.vue | 2 +- .../host/file-management/compress/index.vue | 4 +- .../host/file-management/create/index.vue | 2 +- .../host/file-management/decompress/index.vue | 40 ++++++++++--------- .../host/file-management/download/index.vue | 2 +- .../views/host/file-management/move/index.vue | 34 +++++++++------- .../host/file-management/rename/index.vue | 2 +- .../views/host/file-management/wget/index.vue | 4 +- .../setting/backup-account/operate/index.vue | 2 +- .../views/website/website/default/index.vue | 2 +- 23 files changed, 77 insertions(+), 58 deletions(-) diff --git a/backend/app/service/file.go b/backend/app/service/file.go index 2bbbd497d..4bdf2d9a7 100644 --- a/backend/app/service/file.go +++ b/backend/app/service/file.go @@ -4,6 +4,8 @@ import ( "fmt" "github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/app/dto/response" + "github.com/1Panel-dev/1Panel/backend/buserr" + "github.com/1Panel-dev/1Panel/backend/constant" "io/fs" "os" "path/filepath" @@ -57,7 +59,6 @@ func (f FileService) GetFileTree(op request.FileOption) ([]response.FileTree, er } func (f FileService) Create(op request.FileCreate) error { - fo := files.NewFileOp() if fo.Stat(op.Path) { return errors.New("file is exist") @@ -154,6 +155,10 @@ func (f FileService) Wget(w request.FileWget) (string, error) { func (f FileService) MvFile(m request.FileMove) error { fo := files.NewFileOp() + if !fo.Stat(m.NewPath) { + return buserr.New(constant.ErrPathNotFound) + } + if m.Type == "cut" { return fo.Cut(m.OldPaths, m.NewPath) } diff --git a/backend/constant/errs.go b/backend/constant/errs.go index e4e08f99b..a4a58ce4b 100644 --- a/backend/constant/errs.go +++ b/backend/constant/errs.go @@ -70,3 +70,8 @@ var ( ErrAccountCannotDelete = "ErrAccountCannotDelete" ErrSSLApply = "ErrSSLApply" ) + +//file +var ( + ErrPathNotFound = "ErrPathNotFound" +) diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index 827cb2613..0198e8eba 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -23,10 +23,10 @@ ErrAppRequired: "{{ .detail }} app is required" ErrNotInstall: "App not installed" ErrPortInOtherApp: "{{ .port }} port already in use by {{ .apps }}" - #file ErrFileCanNotRead: "File can not read" ErrFileToLarge: "file is too large" +ErrPathNotFound: "Path is not found" #website ErrDomainIsExist: "Domain is already exist" diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index d8e4a3b4a..22ce0905a 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -26,6 +26,7 @@ ErrPortInOtherApp: "{{ .port }} 端口已被 {{ .apps }}占用!" #file ErrFileCanNotRead: "此文件不支持预览" ErrFileToLarge: "文件超过10M,无法打开" +ErrPathNotFound: "目录不存在" #website ErrDomainIsExist: "域名已存在" diff --git a/frontend/components.d.ts b/frontend/components.d.ts index b987f0e7d..18da02c96 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -59,6 +59,7 @@ declare module 'vue' { ElRow: typeof import('element-plus/es')['ElRow'] ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElSelect: typeof import('element-plus/es')['ElSelect'] + ElSpan: typeof import('element-plus/es')['ElSpan'] ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] diff --git a/frontend/src/views/app-store/installed/update/index.vue b/frontend/src/views/app-store/installed/update/index.vue index 85ef2f666..c0dd53613 100644 --- a/frontend/src/views/app-store/installed/update/index.vue +++ b/frontend/src/views/app-store/installed/update/index.vue @@ -1,5 +1,5 @@