feat: complete stage 2 core refactor

This commit is contained in:
Jason
2025-10-16 10:49:56 +08:00
parent cc0b7053aa
commit b88eb88608
17 changed files with 1521 additions and 461 deletions

View File

@@ -0,0 +1,75 @@
import { BarChart3, Check, Play, Trash2 } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
interface ProviderActionsProps {
isCurrent: boolean;
onSwitch: () => void;
onEdit: () => void;
onConfigureUsage: () => void;
onDelete: () => void;
}
export function ProviderActions({
isCurrent,
onSwitch,
onEdit,
onConfigureUsage,
onDelete,
}: ProviderActionsProps) {
const { t } = useTranslation();
return (
<div className="flex items-center gap-2">
<Button
size="sm"
variant={isCurrent ? "secondary" : "default"}
onClick={onSwitch}
disabled={isCurrent}
className={cn(
"w-[96px]",
isCurrent && "text-muted-foreground hover:text-muted-foreground",
)}
>
{isCurrent ? (
<>
<Check className="h-4 w-4" />
{t("provider.inUse", { defaultValue: "已启用" })}
</>
) : (
<>
<Play className="h-4 w-4" />
{t("provider.enable", { defaultValue: "启用" })}
</>
)}
</Button>
<Button size="sm" variant="outline" onClick={onEdit}>
{t("common.edit", { defaultValue: "编辑" })}
</Button>
<Button
size="sm"
variant="outline"
onClick={onConfigureUsage}
title={t("provider.configureUsage", { defaultValue: "配置用量查询" })}
>
<BarChart3 className="h-4 w-4" />
</Button>
<Button
size="sm"
variant="ghost"
onClick={onDelete}
disabled={isCurrent}
className={cn(
"text-destructive hover:text-destructive",
isCurrent && "text-muted-foreground hover:text-muted-foreground",
)}
>
<Trash2 className="h-4 w-4" />
</Button>
</div>
);
}