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注意:只能删除空文件夹!" : "";