修复文件管理器侧边栏显示问题
- 修复目录树API数据格式不匹配:listSSHFiles返回{files, path}对象而非数组
- 修复侧边栏滚动问题:添加thin-scrollbar类保持样式一致性
- 修复Recent和Pin文件点击行为:区分文件和文件夹处理逻辑
- 增强侧边栏高度约束:确保滚动容器正确工作
- 优化TypeScript类型安全:更新listSSHFiles返回类型定义
主要改进:
1. 侧边栏目录树现在正确显示所有文件夹而不是只有根目录
2. Recent和Pinned文件点击时正确打开文件而不是当作文件夹处理
3. 侧边栏支持滚动查看所有内容,滚动条样式与主容器一致
4. API错误处理更加健壮,避免undefined导致的运行时错误
This commit is contained in:
@@ -45,6 +45,7 @@ import {
|
||||
addFolderShortcut,
|
||||
getPinnedFiles
|
||||
} from "@/ui/main-axios.ts";
|
||||
import type { SidebarItem } from "./FileManagerSidebar";
|
||||
|
||||
|
||||
interface FileManagerModernProps {
|
||||
@@ -1309,6 +1310,19 @@ function FileManagerContent({ initialHost, onClose }: FileManagerModernProps) {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理侧边栏文件打开
|
||||
async function handleSidebarFileOpen(sidebarItem: SidebarItem) {
|
||||
// 将SidebarItem转换为FileItem格式
|
||||
const file: FileItem = {
|
||||
name: sidebarItem.name,
|
||||
path: sidebarItem.path,
|
||||
type: 'file' // recent和pinned都是文件类型
|
||||
};
|
||||
|
||||
// 调用常规的文件打开处理
|
||||
await handleFileOpen(file);
|
||||
}
|
||||
|
||||
// 处理文件打开
|
||||
async function handleFileOpen(file: FileItem) {
|
||||
if (file.type === 'directory') {
|
||||
@@ -1481,12 +1495,13 @@ function FileManagerContent({ initialHost, onClose }: FileManagerModernProps) {
|
||||
{/* 主内容区域 */}
|
||||
<div className="flex-1 flex" {...dragHandlers}>
|
||||
{/* 左侧边栏 */}
|
||||
<div className="w-64 flex-shrink-0">
|
||||
<div className="w-64 flex-shrink-0 h-full">
|
||||
<FileManagerSidebar
|
||||
currentHost={currentHost}
|
||||
currentPath={currentPath}
|
||||
onPathChange={setCurrentPath}
|
||||
onLoadDirectory={loadDirectory}
|
||||
onFileOpen={handleSidebarFileOpen}
|
||||
sshSessionId={sshSessionId}
|
||||
refreshTrigger={sidebarRefreshTrigger}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user