From 162f4575037ae2a9456253ecdae187307dbb7672 Mon Sep 17 00:00:00 2001 From: cc Date: Tue, 14 Apr 2026 17:42:22 +0200 Subject: [PATCH] Fix routing and optimize paths layout - Fix double base path in tab navigation (router.push handles it) - Use multi-column grid for files in shallow folders - Show item counts always (not just on hover) - Better use of horizontal space on desktop --- src/app/os/layout.tsx | 2 +- src/components/filesystem.tsx | 109 ++++++++++++++++++++++++---------- 2 files changed, 80 insertions(+), 31 deletions(-) diff --git a/src/app/os/layout.tsx b/src/app/os/layout.tsx index 44f6f95..61447f4 100644 --- a/src/app/os/layout.tsx +++ b/src/app/os/layout.tsx @@ -40,7 +40,7 @@ export default function OSDetailLayout({ const handleTabChange = (tab: string) => { if (tab === "bin") return; - router.push(addBasePath(`/os/${tab}?os=${os}`)); + router.push(`/os/${tab}?os=${os}`); }; return ( diff --git a/src/components/filesystem.tsx b/src/components/filesystem.tsx index e746088..75427ed 100644 --- a/src/components/filesystem.tsx +++ b/src/components/filesystem.tsx @@ -21,6 +21,39 @@ function countItems(item: TreeWithFullPath): number { return count; } +function getMaxDepth(item: TreeWithFullPath, current = 0): number { + let max = current; + for (const value of Object.values(item)) { + if (typeof value !== "string") { + max = Math.max(max, getMaxDepth(value, current + 1)); + } + } + return max; +} + +function FileItem({ + name, + fullPath, + os, +}: { + name: string; + fullPath: string; + os: string; +}) { + return ( +
+ + + {name} + +
+ ); +} + function Tree({ item, os, @@ -32,35 +65,36 @@ function Tree({ depth: number; expandAll: boolean; }) { + const entries = Object.entries(item); + const files = entries.filter(([, v]) => typeof v === "string"); + const folders = entries.filter(([, v]) => typeof v !== "string"); + return ( ); } @@ -80,6 +114,8 @@ function TreeFolder({ }) { const [open, setOpen] = useState(expandAll || depth < 1); const itemCount = countItems(item); + const maxDepth = getMaxDepth(item); + const isShallow = maxDepth === 0; return (
  • @@ -92,13 +128,26 @@ function TreeFolder({ )} {name} - + {itemCount} -
    - +
    + {isShallow ? ( +
    + {Object.entries(item).map(([key, value]) => ( + + ))} +
    + ) : ( + + )}