import { ArrowLeft, Loader2, Trophy, WandSparkles } from 'lucide-react'; import { useMemo, useState } from 'react'; import type { BarkBattleConfigEditorPayload } from '../../../packages/shared/src/contracts/barkBattle'; import type { BarkBattleDifficultyPreset } from '../../../packages/shared/src/contracts/barkBattle'; import { BarkBattlePreviewCard } from './BarkBattlePreviewCard'; export type BarkBattleConfigEditorProps = { isBusy?: boolean; error?: string | null; onPublish: (payload: BarkBattleConfigEditorPayload) => void | Promise; onBack?: () => void; showBackButton?: boolean; title?: string | null; }; const THEME_OPTIONS = [ { value: 'sunny-yard', label: '阳光院子' }, { value: 'neon-park', label: '霓虹公园' }, { value: 'moonlight-rooftop', label: '月光天台' }, ]; const DOG_SKIN_OPTIONS = [ { value: 'corgi', label: '柯基' }, { value: 'shiba', label: '柴犬' }, { value: 'husky', label: '哈士奇' }, ]; const DIFFICULTY_OPTIONS: Array<{ value: BarkBattleDifficultyPreset; label: string }> = [ { value: 'easy', label: '轻松' }, { value: 'normal', label: '标准' }, { value: 'hard', label: '硬核' }, ]; export function BarkBattleConfigEditor({ isBusy = false, error: externalError = null, onPublish, onBack, showBackButton = true, title: headingTitle = '汪汪声浪大作战', }: BarkBattleConfigEditorProps) { const [title, setTitle] = useState('我的声浪竞技场'); const [description, setDescription] = useState(''); const [themePreset, setThemePreset] = useState('sunny-yard'); const [playerDogSkinPreset, setPlayerDogSkinPreset] = useState('corgi'); const [opponentDogSkinPreset, setOpponentDogSkinPreset] = useState('husky'); const [difficultyPreset, setDifficultyPreset] = useState('normal'); const [leaderboardEnabled, setLeaderboardEnabled] = useState(true); const [localError, setLocalError] = useState(null); const payload = useMemo( () => ({ title: title.trim(), description: description.trim(), themePreset, playerDogSkinPreset, opponentDogSkinPreset, difficultyPreset, leaderboardEnabled, }), [ title, description, themePreset, playerDogSkinPreset, opponentDogSkinPreset, difficultyPreset, leaderboardEnabled, ], ); const handlePublish = () => { if (!payload.title) { setLocalError('请先填写作品标题'); return; } setLocalError(null); void onPublish(payload); }; const visibleError = localError ?? externalError; return (
{showBackButton && onBack ? (
) : null}
{headingTitle ? (

{headingTitle}

轻配置
) : null}