From 42dd00c5ea4fb8c93acbac10b5bf51e352c09416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Sun, 27 Oct 2024 00:17:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=87=E8=AE=B0=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=AF=E4=BB=A5=E5=8F=96=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/service/file.go | 24 ++++++++++++------------ web/src/views/file/ToolBar.vue | 7 +++++++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/internal/service/file.go b/internal/service/file.go index 05bc4f14..9779807d 100644 --- a/internal/service/file.go +++ b/internal/service/file.go @@ -72,11 +72,11 @@ func (s *FileService) Content(w http.ResponseWriter, r *http.Request) { return } if fileInfo.IsDir() { - Error(w, http.StatusInternalServerError, "目标路径不是文件") + Error(w, http.StatusInternalServerError, "target is a directory") return } if fileInfo.Size() > 10*1024*1024 { - Error(w, http.StatusInternalServerError, "文件大小超过 10 M,不支持在线编辑") + Error(w, http.StatusInternalServerError, "file is too large, please download it") return } @@ -135,17 +135,17 @@ func (s *FileService) Upload(w http.ResponseWriter, r *http.Request) { path := r.FormValue("path") _, handler, err := r.FormFile("file") if err != nil { - Error(w, http.StatusInternalServerError, "上传文件失败:%v", err) + Error(w, http.StatusInternalServerError, "upload file error: %v", err) return } if io.Exists(path) { - Error(w, http.StatusForbidden, "目标路径 %s 已存在", path) + Error(w, http.StatusForbidden, "target path %s already exists", path) return } if !io.Exists(filepath.Dir(path)) { if err = io.Mkdir(filepath.Dir(path), 0755); err != nil { - Error(w, http.StatusInternalServerError, "创建文件夹失败:%v", err) + Error(w, http.StatusInternalServerError, "create directory error: %v", err) return } } @@ -153,12 +153,12 @@ func (s *FileService) Upload(w http.ResponseWriter, r *http.Request) { src, _ := handler.Open() out, err := stdos.OpenFile(path, stdos.O_CREATE|stdos.O_RDWR|stdos.O_TRUNC, 0644) if err != nil { - Error(w, http.StatusInternalServerError, "打开文件失败:%v", err) + Error(w, http.StatusInternalServerError, "open file error: %v", err) return } if _, err = stdio.Copy(out, src); err != nil { - Error(w, http.StatusInternalServerError, "写入文件失败:%v", err) + Error(w, http.StatusInternalServerError, "write file error: %v", err) return } @@ -175,12 +175,12 @@ func (s *FileService) Move(w http.ResponseWriter, r *http.Request) { } if io.Exists(req.Target) && !req.Force { - Error(w, http.StatusForbidden, "目标路径 %s 已存在", req.Target) + Error(w, http.StatusForbidden, "target path %s already exists", req.Target) return } if io.IsDir(req.Source) && strings.HasPrefix(req.Target, req.Source) { - Error(w, http.StatusForbidden, "你不能这样做,会玩坏的") + Error(w, http.StatusForbidden, "you can't do this, it will be broken") return } @@ -200,12 +200,12 @@ func (s *FileService) Copy(w http.ResponseWriter, r *http.Request) { } if io.Exists(req.Target) && !req.Force { - Error(w, http.StatusForbidden, "目标路径 %s 已存在", req.Target) + Error(w, http.StatusForbidden, "target path %s already exists", req.Target) return } if io.IsDir(req.Source) && strings.HasPrefix(req.Target, req.Source) { - Error(w, http.StatusForbidden, "你不能这样做,会玩坏的") + Error(w, http.StatusForbidden, "you can't do this, it will be broken") return } @@ -230,7 +230,7 @@ func (s *FileService) Download(w http.ResponseWriter, r *http.Request) { return } if info.IsDir() { - Error(w, http.StatusInternalServerError, "不能下载目录") + Error(w, http.StatusInternalServerError, "can't download a directory") return } diff --git a/web/src/views/file/ToolBar.vue b/web/src/views/file/ToolBar.vue index 0bbfffa3..a86d1b03 100644 --- a/web/src/views/file/ToolBar.vue +++ b/web/src/views/file/ToolBar.vue @@ -107,6 +107,10 @@ const handlePaste = async () => { marked.value = [] } +const handleCancel = () => { + marked.value = [] +} + const bulkDelete = () => { if (!selected.value.length) { window.$message.error('请选择要删除的文件/文件夹') @@ -154,6 +158,9 @@ watch( 远程下载
+ + 取消 + 粘贴