import { ChevronRight, HardDrive } from "lucide-react"; import { useState } from "react"; import type { FileRoot } from "~/api/files.ts"; import { cn } from "~/lib/utils.ts"; import { breadcrumbItems, collapseCrumbs } from "./model.ts"; /** * 路径面包屑(照 MP「本地 > MEDIA > 亚洲剧集」):登记目录类型(下载目录 / 媒体库,只作说明)> 登记目录 > 各级子目录。 * 目录各段可点击跳转,也是拖放目标(拖入 = 移动到该目录)。窄屏去掉类型,折叠为"根 / … / 父 / 当前"。 */ export function PathBreadcrumb({ root, path, onNavigate, onDropTo, className, }: { root: Pick; path: string; onNavigate: (path: string) => void; /** 有值时每段可作为拖放目标 */ onDropTo?: (path: string, e: React.DragEvent) => void; className?: string; }) { const { group, crumbs } = breadcrumbItems(root, path); const [over, setOver] = useState(null); const render = (items: ((typeof crumbs)[number] | null)[], key: string, extra?: string, withGroup = false) => (
    {withGroup ? (
  1. {group}
  2. ) : null} {items.map((c, i) => { const last = i === items.length - 1; return (
  3. {i > 0 ? : null} {c === null ? ( … ) : ( )}
  4. ); })}
); return ( ); }