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]) => ( + + ))} +
    + ) : ( + + )}