Commit 98b281d7 authored by Chunchi Che's avatar Chunchi Che

add navigatin

parent be7512d0
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import { createSlice } from "@reduxjs/toolkit"; import { createSlice } from "@reduxjs/toolkit";
import { InitInfo, meInfoInitImpl, opInfoInitImpl } from "./initInfoSlice"; import { InitInfo, meInfoInitImpl, opInfoInitImpl } from "./initInfoSlice";
import { Hands, meAddHandsImpl, opAddHandsImpl } from "./handsSlice"; import { Hands, meAddHandsImpl, opAddHandsImpl } from "./handsSlice";
import { RootState } from "../../store";
export interface DuelState { export interface DuelState {
meInitInfo?: InitInfo; // 自己的初始状态 meInitInfo?: InitInfo; // 自己的初始状态
...@@ -29,4 +30,7 @@ const duelSlice = createSlice({ ...@@ -29,4 +30,7 @@ const duelSlice = createSlice({
export const { meInfoInit, opInfoInit, meAddHands, opAddHands } = export const { meInfoInit, opInfoInit, meAddHands, opAddHands } =
duelSlice.actions; duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null;
};
export default duelSlice.reducer; export default duelSlice.reducer;
...@@ -14,7 +14,10 @@ import { ...@@ -14,7 +14,10 @@ import {
unSelectTpAble, unSelectTpAble,
} from "../reducers/moraSlice"; } from "../reducers/moraSlice";
import { selectPlayer0, selectPlayer1 } from "../reducers/playerSlice"; import { selectPlayer0, selectPlayer1 } from "../reducers/playerSlice";
import { selectDuelHsStart } from "../reducers/duel/mod";
import { store } from "../store"; import { store } from "../store";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
// TODO: 应该展示聊天信息 // TODO: 应该展示聊天信息
export default function Mora() { export default function Mora() {
...@@ -23,6 +26,13 @@ export default function Mora() { ...@@ -23,6 +26,13 @@ export default function Mora() {
const selectTpAble = useAppSelector(selectTpSelectAble); const selectTpAble = useAppSelector(selectTpSelectAble);
const player0 = useAppSelector(selectPlayer0); const player0 = useAppSelector(selectPlayer0);
const player1 = useAppSelector(selectPlayer1); const player1 = useAppSelector(selectPlayer1);
const duelHsStart = useAppSelector(selectDuelHsStart);
useEffect(() => {
if (duelHsStart) {
useNavigate()("/duel");
}
}, [duelHsStart]);
const handleSelectScissors = () => { const handleSelectScissors = () => {
sendHandResult("scissors"); sendHandResult("scissors");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment