forked from eesast/web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): switches for playback, playground & stream (eesast#1695)
- Loading branch information
Showing
7 changed files
with
215 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,68 @@ | ||
import React from "react"; | ||
import React, { useEffect } from "react"; | ||
import { ContestProps } from "."; | ||
import { useUrl } from "@/api/hooks/url"; | ||
import NotImplementedPage from "./Components/NotImplemented"; | ||
import * as graphql from "@/generated/graphql"; | ||
import NotImplemented from "./Components/NotImplemented"; | ||
import { message } from "antd"; | ||
import styled from "styled-components"; | ||
|
||
const Container = styled.div` | ||
height: calc(100vh - 72px); | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
const PlaygroundPage: React.FC<ContestProps> = ({ mode, user }) => { | ||
const url = useUrl(); | ||
const contest = url.query.get("contest"); | ||
|
||
if (contest === "b4e3f620-49f7-4883-ba0f-81cbfdcf6196") { | ||
return ( | ||
<div> | ||
<h1>Playground for THUAI7, not implemented yet.</h1> | ||
</div> | ||
); | ||
} else { | ||
return <NotImplementedPage />; | ||
} | ||
const { data: contestNameData, error: contestNameError } = | ||
graphql.useGetContestNameSuspenseQuery({ | ||
variables: { | ||
contest_id: contest, | ||
}, | ||
}); | ||
useEffect(() => { | ||
if (contestNameError) { | ||
message.error("获取比赛信息失败"); | ||
console.log(contestNameError.message); | ||
} | ||
}); | ||
|
||
const { data: contestSwitchData, error: contestSwitchError } = | ||
graphql.useGetContestSwitchSubscription({ | ||
variables: { | ||
contest_id: contest, | ||
}, | ||
}); | ||
useEffect(() => { | ||
if (contestSwitchError) { | ||
message.error("获取比赛状态失败"); | ||
console.log(contestSwitchError.message); | ||
} | ||
}); | ||
|
||
const projectUrl = | ||
process.env.REACT_APP_STATIC_URL! + | ||
`/public/WebGL/${contestNameData?.contest_by_pk?.name ?? "Jump"}/`; | ||
const projectName = "Playground"; | ||
|
||
return contestSwitchData?.contest_by_pk?.playground_switch ? ( | ||
// TODO: Copy from PlaybackPage.tsx | ||
<div> | ||
<h1>Playground for THUAI7, not implemented yet.</h1> | ||
<br /> | ||
<p>Project URL: {projectUrl}</p> | ||
<br /> | ||
<p>Project Name: {projectName}</p> | ||
</div> | ||
) : ( | ||
<Container> | ||
<NotImplemented /> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default PlaygroundPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,75 @@ | ||
import { useState } from "react"; | ||
import { useState, useEffect } from "react"; | ||
import React from "react"; | ||
import { useUrl } from "../../api/hooks/url"; | ||
import { ContestProps } from "."; | ||
import THUAI6 from "./Components/THUAI6/StreamNative"; | ||
import * as graphql from "@/generated/graphql"; | ||
import { message } from "antd"; | ||
import styled from "styled-components"; | ||
import NotImplemented from "./Components/NotImplemented"; | ||
|
||
export interface StreamProps { | ||
url: string; | ||
} | ||
|
||
const Container = styled.div` | ||
height: calc(100vh - 72px); | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
const StreamPage: React.FC<ContestProps> = ({ mode, user }) => { | ||
const url = useUrl(); | ||
const Contest_id = url.query.get("contest"); | ||
const [streamUrl, setStreamUrl] = useState<string>("https://api.eesast.com"); | ||
const contest = url.query.get("contest"); | ||
|
||
const { data: contestNameData, error: contestNameError } = | ||
graphql.useGetContestNameSuspenseQuery({ | ||
variables: { | ||
contest_id: contest, | ||
}, | ||
}); | ||
useEffect(() => { | ||
if (contestNameError) { | ||
message.error("获取比赛信息失败"); | ||
console.log(contestNameError.message); | ||
} | ||
}); | ||
|
||
const { data: contestSwitchData, error: contestSwitchError } = | ||
graphql.useGetContestSwitchSubscription({ | ||
variables: { | ||
contest_id: contest, | ||
}, | ||
}); | ||
useEffect(() => { | ||
if (contestSwitchError) { | ||
message.error("获取比赛状态失败"); | ||
console.log(contestSwitchError.message); | ||
} | ||
}); | ||
|
||
const [streamUrl, setStreamUrl] = useState<string>( | ||
"https://api.eesast.com:8879", | ||
); | ||
if (url.query.get("url") !== null) { | ||
setStreamUrl("http://" + url.query.get("url")); | ||
} | ||
if (Contest_id === "211b9ac2-f004-489d-bd71-4bdde335b597") | ||
return <THUAI6 url={streamUrl} />; | ||
|
||
const Stream = (props: StreamProps) => { | ||
if (contestNameData?.contest_by_pk?.name === "THUAI6") | ||
return <THUAI6 url={props.url} />; | ||
else return <NotImplemented />; | ||
}; | ||
|
||
return contestSwitchData?.contest_by_pk?.stream_switch ? ( | ||
<Stream url={streamUrl} /> | ||
) : ( | ||
<Container> | ||
<NotImplemented /> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default StreamPage; |
Oops, something went wrong.