Commit b8d9f007 authored by Chunchi Che's avatar Chunchi Che

handle EntertainMatch

parent 7f602b1c
Pipeline #22820 passed with stages
in 16 minutes and 20 seconds
......@@ -2,6 +2,7 @@ import React, { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { useSnapshot } from "valtio";
import { match } from "@/api";
import { useConfig } from "@/config";
import { accountStore } from "@/stores";
......@@ -23,6 +24,22 @@ const Home: React.FC = () => {
}:${NeosConfig.servers[0].port}`
);
};
const onEntertainMatch = async () => {
if (user) {
const matchInfo = await match(user.username, user.external_id);
if (matchInfo) {
navigate(
`/room/${user.username}/${encodeURIComponent(matchInfo.password)}/${
matchInfo.address
}:${matchInfo.port}`
);
} else {
alert("匹配失败");
}
} else {
alert("请先登录萌卡账号");
}
};
useEffect(() => {
if (!user) {
......@@ -63,12 +80,12 @@ const Home: React.FC = () => {
<div className={styles.bg}></div>
<div className={styles.box}>
<p>欢迎来到NEOS,{user?.username}</p>
<button>娱乐匹配</button>
<button>竞技匹配</button>
<button onClick={onEntertainMatch}>娱乐匹配</button>
<button onClick={() => alert("暂不支持,敬请期待")}>竞技匹配</button>
<button onClick={() => navigate("/match")}>自定义匹配</button>
<button onClick={onMatchAI}>人机对战</button>
<button onClick={() => navigate("/replay")}>录像回放</button>
<button>卡组编辑</button>
<button onClick={() => alert("暂不支持,敬请期待")}>卡组编辑</button>
</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