import { useEffect } from 'react' import { useParams } from 'react-router-dom' import { useProjectStore } from '../stores/project' import { useToastStore } from '../stores/toast' import { PROJECT_TYPES, PROJECT_TYPE_KEY, getCustomTags } from '../utils/style' import StyleSelector from './StyleSelector' import CustomTagsEditor from './CustomTagsEditor' import Skeleton from './Skeleton' export default function ProjectConfigPanel() { const { projectId = '' } = useParams() const { draftName, draftStyle, hasUnsavedChanges, loading, loadProject, loadStyle, startEditing, updateDraft, setDraftStyle, setDraftName, discardDraft, commitDraft, } = useProjectStore() const addToast = useToastStore(s => s.addToast) useEffect(() => { if (projectId) { loadProject(projectId) loadStyle(projectId) startEditing() } }, [projectId, loadProject, loadStyle, startEditing]) const handleSave = async () => { try { await commitDraft() addToast({ type: 'success', message: '配置已保存' }) } catch { addToast({ type: 'error', message: '保存失败' }) } } if (loading) { return (
) } return (
setDraftName(e.target.value)} style={{ width: '100%', fontSize: 16, fontWeight: 600, padding: '4px 0', border: 'none', background: 'transparent', outline: 'none', borderBottom: '2px solid transparent', }} onFocus={e => (e.target.style.borderBottomColor = 'var(--accent)')} onBlur={e => (e.target.style.borderBottomColor = 'transparent')} />
({ value: p.value, label: p.label })), }]} customTags={getCustomTags(draftStyle)} />
) }