Commit e17b4245 authored by Chunchi Che's avatar Chunchi Che

add auto return to single mode

parent 102cf9fc
Pipeline #28720 passed with stages
in 15 minutes and 47 seconds
...@@ -84,4 +84,8 @@ export class WebSocketStream { ...@@ -84,4 +84,8 @@ export class WebSocketStream {
close() { close() {
this.ws.close(); this.ws.close();
} }
isClosed(): boolean {
return this.ws.readyState === WebSocket.CLOSED;
}
} }
...@@ -5,6 +5,5 @@ export default function handleDuelEnd( ...@@ -5,6 +5,5 @@ export default function handleDuelEnd(
container: Container, container: Container,
_pb: ygopro.YgoStocMsg, _pb: ygopro.YgoStocMsg,
) { ) {
console.log("duel end");
container.context.matStore.duelEnd = true; container.context.matStore.duelEnd = true;
} }
import { App } from "antd";
import React, { CSSProperties } from "react"; import React, { CSSProperties } from "react";
import { useNavigate } from "react-router-dom";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
import { fetchStrings, Region } from "@/api"; import { fetchStrings, Region } from "@/api";
import { getUIContainer } from "@/container/compat";
import { replayStore, resetDuel } from "@/stores"; import { replayStore, resetDuel } from "@/stores";
import { NeosModal } from "../NeosModal"; import { NeosModal } from "../NeosModal";
...@@ -21,12 +24,21 @@ const defaultProps: EndProps = { ...@@ -21,12 +24,21 @@ const defaultProps: EndProps = {
const localStore = proxy(defaultProps); const localStore = proxy(defaultProps);
export const EndModal: React.FC = () => { export const EndModal: React.FC = () => {
const container = getUIContainer();
const { message } = App.useApp();
const { isOpen, isWin, reason } = useSnapshot(localStore); const { isOpen, isWin, reason } = useSnapshot(localStore);
const { isReplay } = useSnapshot(replayStore); const { isReplay } = useSnapshot(replayStore);
const navigate = useNavigate();
const onReturn = () => { const onReturn = () => {
resetDuel(); resetDuel();
rs(); rs();
if (container.conn.isClosed()) {
message.info("服务器关闭了连接,返回匹配页。");
navigate("/match");
}
}; };
return ( return (
......
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