import { useState } from 'react' import { PROJECT_TYPES, PROJECT_TYPE_KEY, getCustomTags } from '../utils/style' import StyleSelector from './StyleSelector' import CustomTagsEditor from './CustomTagsEditor' interface CreateProjectModalProps { open: boolean onClose: () => void onSubmit: (name: string, style: Record) => Promise } export default function CreateProjectModal({ open, onClose, onSubmit, }: CreateProjectModalProps) { const [name, setName] = useState('') const [style, setStyle] = useState>({}) const [submitting, setSubmitting] = useState(false) if (!open) return null const handleStyleChange = (key: string, value: string) => { setStyle(prev => prev[key] === value ? (() => { const { [key]: _, ...rest } = prev return rest })() : { ...prev, [key]: value } ) } const handleSubmit = async () => { if (!name.trim()) return setSubmitting(true) try { await onSubmit(name.trim(), style) setName('') setStyle({}) onClose() } finally { setSubmitting(false) } } return (
e.stopPropagation()} >

新建工程

({ value: p.value, label: p.label })), }]} customTags={getCustomTags(style)} />
) }