feat(frontend): artifact 文件卡片支持右键引用
This commit is contained in:
parent
4dbe930775
commit
3d5006af48
|
|
@ -10,9 +10,16 @@ import {
|
|||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import {
|
||||
ContextMenu,
|
||||
ContextMenuContent,
|
||||
ContextMenuItem,
|
||||
ContextMenuTrigger,
|
||||
} from "@/components/ui/context-menu";
|
||||
import { urlOfArtifact } from "@/core/artifacts/utils";
|
||||
import { useI18n } from "@/core/i18n/hooks";
|
||||
import { installSkill } from "@/core/skills/api";
|
||||
import { dispatchMentionReference } from "@/core/threads/reference-events";
|
||||
import {
|
||||
getFileExtensionDisplayName,
|
||||
getFileIcon,
|
||||
|
|
@ -78,8 +85,9 @@ export function ArtifactFileList({
|
|||
data-testid="artifact-file-list"
|
||||
>
|
||||
{files.map((file) => (
|
||||
<ContextMenu key={file}>
|
||||
<ContextMenuTrigger asChild>
|
||||
<Card
|
||||
key={file}
|
||||
className="relative cursor-pointer p-4"
|
||||
data-testid="artifact-file-card"
|
||||
onClick={() => handleClick(file)}
|
||||
|
|
@ -124,9 +132,9 @@ export function ArtifactFileList({
|
|||
target="_blank"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Button variant="ghost"
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="h-full! text-[var(--muted-foreground)]! hover:bg-transparent! hover:text-[#333333]!"
|
||||
|
||||
>
|
||||
<DownloadIcon className="size-4" />
|
||||
{t.common.download}
|
||||
|
|
@ -141,6 +149,22 @@ export function ArtifactFileList({
|
|||
</CardAction>
|
||||
</CardHeader>
|
||||
</Card>
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent className="min-w-[120px] p-1">
|
||||
<ContextMenuItem
|
||||
onSelect={() => {
|
||||
dispatchMentionReference({
|
||||
threadId,
|
||||
filename: getFileName(file),
|
||||
path: file,
|
||||
ref_source: "artifact",
|
||||
});
|
||||
}}
|
||||
>
|
||||
引用
|
||||
</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue