mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-06-30 10:35:55 +08:00
feat(frontend): 对局视图 + 回放视图 + 计时器 hook
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useGameStore } from '../../store/gameStore';
|
||||
|
||||
interface Props {
|
||||
onBackToMenu: () => void;
|
||||
}
|
||||
|
||||
export default function GameControls({ onBackToMenu }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const undo = useGameStore((s) => s.undo);
|
||||
const mode = useGameStore((s) => s.mode);
|
||||
const status = useGameStore((s) => s.status);
|
||||
|
||||
const handleUndo = () => {
|
||||
undo(1);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="game-controls">
|
||||
<button onClick={handleUndo} disabled={status === 'game_over'}>
|
||||
{t('game.undo')}
|
||||
</button>
|
||||
<button onClick={onBackToMenu}>{t('game.new_game')}</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user