fix: 修复文件夹功能的多个严重bug
问题修复:
1. 【文件夹无法重命名和删除】
- 原因: showFileContextMenu 函数中 `if (file.isDirectory) return` 阻止了文件夹显示右键菜单
- 修复: 移除这个限制,允许文件夹显示右键菜单
- 效果: 文件夹现在可以右键重命名和删除
2. 【进入文件夹后无法返回上一页】
- 原因: 页面没有路径导航条(面包屑导航)
- 修复: 在文件列表上方添加完整的路径导航组件
- 功能:
* 显示当前路径层级
* 点击路径中的任意层级可快速跳转
* "返回上一级"按钮
* "返回根目录"按钮
- 新增 navigateUp() 方法处理返回上一级
3. 【上传文件到子文件夹路径错误(undefined文件夹)】
- 原因: loadFiles() 调用时未传递 path 参数,导致 currentPath 变为 undefined
- 修复:
* loadFiles 开头添加安全检查: `this.currentPath = path || '/'`
* createFolder 成功后调用 loadFiles 时传递 currentPath
- 效果: 路径不会变成undefined,文件正确上传到当前目录
4. 【优化删除确认提示】
- 旧提示: "只能删除空文件夹"(错误信息)
- 新提示: "⚠️ 警告:文件夹内所有文件将被永久删除!"(准确描述行为)
技术改动:
- frontend/app.html: +15行 (路径导航条UI)
- frontend/app.js: +10行 (navigateUp方法 + 安全检查)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -740,7 +740,8 @@ handleDragLeave(e) {
|
||||
|
||||
async loadFiles(path) {
|
||||
this.loading = true;
|
||||
this.currentPath = path;
|
||||
// 确保路径不为undefined
|
||||
this.currentPath = path || '/';
|
||||
|
||||
try {
|
||||
const response = await axios.get(`${this.apiBase}/api/files`, {
|
||||
@@ -802,6 +803,15 @@ handleDragLeave(e) {
|
||||
this.loadFiles(path);
|
||||
},
|
||||
|
||||
// 返回上一级目录
|
||||
navigateUp() {
|
||||
if (this.currentPath === '/') return;
|
||||
const parts = this.currentPath.split('/').filter(p => p !== '');
|
||||
parts.pop();
|
||||
const newPath = parts.length === 0 ? '/' : '/' + parts.join('/');
|
||||
this.loadFiles(newPath);
|
||||
},
|
||||
|
||||
downloadFile(file) {
|
||||
console.log("[DEBUG] 下载文件:", file);
|
||||
if (file.httpDownloadUrl) {
|
||||
@@ -885,7 +895,7 @@ handleDragLeave(e) {
|
||||
this.showToast('success', '成功', '文件夹创建成功');
|
||||
this.showCreateFolderModal = false;
|
||||
this.createFolderForm.folderName = '';
|
||||
await this.loadFiles(); // 刷新文件列表
|
||||
await this.loadFiles(this.currentPath); // 刷新文件列表
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[创建文件夹失败]', error);
|
||||
@@ -895,7 +905,7 @@ handleDragLeave(e) {
|
||||
|
||||
confirmDeleteFile(file) {
|
||||
const fileType = file.isDirectory ? '文件夹' : '文件';
|
||||
const warning = file.isDirectory ? "\n注意:只能删除空文件夹!" : "";
|
||||
const warning = file.isDirectory ? "\n⚠️ 警告:文件夹内所有文件将被永久删除!" : "";
|
||||
if (confirm(`确定要删除${fileType} "${file.name}" 吗?此操作无法撤销!${warning}`)) {
|
||||
this.deleteFile(file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user