import type { FileRef, FileRoot } from "~/api/files.ts"; import { cn } from "~/lib/utils.ts"; import { DirTree } from "./dir-tree.tsx"; /** 可选的目标根:可写、在线的媒体库;移动 / 复制还可以放进 Alist 存储(includeStorage),整理「指定目录」与还原只能选媒体库 */ export function pickableRoots>( roots: T[], includeStorage = false, ): T[] { return roots.filter( (r) => (r.kind === "library" || (includeStorage && r.kind === "storage")) && r.writable && r.health !== "offline", ); } /** * 目录选择器(§14 DirPicker):基于 DirTree,只能选可写库根下的目录。 * 移动/复制到…、回收站"还原到…"、整理向导"指定目录"共用。 */ export function DirPicker({ roots, value, onChange, className, includeStorage = false, }: { roots: FileRoot[]; value: FileRef | null; onChange: (ref: FileRef) => void; className?: string; includeStorage?: boolean; }) { const writable = pickableRoots(roots, includeStorage); return (
{writable.length ? ( r.id)} onSelect={onChange} /> ) : (

没有可写入的{includeStorage ? "目录" : "媒体库目录"}。先在设置里添加。

)}
); }