0.1.14 上线前更改

This commit is contained in:
liaibo
2026-01-11 12:35:53 +08:00
parent be71849aa5
commit 725a60d3aa
44 changed files with 3427 additions and 310 deletions
@@ -17,9 +17,10 @@ interface FileTreeProps {
onRowContextMenu: (row: FileTreeRow, event: React.MouseEvent) => void;
onRowDragStart?: (row: FileTreeRow, event: React.DragEvent) => void;
onToggleExpand: (docId: string) => void;
onToggleAssetFolderExpand?: (assetId: string) => void;
onCreateChild: (parentId: string | null) => void;
onBlankMouseDown?: (event: React.MouseEvent) => void;
onDropFiles?: (docId: string, files: FileList) => void;
onDropFiles?: (docId: string, files: FileList, targetRow?: FileTreeRow) => void;
onInternalDrop?: (args: { targetRow: FileTreeRow; rowIds: string[]; copy: boolean }) => void;
}
@@ -34,6 +35,7 @@ export function FileTree({
onRowContextMenu,
onRowDragStart,
onToggleExpand,
onToggleAssetFolderExpand,
onCreateChild,
onBlankMouseDown,
onDropFiles,
@@ -53,8 +55,8 @@ export function FileTree({
// 标记为 drop feedback(包含它的所有可见子节点)。我们用“扁平化 rows +
// depth”来近似计算该范围。
let endIndex = startIndex + 1;
if (target.kind === "doc" && target.isExpanded && target.hasChildren) {
while (endIndex < rows.length && rows[endIndex].depth > targetDepth) {
if ((target.kind === "doc" || target.kind === "asset-folder") && target.isExpanded && target.hasChildren) {
while (endIndex < rows.length && rows[endIndex].depth > targetDepth) {
endIndex += 1;
}
}
@@ -91,7 +93,7 @@ export function FileTree({
(row) => row.kind === "doc" && row.docId === activeId,
);
const firstDocRow = rows.find((row) => row.kind === "doc");
const targetDocId = activeDocRow?.docId ?? firstDocRow?.docId ?? "";
const targetDocId = activeDocRow?.docId ?? firstDocRow?.docId ?? "";
onDropFiles(targetDocId, files);
}
}}
@@ -210,7 +212,7 @@ export function FileTree({
if (onDropFiles && event.dataTransfer.files?.length) {
event.preventDefault();
event.stopPropagation();
onDropFiles(row.docId, event.dataTransfer.files);
onDropFiles(row.docId, event.dataTransfer.files, row);
}
}}
role="button"
@@ -258,6 +260,31 @@ export function FileTree({
<FileText className="h-4 w-4 text-gray-500" />
<span className="min-w-0 flex-1 truncate text-left">{label}</span>
</>
) : row.kind === "asset-folder" ? (
<>
{row.hasChildren ? (
<button
type="button"
aria-label="展开或折叠"
onClick={(event) => {
event.stopPropagation();
onToggleAssetFolderExpand?.(row.asset.id);
}}
className="flex h-5 w-5 items-center justify-center rounded-md hover:bg-gray-100"
>
<ChevronRight
className={cn(
"h-3.5 w-3.5 transition-transform",
row.isExpanded && "rotate-90",
)}
/>
</button>
) : (
<span className="h-5 w-5" />
)}
<Folder className="h-4 w-4 text-[#2563eb]" />
<span className="min-w-0 flex-1 truncate text-left">{label}</span>
</>
) : (
<>
<span className="h-4 w-4" />