Skip to content

Commit

Permalink
chore: disable polling for io, fix competition side
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed May 7, 2024
1 parent 6269e29 commit 7cc9e9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"scripts": {
"dev": "gulp dev",
"dev:competition-side": "cross-env COMPETITION_SIDE=1 gulp dev",
"start": "cross-env BROWSER=none umi dev",
"dup-less": "gulp dup-less",
"build": "umi build",
Expand Down
16 changes: 13 additions & 3 deletions src/layouts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class Index extends React.Component<Props, State> {
const sockets: Record<string, SocketIOClient.Socket> = {};
sockets.judger = io(socketConfig.judger.url, {
path: socketConfig.path,
transports: ['websocket'],
});
sockets.judger.on('connect', () => {
// console.log('judger socket connected');
Expand Down Expand Up @@ -296,7 +297,10 @@ class Index extends React.Component<Props, State> {
const blockedByCompetitionSide =
isCompetitionSide() && !location.pathname.startsWith('/competitions');
const hideNav =
blockedByCompetitionSide || (isCompetitionSide() && location.pathname === '/competitions');
blockedByCompetitionSide ||
(isCompetitionSide() &&
(location.pathname === '/competitions' ||
location.pathname.startsWith('/competitions-public')));
return (
<Layout
className={classNames({
Expand Down Expand Up @@ -327,8 +331,14 @@ class Index extends React.Component<Props, State> {
</Header>
<Content>
<NoticeModal />
{blockedByCompetitionSide ? null : this.state.sessionLoaded ||
location.pathname === '/OJBK' ? (
{blockedByCompetitionSide ? (
<div className="center-view">
<h3 className="mb-xl">This page is not allowed to access</h3>
<Link to={pages.competitions.index}>
<Button type="default">Back to Competitions</Button>
</Link>
</div>
) : this.state.sessionLoaded || location.pathname === '/OJBK' ? (
children
) : (
<PageLoading />
Expand Down

0 comments on commit 7cc9e9a

Please sign in to comment.