diff --git a/src/ui/Desktop/Apps/File Manager/FileManagerGrid.tsx b/src/ui/Desktop/Apps/File Manager/FileManagerGrid.tsx index 38ba9365..063cfee1 100644 --- a/src/ui/Desktop/Apps/File Manager/FileManagerGrid.tsx +++ b/src/ui/Desktop/Apps/File Manager/FileManagerGrid.tsx @@ -13,7 +13,9 @@ import { Download, ChevronLeft, ChevronRight, - MoreHorizontal + MoreHorizontal, + RefreshCw, + ArrowUp } from "lucide-react"; import { useTranslation } from "react-i18next"; @@ -134,6 +136,49 @@ export function FileManagerGrid({ const [selectionStart, setSelectionStart] = useState<{ x: number; y: number } | null>(null); const [selectionRect, setSelectionRect] = useState<{ x: number; y: number; width: number; height: number } | null>(null); + // 导航历史管理 + const [navigationHistory, setNavigationHistory] = useState([currentPath]); + const [historyIndex, setHistoryIndex] = useState(0); + + // 更新导航历史 + useEffect(() => { + const lastPath = navigationHistory[historyIndex]; + if (currentPath !== lastPath) { + const newHistory = navigationHistory.slice(0, historyIndex + 1); + newHistory.push(currentPath); + setNavigationHistory(newHistory); + setHistoryIndex(newHistory.length - 1); + } + }, [currentPath]); + + // 导航函数 + const goBack = () => { + if (historyIndex > 0) { + const newIndex = historyIndex - 1; + setHistoryIndex(newIndex); + onPathChange(navigationHistory[newIndex]); + } + }; + + const goForward = () => { + if (historyIndex < navigationHistory.length - 1) { + const newIndex = historyIndex + 1; + setHistoryIndex(newIndex); + onPathChange(navigationHistory[newIndex]); + } + }; + + const goUp = () => { + const parts = currentPath.split('/').filter(Boolean); + if (parts.length > 0) { + parts.pop(); + const parentPath = '/' + parts.join('/'); + onPathChange(parentPath); + } else if (currentPath !== '/') { + onPathChange('/'); + } + }; + // 路径导航 const pathParts = currentPath.split('/').filter(Boolean); const navigateToPath = (index: number) => { @@ -296,32 +341,44 @@ export function FileManagerGrid({ {/* 导航按钮 */}