Commit 7553a952 authored by Chunchi Che's avatar Chunchi Che

finish side migration 100%

parent cf314eab
Pipeline #23299 passed with stages
in 12 minutes and 29 seconds
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { useSnapshot } from "valtio";
import { resetUniverse } from "@/stores"; import { SideStage, sideStore } from "@/stores";
import { import {
Alert, Alert,
...@@ -20,13 +22,15 @@ import { ...@@ -20,13 +22,15 @@ import {
import { LifeBar, Mat, Menu, Underlying } from "./PlayMat"; import { LifeBar, Mat, Menu, Underlying } from "./PlayMat";
export const Component: React.FC = () => { export const Component: React.FC = () => {
const { stage } = useSnapshot(sideStore);
const navigate = useNavigate();
useEffect(() => { useEffect(() => {
return () => { if (stage === SideStage.SIDE_CHANGING) {
// FIXME // 跳转更换Side
// Duel组件卸载的时候初始化一些store navigate("/side");
resetUniverse(); }
}; }, [stage]);
}, []);
return ( return (
<> <>
......
...@@ -6,12 +6,12 @@ import { ...@@ -6,12 +6,12 @@ import {
} from "@ant-design/icons"; } from "@ant-design/icons";
import { App, Button, Space } from "antd"; import { App, Button, Space } from "antd";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom"; import { LoaderFunction, useNavigate } from "react-router-dom";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import { match } from "@/api"; import { match } from "@/api";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import { accountStore, deckStore, roomStore } from "@/stores"; import { accountStore, deckStore, resetUniverse, roomStore } from "@/stores";
import { Background, IconFont, Select } from "@/ui/Shared"; import { Background, IconFont, Select } from "@/ui/Shared";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
...@@ -21,6 +21,12 @@ import { connectSrvpro } from "./util"; ...@@ -21,6 +21,12 @@ import { connectSrvpro } from "./util";
const NeosConfig = useConfig(); const NeosConfig = useConfig();
export const loader: LoaderFunction = () => {
// 在加载这个页面之前先重置一些store,清掉上局游戏遗留的数据
resetUniverse();
return null;
};
export const Component: React.FC = () => { export const Component: React.FC = () => {
const { message } = App.useApp(); const { message } = App.useApp();
const serverList = NeosConfig.servers; const serverList = NeosConfig.servers;
......
...@@ -5,7 +5,7 @@ import { useSnapshot } from "valtio"; ...@@ -5,7 +5,7 @@ import { useSnapshot } from "valtio";
import { sendTpResult } from "@/api"; import { sendTpResult } from "@/api";
import { SideStage, sideStore } from "@/stores"; import { SideStage, sideStore } from "@/stores";
import styles from "./index.module.scss"; import styles from "./TpModal.module.scss";
export const TpModal: React.FC = () => { export const TpModal: React.FC = () => {
const { stage } = useSnapshot(sideStore); const { stage } = useSnapshot(sideStore);
......
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