2024-03-03 15:22:03 +00:00
|
|
|
import {AboutDialog} from "./composites/about-dialog";
|
|
|
|
|
import {Navbar} from "./composites/Menu";
|
|
|
|
|
import {SongSlider} from "./composites/song-slider";
|
|
|
|
|
import {Helper} from "./composites/helper";
|
2024-03-04 14:26:11 +00:00
|
|
|
import {useEffect} from "react";
|
2024-03-03 15:22:03 +00:00
|
|
|
import {OsuRenderer} from "@/osu/OsuRenderer";
|
2024-03-03 22:27:54 +00:00
|
|
|
import {Stats} from "@/interface/composites/stats";
|
2024-03-10 14:56:49 +00:00
|
|
|
import {LoadingDialog} from "@/interface/composites/loading-dialog";
|
2024-03-03 15:22:03 +00:00
|
|
|
|
|
|
|
|
export function App() {
|
|
|
|
|
|
2024-03-04 14:26:11 +00:00
|
|
|
const loadReplay = async (replayId: number) => {
|
|
|
|
|
await OsuRenderer.loadReplayFromUrl(replayId);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const loadReplayPair = async (replayId1: number, replayId2: number) => {
|
|
|
|
|
await OsuRenderer.loadReplayPairFromUrl(replayId1, replayId2);
|
|
|
|
|
}
|
2024-03-03 15:22:03 +00:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
2024-03-04 14:26:11 +00:00
|
|
|
// This pattern matches one or more digits followed by an optional slash and any characters (non-greedy)
|
|
|
|
|
const pathRegex = /^\/(\d+)(?:\/(\d+))?/;
|
|
|
|
|
const match = location.pathname.match(pathRegex);
|
2024-03-03 15:22:03 +00:00
|
|
|
|
2024-03-04 14:26:11 +00:00
|
|
|
if (match) {
|
|
|
|
|
// match[1] will contain the first ID, match[2] (if present) will contain the second ID
|
|
|
|
|
const pathReplayId1 = Number.parseInt(match[1]);
|
|
|
|
|
const pathReplayId2 = match[2] ? Number.parseInt(match[2]) : null;
|
2024-03-03 15:22:03 +00:00
|
|
|
|
2024-03-04 14:26:11 +00:00
|
|
|
if(pathReplayId2 != null) {
|
|
|
|
|
loadReplayPair(pathReplayId1, pathReplayId2);
|
|
|
|
|
} else {
|
|
|
|
|
loadReplay(pathReplayId1);
|
|
|
|
|
}
|
2024-03-03 15:22:03 +00:00
|
|
|
}
|
|
|
|
|
}, [location.pathname]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Navbar/>
|
|
|
|
|
<AboutDialog/>
|
2024-03-10 14:56:49 +00:00
|
|
|
<LoadingDialog/>
|
2024-03-03 15:22:03 +00:00
|
|
|
<SongSlider/>
|
2024-03-03 22:27:54 +00:00
|
|
|
<Stats/>
|
2024-03-03 15:22:03 +00:00
|
|
|
<Helper/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|