修复文件管理器多个关键问题
- 修复侧边栏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:
@@ -16,7 +16,9 @@ import {
|
||||
Share,
|
||||
ExternalLink,
|
||||
Terminal,
|
||||
Play
|
||||
Play,
|
||||
Star,
|
||||
Bookmark
|
||||
} from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
@@ -54,6 +56,10 @@ interface ContextMenuProps {
|
||||
onDragToDesktop?: () => void;
|
||||
onOpenTerminal?: (path: string) => void;
|
||||
onRunExecutable?: (file: FileItem) => void;
|
||||
onPinFile?: (file: FileItem) => void;
|
||||
onUnpinFile?: (file: FileItem) => void;
|
||||
onAddShortcut?: (path: string) => void;
|
||||
isPinned?: (file: FileItem) => boolean;
|
||||
currentPath?: string;
|
||||
}
|
||||
|
||||
@@ -89,6 +95,10 @@ export function FileManagerContextMenu({
|
||||
onDragToDesktop,
|
||||
onOpenTerminal,
|
||||
onRunExecutable,
|
||||
onPinFile,
|
||||
onUnpinFile,
|
||||
onAddShortcut,
|
||||
isPinned,
|
||||
currentPath
|
||||
}: ContextMenuProps) {
|
||||
const { t } = useTranslation();
|
||||
@@ -259,6 +269,34 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// PIN/UNPIN 功能 - 仅对单个文件显示
|
||||
if (isSingleFile && files[0].type === 'file') {
|
||||
const isCurrentlyPinned = isPinned ? isPinned(files[0]) : false;
|
||||
|
||||
if (isCurrentlyPinned && onUnpinFile) {
|
||||
menuItems.push({
|
||||
icon: <Star className="w-4 h-4 fill-yellow-400" />,
|
||||
label: "取消固定",
|
||||
action: () => onUnpinFile(files[0])
|
||||
});
|
||||
} else if (!isCurrentlyPinned && onPinFile) {
|
||||
menuItems.push({
|
||||
icon: <Star className="w-4 h-4" />,
|
||||
label: "固定文件",
|
||||
action: () => onPinFile(files[0])
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 添加文件夹快捷方式 - 仅对单个文件夹显示
|
||||
if (isSingleFile && files[0].type === 'directory' && onAddShortcut) {
|
||||
menuItems.push({
|
||||
icon: <Bookmark className="w-4 h-4" />,
|
||||
label: "添加到快捷方式",
|
||||
action: () => onAddShortcut(files[0].path)
|
||||
});
|
||||
}
|
||||
|
||||
menuItems.push({ separator: true } as MenuItem);
|
||||
|
||||
if (isSingleFile && onRename) {
|
||||
|
||||
Reference in New Issue
Block a user