修复文件管理器多个关键问题

- 修复侧边栏API路由问题:将数据API从fileManagerApi(8084)切换到authApi(8081)
- 实现PIN功能:添加文件固定/取消固定功能,支持右键菜单操作
- 修复FileWindow组件props传递错误:正确传递file对象和sshHost参数
- 添加侧边栏数据刷新机制:PIN/Recent/Shortcut操作后自动更新显示
- 修复目录树展开问题:handleItemClick正确传递folderPath参数
- 新增FileManagerSidebar组件:支持Recent、Pinned、Shortcuts和目录树

主要修复:
1. API路由从localhost:8084/ssh/file_manager/* 修正为 localhost:8081/ssh/file_manager/*
2. 双击文件不再报错"Cannot read properties of undefined (reading 'name')"
3. 侧边栏实时同步数据更新,提升用户体验
This commit is contained in:
ZacharyZcR
2025-09-17 09:55:42 +08:00
parent 7fc474b9e4
commit 4e915a1b3e
6 changed files with 636 additions and 6 deletions

View File

@@ -1204,6 +1204,148 @@ export async function moveSSHItem(
}
}
// ============================================================================
// FILE MANAGER DATA
// ============================================================================
// Recent Files
export async function getRecentFiles(hostId: number): Promise<any> {
try {
const response = await authApi.get("/ssh/file_manager/recent", {
params: { hostId }
});
return response.data;
} catch (error) {
handleApiError(error, "get recent files");
throw error;
}
}
export async function addRecentFile(
hostId: number,
path: string,
name?: string
): Promise<any> {
try {
const response = await authApi.post("/ssh/file_manager/recent", {
hostId,
path,
name
});
return response.data;
} catch (error) {
handleApiError(error, "add recent file");
throw error;
}
}
export async function removeRecentFile(
hostId: number,
path: string
): Promise<any> {
try {
const response = await authApi.delete("/ssh/file_manager/recent", {
data: { hostId, path }
});
return response.data;
} catch (error) {
handleApiError(error, "remove recent file");
throw error;
}
}
// Pinned Files
export async function getPinnedFiles(hostId: number): Promise<any> {
try {
const response = await authApi.get("/ssh/file_manager/pinned", {
params: { hostId }
});
return response.data;
} catch (error) {
handleApiError(error, "get pinned files");
throw error;
}
}
export async function addPinnedFile(
hostId: number,
path: string,
name?: string
): Promise<any> {
try {
const response = await authApi.post("/ssh/file_manager/pinned", {
hostId,
path,
name
});
return response.data;
} catch (error) {
handleApiError(error, "add pinned file");
throw error;
}
}
export async function removePinnedFile(
hostId: number,
path: string
): Promise<any> {
try {
const response = await authApi.delete("/ssh/file_manager/pinned", {
data: { hostId, path }
});
return response.data;
} catch (error) {
handleApiError(error, "remove pinned file");
throw error;
}
}
// Folder Shortcuts
export async function getFolderShortcuts(hostId: number): Promise<any> {
try {
const response = await authApi.get("/ssh/file_manager/shortcuts", {
params: { hostId }
});
return response.data;
} catch (error) {
handleApiError(error, "get folder shortcuts");
throw error;
}
}
export async function addFolderShortcut(
hostId: number,
path: string,
name?: string
): Promise<any> {
try {
const response = await authApi.post("/ssh/file_manager/shortcuts", {
hostId,
path,
name
});
return response.data;
} catch (error) {
handleApiError(error, "add folder shortcut");
throw error;
}
}
export async function removeFolderShortcut(
hostId: number,
path: string
): Promise<any> {
try {
const response = await authApi.delete("/ssh/file_manager/shortcuts", {
data: { hostId, path }
});
return response.data;
} catch (error) {
handleApiError(error, "remove folder shortcut");
throw error;
}
}
// ============================================================================
// SERVER STATISTICS
// ============================================================================