import React from 'react'; import { createPortal } from 'react-dom'; import { Bot, Loader2, Save, Settings, X } from 'lucide-react'; import type { AccountDetail, AIReplySettings } from '../../../../types'; // AccountAISettingsModalProps 描述账号 AI 设置弹窗需要的状态和回调。 export interface AccountAISettingsModalProps { // account 是当前正在编辑 AI 设置的账号。 account: AccountDetail; // settings 是账号 AI 设置编辑草稿。 settings: AIReplySettings; // saving 表示 AI 设置保存请求是否正在执行。 saving: boolean; // onChange 更新 AI 设置草稿。 onChange: (settings: AIReplySettings) => void; // onClose 关闭 AI 设置弹窗。 onClose: () => void; // onSave 保存 AI 设置并刷新账号列表。 onSave: () => void | Promise; } // AccountAISettingsModal 渲染账号 AI 自动回复策略编辑界面。 export const AccountAISettingsModal: React.FC = ({ account, settings, saving, onChange, onClose, onSave }) => { // updateSettings 使用最新草稿合并单个 AI 字段变化。 const updateSettings = (patch: Partial) => onChange({ ...settings, ...patch }); // handleEnabledChange 切换 AI 自动回复开关。 const handleEnabledChange = () => updateSettings({ ai_enabled: !settings.ai_enabled }); // handleDiscountPercentChange 更新最大折扣比例。 const handleDiscountPercentChange = (event: React.ChangeEvent) => updateSettings({ max_discount_percent: parseInt(event.target.value, 10) || 0 }); // handleDiscountAmountChange 更新最大折扣金额。 const handleDiscountAmountChange = (event: React.ChangeEvent) => updateSettings({ max_discount_amount: parseInt(event.target.value, 10) || 0 }); // handleBargainRoundsChange 更新最大砍价轮次。 const handleBargainRoundsChange = (event: React.ChangeEvent) => updateSettings({ max_bargain_rounds: parseInt(event.target.value, 10) || 1 }); // handlePromptChange 更新自定义 AI 提示词。 const handlePromptChange = (event: React.ChangeEvent) => updateSettings({ custom_prompts: event.target.value }); return createPortal(

AI助手设置

{account.nickname || account.remark || account.id}

启用AI自动回复
AI将自动处理买家的砍价消息

砍价策略

例如:10 表示最多降价 10%;设为 0 表示不允许降价

例如:100 表示最多降价 100 元;设为 0 表示不允许降价

买家最多可以砍价的次数