import React from 'react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/alert-dialog' import { Plus, Trash2 } from 'lucide-react' import type { BotConfig } from '../types' interface BotInfoSectionProps { config: BotConfig onChange: (config: BotConfig) => void } export const BotInfoSection = React.memo(function BotInfoSection({ config, onChange }: BotInfoSectionProps) { // 确保 platforms 和 alias_names 始终是数组 const platforms = config.platforms || [] const aliasNames = config.alias_names || [] const addPlatform = () => { onChange({ ...config, platforms: [...platforms, ''] }) } const removePlatform = (index: number) => { onChange({ ...config, platforms: platforms.filter((_, i) => i !== index), }) } const updatePlatform = (index: number, value: string) => { const newPlatforms = [...platforms] newPlatforms[index] = value onChange({ ...config, platforms: newPlatforms }) } const addAlias = () => { onChange({ ...config, alias_names: [...aliasNames, ''] }) } const removeAlias = (index: number) => { onChange({ ...config, alias_names: aliasNames.filter((_, i) => i !== index), }) } const updateAlias = (index: number, value: string) => { const newAliases = [...aliasNames] newAliases[index] = value onChange({ ...config, alias_names: newAliases }) } return (

基本信息

onChange({ ...config, platform: e.target.value })} placeholder="qq" />
onChange({ ...config, qq_account: e.target.value })} placeholder="123456789" />
onChange({ ...config, nickname: e.target.value })} placeholder="麦麦" />
{aliasNames.map((alias, index) => (
updateAlias(index, e.target.value)} placeholder="小麦" /> 确认删除 确定要删除别名 "{alias || '(空)'}" 吗?此操作无法撤销。 取消 removeAlias(index)}> 删除
))} {aliasNames.length === 0 && (

暂无别名

)}
{platforms.map((platform, index) => (
updatePlatform(index, e.target.value)} placeholder="wx:114514" /> 确认删除 确定要删除平台账号 "{platform || '(空)'}" 吗?此操作无法撤销。 取消 removePlatform(index)}> 删除
))} {platforms.length === 0 && (

暂无其他平台账号

)}
) })