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";
|
|
|
|
|
import {useEffect, useState} from "react";
|
|
|
|
|
import {OsuRenderer} from "@/osu/OsuRenderer";
|
2024-03-03 22:27:54 +00:00
|
|
|
import {Stats} from "@/interface/composites/stats";
|
2024-03-03 15:22:03 +00:00
|
|
|
|
|
|
|
|
export function App() {
|
|
|
|
|
|
2024-03-03 22:27:54 +00:00
|
|
|
const [replayId, setReplayId] = useState<number>(0);
|
2024-03-03 15:22:03 +00:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
2024-03-03 22:27:54 +00:00
|
|
|
let pathReplayId = Number.parseInt(location.pathname.slice(1, location.pathname.length));
|
2024-03-03 15:22:03 +00:00
|
|
|
|
|
|
|
|
const loadReplay = async () => {
|
2024-03-03 17:23:35 +00:00
|
|
|
if(document.location.hostname === "localhost") {
|
2024-03-03 22:27:54 +00:00
|
|
|
await OsuRenderer.loadReplayFromUrl(`http://localhost:8080/score/${pathReplayId}/replay`, pathReplayId);
|
2024-03-03 17:23:35 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2024-03-03 22:27:54 +00:00
|
|
|
await OsuRenderer.loadReplayFromUrl(`https://nise.moe/api/score/${pathReplayId}/replay`, pathReplayId);
|
2024-03-03 15:22:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if(replayId !== pathReplayId) {
|
|
|
|
|
setReplayId(pathReplayId);
|
|
|
|
|
loadReplay();
|
|
|
|
|
}
|
|
|
|
|
}, [location.pathname]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Navbar/>
|
|
|
|
|
<AboutDialog/>
|
|
|
|
|
<SongSlider/>
|
2024-03-03 22:27:54 +00:00
|
|
|
<Stats/>
|
2024-03-03 15:22:03 +00:00
|
|
|
<Helper/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|