Commit 04548ae3 authored by Chunchi Che's avatar Chunchi Che

update

parent e6c4ec4a
Pipeline #23637 passed with stages
in 16 minutes and 4 seconds
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
"name":"koishi", "name":"koishi",
"ip":"koishi.momobako.com", "ip":"koishi.momobako.com",
"port":"7211" "port":"7211"
},
{
"name":"mycard",
"ip":"tiramisu.moecube.com",
"port":"7912"
} }
], ],
"assetsPath":"/neos-assets", "assetsPath":"/neos-assets",
...@@ -18,7 +23,7 @@ ...@@ -18,7 +23,7 @@
"profileUrl":"https://accounts.moecube.com/profiles", "profileUrl":"https://accounts.moecube.com/profiles",
"athleticWatchUrl":"wss://tiramisu.moecube.com:8923", "athleticWatchUrl":"wss://tiramisu.moecube.com:8923",
"entertainWatchUrl":"wss://tiramisu.moecube.com:7923", "entertainWatchUrl":"wss://tiramisu.moecube.com:7923",
"avatarApi": "https://sapi.moecube.com:444/avatar/avatar/{username}/120/1.png", "avatarApi":"https://sapi.moecube.com:444/avatar/avatar/{username}/120/1.png",
"streamInterval":20, "streamInterval":20,
"startDelay":1000, "startDelay":1000,
"ui":{ "ui":{
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
"name":"koishi", "name":"koishi",
"ip":"koishi.momobako.com", "ip":"koishi.momobako.com",
"port":"7211" "port":"7211"
},
{
"name":"mycard",
"ip":"tiramisu.moecube.com",
"port":"7912"
} }
], ],
"assetsPath":"/neos-assets", "assetsPath":"/neos-assets",
...@@ -18,7 +23,7 @@ ...@@ -18,7 +23,7 @@
"profileUrl":"https://accounts.moecube.com/profiles", "profileUrl":"https://accounts.moecube.com/profiles",
"athleticWatchUrl":"wss://tiramisu.moecube.com:8923", "athleticWatchUrl":"wss://tiramisu.moecube.com:8923",
"entertainWatchUrl":"wss://tiramisu.moecube.com:7923", "entertainWatchUrl":"wss://tiramisu.moecube.com:7923",
"avatarApi": "https://sapi.moecube.com:444/avatar/avatar/{username}/120/1.png", "avatarApi":"https://sapi.moecube.com:444/avatar/avatar/{username}/120/1.png",
"streamInterval":20, "streamInterval":20,
"startDelay":1000, "startDelay":1000,
"ui":{ "ui":{
......
...@@ -33,7 +33,9 @@ interface Options { ...@@ -33,7 +33,9 @@ interface Options {
auto_death: boolean; auto_death: boolean;
} }
export const WatchModal: React.FC = () => { export const WatchContent: React.FC<{
setWatchPasswd: React.Dispatch<React.SetStateAction<string | undefined>>;
}> = ({ setWatchPasswd }) => {
const [rooms, setRooms] = useState<Room[]>([]); const [rooms, setRooms] = useState<Room[]>([]);
const { message } = App.useApp(); const { message } = App.useApp();
const url = new URL(athleticWatchUrl); const url = new URL(athleticWatchUrl);
...@@ -99,7 +101,7 @@ export const WatchModal: React.FC = () => { ...@@ -99,7 +101,7 @@ export const WatchModal: React.FC = () => {
}} }}
dataSource={rooms} dataSource={rooms}
renderItem={(room) => ( renderItem={(room) => (
<List.Item key={room.id}> <List.Item key={room.id} onClick={() => setWatchPasswd(room.id)}>
<List.Item.Meta <List.Item.Meta
avatar={ avatar={
<Avatar <Avatar
......
...@@ -18,9 +18,9 @@ import styles from "./index.module.scss"; ...@@ -18,9 +18,9 @@ import styles from "./index.module.scss";
import { MatchModal, matchStore } from "./MatchModal"; import { MatchModal, matchStore } from "./MatchModal";
import { ReplayModal, replayOpen } from "./ReplayModal"; import { ReplayModal, replayOpen } from "./ReplayModal";
import { connectSrvpro } from "./util"; import { connectSrvpro } from "./util";
import { WatchModal } from "./WatchModal"; import { WatchContent } from "./WatchModal";
const NeosConfig = useConfig(); const { servers: serverList } = useConfig();
export const loader: LoaderFunction = () => { export const loader: LoaderFunction = () => {
// 在加载这个页面之前先重置一些store,清掉上局游戏遗留的数据 // 在加载这个页面之前先重置一些store,清掉上局游戏遗留的数据
...@@ -30,7 +30,6 @@ export const loader: LoaderFunction = () => { ...@@ -30,7 +30,6 @@ export const loader: LoaderFunction = () => {
export const Component: React.FC = () => { export const Component: React.FC = () => {
const { message, modal } = App.useApp(); const { message, modal } = App.useApp();
const serverList = NeosConfig.servers;
const server = `${serverList[0].ip}:${serverList[0].port}`; const server = `${serverList[0].ip}:${serverList[0].port}`;
const { decks } = deckStore; const { decks } = deckStore;
const [deckName, setDeckName] = useState(decks.at(0)?.deckName ?? ""); const [deckName, setDeckName] = useState(decks.at(0)?.deckName ?? "");
...@@ -38,6 +37,8 @@ export const Component: React.FC = () => { ...@@ -38,6 +37,8 @@ export const Component: React.FC = () => {
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); // 匹配模式的loading状态 const [matchLoading, setMatchLoading] = useState(false); // 匹配模式的loading状态
const [watchLoading, setWatchLoading] = useState(false); // 观战模式的loading状态
const [watchPasswd, setWatchPasswd] = useState<string | undefined>(undefined);
const navigate = useNavigate(); const navigate = useNavigate();
// 竞技匹配 // 竞技匹配
...@@ -63,6 +64,43 @@ export const Component: React.FC = () => { ...@@ -63,6 +64,43 @@ export const Component: React.FC = () => {
} }
}; };
// MC观战
const onMCWatch = () => {
if (!user) {
message.error("请先登录萌卡账号");
} else {
modal.info({
icon: null,
okText: "进入观战",
onOk: async () => {
if (watchPasswd) {
setWatchLoading(true);
const mcServer = serverList.find(
(server) => server.name === "mycard",
);
if (mcServer) {
await connectSrvpro({
ip: mcServer.ip + ":" + mcServer.port,
player: user.username,
passWd: watchPasswd,
});
} else {
message.error(
"Something unexpected happened, please contact <ccc@neos.moe> to fix",
);
}
} else {
message.error("请选择观战的房间");
}
},
centered: true,
maskClosable: true,
content: <WatchContent setWatchPasswd={setWatchPasswd} />,
});
}
};
// 单人模式 // 单人模式
const onAIMatch = async () => { const onAIMatch = async () => {
setSingleLoading(true); setSingleLoading(true);
...@@ -82,6 +120,7 @@ export const Component: React.FC = () => { ...@@ -82,6 +120,7 @@ export const Component: React.FC = () => {
if (joined) { if (joined) {
setSingleLoading(false); setSingleLoading(false);
setMatchLoading(false); setMatchLoading(false);
setWatchLoading(false);
navigate(`/waitroom`); navigate(`/waitroom`);
} }
}, [joined]); }, [joined]);
...@@ -142,16 +181,8 @@ export const Component: React.FC = () => { ...@@ -142,16 +181,8 @@ export const Component: React.FC = () => {
<Mode <Mode
title="MC观战列表" title="MC观战列表"
desc="观看萌卡MyCard上正在进行的决斗。" desc="观看萌卡MyCard上正在进行的决斗。"
icon={<PlayCircleFilled />} icon={watchLoading ? <LoadingOutlined /> : <PlayCircleFilled />}
onClick={() => onClick={onMCWatch}
modal.info({
icon: null,
footer: <></>,
centered: true,
maskClosable: true,
content: <WatchModal />,
})
}
/> />
<Mode <Mode
title="单人模式" title="单人模式"
......
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