Commit 3159c733 authored by Chunchi Che's avatar Chunchi Che

update Match.tsx

parent 405944be
Pipeline #23206 passed with stages
in 11 minutes and 7 seconds
...@@ -29,12 +29,53 @@ export const Component: React.FC = () => { ...@@ -29,12 +29,53 @@ export const Component: React.FC = () => {
); );
const { decks } = useSnapshot(deckStore); const { decks } = useSnapshot(deckStore);
const [deck, setDeck] = useState<IDeck>(JSON.parse(JSON.stringify(decks[0]))); const [deck, setDeck] = useState<IDeck>(JSON.parse(JSON.stringify(decks[0])));
const { user } = useSnapshot(accountStore); const user = accountStore.user;
const { joined } = useSnapshot(roomStore); const { joined } = useSnapshot(roomStore);
const [singleLoading, setSingleLoading] = useState(false); // 单人模式的loading状态 const [singleLoading, setSingleLoading] = useState(false); // 单人模式的loading状态
const [matchLoading, setMatchLoading] = useState(false); const [matchLoading, setMatchLoading] = useState(false);
const navigate = useNavigate(); const navigate = useNavigate();
// 竞技匹配
const onCompetitiveMatch = () => message.error("暂未开放,敬请期待");
// 娱乐匹配
const onEntertainMatch = async () => {
if (!user) {
message.error("请先登录萌卡账号");
} else {
setMatchLoading(true);
const matchInfo = await match(user.username, user.external_id);
if (matchInfo) {
await connectSrvpro({
ip: matchInfo.address + ":" + (matchInfo.port + 1),
player: user.username,
passWd: matchInfo.password,
});
} else {
message.error("匹配失败T_T");
}
}
};
// 单人模式
const onAIMatch = async () => {
setSingleLoading(true);
// 初始化,然后等待后端通知成功加入房间后跳转页面
await connectSrvpro({
ip: server,
player: user?.name ?? "Guest",
passWd: "AI",
});
};
// 自定义房间
const onCustomRoom = () => (matchStore.open = true);
// 观战列表
const onWatchList = () => message.error("开发中,敬请期待");
useEffect(() => { useEffect(() => {
if (joined) { if (joined) {
setSingleLoading(false); setSingleLoading(false);
...@@ -95,7 +136,7 @@ export const Component: React.FC = () => { ...@@ -95,7 +136,7 @@ export const Component: React.FC = () => {
title="竞技匹配" title="竞技匹配"
desc="与天梯其他数万名玩家激战,追求胜利登顶最强。每月最后一天晚上10点结算成绩,获取奖励与公布排名。" desc="与天梯其他数万名玩家激战,追求胜利登顶最强。每月最后一天晚上10点结算成绩,获取奖励与公布排名。"
icon={<IconFont type="icon-battle" size={32} />} icon={<IconFont type="icon-battle" size={32} />}
onClick={() => message.error("开发中,敬请期待")} onClick={onCompetitiveMatch}
/> />
<Mode <Mode
title="娱乐匹配" title="娱乐匹配"
...@@ -107,27 +148,7 @@ export const Component: React.FC = () => { ...@@ -107,27 +148,7 @@ export const Component: React.FC = () => {
<IconFont type="icon-coffee" size={28} /> <IconFont type="icon-coffee" size={28} />
) )
} }
onClick={async () => { onClick={onEntertainMatch}
if (!user) {
message.error("请先登录萌卡账号");
} else {
setMatchLoading(true);
const matchInfo = await match(
user.username,
user.external_id,
);
if (matchInfo) {
await connectSrvpro({
ip: matchInfo.address + ":" + (matchInfo.port + 1),
player: user.username,
passWd: matchInfo.password,
});
} else {
message.error("匹配失败T_T");
}
}
}}
/> />
<Mode <Mode
title="单人模式" title="单人模式"
...@@ -139,22 +160,13 @@ export const Component: React.FC = () => { ...@@ -139,22 +160,13 @@ export const Component: React.FC = () => {
<IconFont type="icon-chip" size={26} /> <IconFont type="icon-chip" size={26} />
) )
} }
onClick={async () => { onClick={onAIMatch}
setSingleLoading(true);
// 初始化,然后等待后端通知成功加入房间后跳转页面
await connectSrvpro({
ip: server,
player: user?.name ?? "Guest",
passWd: "AI",
});
}}
/> />
<Mode <Mode
title="自定义房间" title="自定义房间"
desc="创建双打TAG或自定义规则的房间,或与好友约战,甚至举办竞技比赛。" desc="创建双打TAG或自定义规则的房间,或与好友约战,甚至举办竞技比赛。"
icon={<SettingFilled />} icon={<SettingFilled />}
onClick={() => (matchStore.open = true)} onClick={onCustomRoom}
/> />
<Mode <Mode
title="录像回放" title="录像回放"
...@@ -166,7 +178,7 @@ export const Component: React.FC = () => { ...@@ -166,7 +178,7 @@ export const Component: React.FC = () => {
title="观战列表" title="观战列表"
desc="观看MyCard上正在进行的决斗" desc="观看MyCard上正在进行的决斗"
icon={<PlayCircleOutlined />} icon={<PlayCircleOutlined />}
onClick={() => message.error("开发中,敬请期待")} onClick={onWatchList}
/> />
</div> </div>
</div> </div>
......
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