From de3b75c53629ad54b2f7cc6024e7c1020659b8d6 Mon Sep 17 00:00:00 2001 From: WanWanYun Date: Sat, 15 Nov 2025 23:50:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DcreateFolder=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=9C=AA=E6=AD=A3=E7=A1=AE=E6=B7=BB=E5=8A=A0=E5=88=B0?= =?UTF-8?q?Vue=20methods=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: 点击"新建文件夹"按钮时控制台报错 "createFolder is not a function" 原因: 之前使用正则表达式添加方法时没有成功匹配,导致方法未被添加 修复: 手动在renameFile方法后面正确添加createFolder方法 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- frontend/app.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/frontend/app.js b/frontend/app.js index 6233545..59a0391 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -858,6 +858,41 @@ handleDragLeave(e) { } }, + // 创建文件夹 + async createFolder() { + const folderName = this.createFolderForm.folderName.trim(); + + if (!folderName) { + this.showToast('error', '错误', '请输入文件夹名称'); + return; + } + + // 前端验证文件夹名称 + if (folderName.includes('/') || folderName.includes('\\') || folderName.includes('..') || folderName.includes(':')) { + this.showToast('error', '错误', '文件夹名称不能包含特殊字符 (/ \\ .. :)'); + return; + } + + try { + const response = await axios.post(`${this.apiBase}/api/files/mkdir`, { + path: this.currentPath, + folderName: folderName + }, { + headers: { 'Authorization': `Bearer ${this.token}` } + }); + + if (response.data.success) { + this.showToast('success', '成功', '文件夹创建成功'); + this.showCreateFolderModal = false; + this.createFolderForm.folderName = ''; + await this.loadFiles(); // 刷新文件列表 + } + } catch (error) { + console.error('[创建文件夹失败]', error); + this.showToast('error', '错误', error.response?.data?.message || '创建文件夹失败'); + } + }, + confirmDeleteFile(file) { const fileType = file.isDirectory ? '文件夹' : '文件'; const warning = file.isDirectory ? "\n注意:只能删除空文件夹!" : "";