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; onPublish: (payload: BarkBattleConfigEditorPayload) => void | Promise; onBack?: () => void; }; 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, onPublish, onBack, }: 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 [error, setError] = 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) { setError('请先填写作品标题'); return; } setError(null); void onPublish(payload); }; return (

轻配置作品

汪汪声浪大作战

配置展示、皮肤、难度和排行榜;公平性规则由后端固定裁决。

{onBack ? ( ) : null}