[fix] 斷線防呆
This commit is contained in:
parent
0d8a5acabc
commit
02e35e070e
@ -7,6 +7,7 @@ import Image from "@/components/Image/Image";
|
||||
import { useGameItems } from "@/context/GameItemsContext";
|
||||
import { GameLaunchRequest, GameLeaveRequest, RpcGameLaunchResponse } from "@/define/Request/GameRequest";
|
||||
import { SlotData } from "@/define/gameData";
|
||||
import GameManager from "@/modules/GameManager";
|
||||
import { Button, Flex } from "antd";
|
||||
import { useEffect, useState } from "react";
|
||||
import SDGame from "./SDGame";
|
||||
@ -34,6 +35,7 @@ const SlotList = () => {
|
||||
return;
|
||||
}
|
||||
setIsGameIn(true);
|
||||
GameManager.IsInGame = true;
|
||||
const url: string = resp.Data;
|
||||
setGameData({
|
||||
...gameData,
|
||||
@ -55,6 +57,7 @@ const SlotList = () => {
|
||||
gameLeaveReq.Send();
|
||||
setGameUrl("");
|
||||
setIsGameIn(false);
|
||||
GameManager.IsInGame = false;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -3,6 +3,8 @@ import SlotData from "./data/SlotData";
|
||||
class GameManager {
|
||||
/** SlotData */
|
||||
public readonly SlotData: SlotData = new SlotData();
|
||||
|
||||
public IsInGame: boolean = false;
|
||||
}
|
||||
|
||||
export default new GameManager();
|
||||
|
@ -2,9 +2,14 @@ import CSMessage from "@/Common/Message/CSMessage";
|
||||
import { INetResponse } from "@/Engine/CatanEngine/NetManagerV2/Core/INetResponse";
|
||||
import { gameObj } from "@/context/GameItemsContext";
|
||||
import { GameInfoRequest } from "@/define/Request/GameRequest";
|
||||
import GameManager from "@/modules/GameManager";
|
||||
|
||||
export function* gameSync(): IterableIterator<any> {
|
||||
const { gameData, setGameData } = gameObj;
|
||||
if (GameManager.IsInGame) {
|
||||
// 不用同步資料,因為已經在遊戲中,所以不用同步資料。
|
||||
return;
|
||||
}
|
||||
let req: GameInfoRequest = new GameInfoRequest();
|
||||
yield req.SendAsync();
|
||||
let resp: INetResponse<JSON> = req.Result;
|
||||
|
Loading…
Reference in New Issue
Block a user