From 53f40b2d7a8e5728a69aa841cae32537420867bc Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 12 Jan 2026 11:20:16 +0800 Subject: [PATCH] refactor(ui): unify pricing edit modal with FullScreenPanel Replace Dialog component with FullScreenPanel in PricingEditModal to match the UI style of other edit dialogs (provider, MCP). Changes: - Switch from small centered Dialog to full-screen panel - Add back button in header and fixed footer for actions - Add Save/Plus icons to submit button --- src/components/usage/PricingConfigPanel.tsx | 1 + src/components/usage/PricingEditModal.tsx | 254 ++++++++++---------- 2 files changed, 128 insertions(+), 127 deletions(-) diff --git a/src/components/usage/PricingConfigPanel.tsx b/src/components/usage/PricingConfigPanel.tsx index 7e81d4128..2f0372102 100644 --- a/src/components/usage/PricingConfigPanel.tsx +++ b/src/components/usage/PricingConfigPanel.tsx @@ -202,6 +202,7 @@ export function PricingConfigPanel() { {editingModel && ( { diff --git a/src/components/usage/PricingEditModal.tsx b/src/components/usage/PricingEditModal.tsx index 4e9a759ae..55cb582c3 100644 --- a/src/components/usage/PricingEditModal.tsx +++ b/src/components/usage/PricingEditModal.tsx @@ -1,13 +1,8 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; import { toast } from "sonner"; -import { - Dialog, - DialogContent, - DialogHeader, - DialogTitle, - DialogFooter, -} from "@/components/ui/dialog"; +import { Save, Plus } from "lucide-react"; +import { FullScreenPanel } from "@/components/common/FullScreenPanel"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; @@ -15,12 +10,14 @@ import { useUpdateModelPricing } from "@/lib/query/usage"; import type { ModelPricing } from "@/types/usage"; interface PricingEditModalProps { + open: boolean; model: ModelPricing; isNew?: boolean; onClose: () => void; } export function PricingEditModal({ + open, model, isNew = false, onClose, @@ -86,139 +83,142 @@ export function PricingEditModal({ }; return ( - - - - - {isNew - ? t("usage.addPricing", "新增定价") - : `${t("usage.editPricing", "编辑定价")} - ${model.modelId}`} - - - -
- {isNew && ( -
- - - setFormData({ ...formData, modelId: e.target.value }) - } - placeholder={t("usage.modelIdPlaceholder", { - defaultValue: "例如: claude-3-5-sonnet-20241022", - })} - required - /> -
+ + {isNew ? ( + + ) : ( + )} - + {updatePricing.isPending + ? t("common.saving", "保存中...") + : isNew + ? t("common.add", "新增") + : t("common.save", "保存")} + + } + > + + {isNew && (
- + - setFormData({ ...formData, displayName: e.target.value }) + setFormData({ ...formData, modelId: e.target.value }) } - placeholder={t("usage.displayNamePlaceholder", { - defaultValue: "例如: Claude 3.5 Sonnet", + placeholder={t("usage.modelIdPlaceholder", { + defaultValue: "例如: claude-3-5-sonnet-20241022", })} required />
+ )} -
- - - setFormData({ ...formData, inputCost: e.target.value }) - } - required - /> -
+
+ + + setFormData({ ...formData, displayName: e.target.value }) + } + placeholder={t("usage.displayNamePlaceholder", { + defaultValue: "例如: Claude 3.5 Sonnet", + })} + required + /> +
-
- - - setFormData({ ...formData, outputCost: e.target.value }) - } - required - /> -
+
+ + + setFormData({ ...formData, inputCost: e.target.value }) + } + required + /> +
-
- - - setFormData({ ...formData, cacheReadCost: e.target.value }) - } - required - /> -
+
+ + + setFormData({ ...formData, outputCost: e.target.value }) + } + required + /> +
-
- - - setFormData({ ...formData, cacheCreationCost: e.target.value }) - } - required - /> -
+
+ + + setFormData({ ...formData, cacheReadCost: e.target.value }) + } + required + /> +
- - - - - -
-
+
+ + + setFormData({ ...formData, cacheCreationCost: e.target.value }) + } + required + /> +
+ + ); }