mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-21 05:14:45 +08:00
feat: integrated with artifacts
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { DownloadIcon } from "lucide-react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardAction,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { getFileExtension, getFileName } from "@/core/utils/files";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
import { useArtifacts } from "./context";
|
||||
|
||||
export function ArtifactFileList({
|
||||
className,
|
||||
files,
|
||||
}: {
|
||||
className?: string;
|
||||
files: string[];
|
||||
}) {
|
||||
const { openArtifact } = useArtifacts();
|
||||
const handleClick = useCallback(
|
||||
(filepath: string) => {
|
||||
openArtifact(filepath);
|
||||
},
|
||||
[openArtifact],
|
||||
);
|
||||
return (
|
||||
<ul className={cn("flex w-full flex-col gap-4", className)}>
|
||||
{files.map((file) => (
|
||||
<Card
|
||||
className="cursor-pointer"
|
||||
key={file}
|
||||
onClick={() => handleClick(file)}
|
||||
>
|
||||
<CardHeader>
|
||||
<CardTitle>{getFileName(file)}</CardTitle>
|
||||
<CardDescription>{getFileExtension(file)} file</CardDescription>
|
||||
<CardAction>
|
||||
<Button variant="ghost">
|
||||
<DownloadIcon className="size-4" />
|
||||
Download
|
||||
</Button>
|
||||
</CardAction>
|
||||
</CardHeader>
|
||||
</Card>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user