From a721091476b7e896dd8d4d24c95a735d192feb10 Mon Sep 17 00:00:00 2001 From: MT-Fire <798521692@qq.com> Date: Sun, 29 Mar 2026 01:04:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20=E7=94=A8=E9=80=9A?= =?UTF-8?q?=E7=94=A8=20Select=20=E6=9B=BF=E6=8D=A2=E6=97=A7=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E9=80=89=E6=8B=A9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ui/dropdown-selector.tsx | 106 ------------------ .../artifacts/artifact-file-detail.tsx | 28 ++++- 2 files changed, 22 insertions(+), 112 deletions(-) delete mode 100644 frontend/src/components/ui/dropdown-selector.tsx diff --git a/frontend/src/components/ui/dropdown-selector.tsx b/frontend/src/components/ui/dropdown-selector.tsx deleted file mode 100644 index 7d435d7c..00000000 --- a/frontend/src/components/ui/dropdown-selector.tsx +++ /dev/null @@ -1,106 +0,0 @@ -import { useState } from "react"; - -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuRadioGroup, - DropdownMenuRadioItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { cn, truncateMiddle } from "@/lib/utils"; - -export interface DropdownSelectorOption { - value: T; - label: string; -} - -interface DropdownSelectorProps { - value: T; - options: DropdownSelectorOption[]; - onChange: (value: T) => void; - triggerClassName?: string; - contentClassName?: string; -} - -function ChevronDownIcon() { - return ( - - - - ); -} - -function ChevronUpIcon() { - return ( - - - - ); -} - -export function DropdownSelector({ - value, - options, - onChange, - triggerClassName, - contentClassName, -}: DropdownSelectorProps) { - const selectedOption = options.find((opt) => opt.value === value); - const [isOpen, setIsOpen] = useState(false); - - return ( - - - - {truncateMiddle(selectedOption?.label ?? value, 50)} - {isOpen ? : } - - - - onChange(v as T)} - > - {options.map((option) => ( - - {truncateMiddle(option.label)} - - ))} - - - - ); -} \ No newline at end of file diff --git a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx index 8423617a..7a34667c 100644 --- a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx +++ b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx @@ -23,7 +23,14 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -import { DropdownSelector } from "@/components/ui/dropdown-selector"; +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import { CodeEditor } from "@/components/workspace/code-editor"; import { useArtifactContent } from "@/core/artifacts/hooks"; @@ -247,11 +254,20 @@ export function ArtifactFileDetail({ {isWriteFile ? (
{truncateMiddle(getFileName(filepath), 50)}
) : ( - + )}