feat(frontend): 菜单组件 — 主菜单/本地双人/AI设置/网络/加载棋谱

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 00:25:19 +08:00
parent 6d8a62eca5
commit a4b3b5c380
5 changed files with 214 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import { useTranslation } from 'react-i18next';
import { useGameStore } from '../../store/gameStore';
import { useState } from 'react';
import type { GameConfig } from '../../core/types';
interface Props { onBack: () => void; onStart: () => void; }
export default function OnlineSetup({ onBack, onStart }: Props) {
const { t } = useTranslation();
const startGame = useGameStore((s) => s.startGame);
const [ip, setIp] = useState('');
const baseConfig: GameConfig = {
boardSize: 15, useForbiddenRules: true, useTimer: false,
timeLimitSecs: 60, aiDifficulty: 3, playerColor: 'Black', isServer: false,
};
const handleHost = async () => {
await startGame('Online', { ...baseConfig, isServer: true });
onStart();
};
const handleJoin = async () => {
await startGame('Online', { ...baseConfig });
onStart();
};
return (
<div className="setup-panel">
<h2>{t('menu.online_game')}</h2>
<button onClick={handleHost}></button>
<div style={{ display: 'flex', gap: 8, marginTop: 12 }}>
<input value={ip} onChange={(e) => setIp(e.target.value)} placeholder="IP:端口" />
<button onClick={handleJoin} disabled={!ip}></button>
</div>
<button onClick={onBack} style={{ marginTop: 12 }}></button>
</div>
);
}