[O] Get userid dynamically

pull/10/head
Azalea 2024-02-09 21:05:53 -05:00
parent 6690c665dd
commit 66034ea407
2 changed files with 17 additions and 11 deletions

View File

@ -10,6 +10,6 @@
<Router {url}> <Router {url}>
<div> <div>
<Route path="/"><Home /></Route> <Route path="/"><Home /></Route>
<Route path="/mai/rating"><MaimaiRating /></Route> <Route path="/u/:userId/mai/rating" component={MaimaiRating}></Route>
</div> </div>
</Router> </Router>

View File

@ -3,6 +3,22 @@
import {getMaimai, getMult} from "../libs/maimai"; import {getMaimai, getMult} from "../libs/maimai";
import type {ParsedRating, Rating} from "../libs/maimaiTypes"; import type {ParsedRating, Rating} from "../libs/maimaiTypes";
export let userId: any
userId = +userId
if (!userId) console.error("No user ID provided")
else {
getMaimai("GetUserRatingApi", {userId}).then(it => {
data = it
parseRatings()
})
fetch(`${data_host}/maimai/meta/00/all-music.json`).then(it => it.json()).then(it => {
musicInfo = it
parseRatings()
})
}
function parseRatings() { function parseRatings() {
if (!data || !musicInfo) return if (!data || !musicInfo) return
parsedRatings = { parsedRatings = {
@ -44,16 +60,6 @@
} | null = null } | null = null
let musicInfo: any = null let musicInfo: any = null
getMaimai("GetUserRatingApi", {userId: 61702139}).then(it => {
data = it
parseRatings()
})
fetch(`${data_host}/maimai/meta/00/all-music.json`).then(it => it.json()).then(it => {
musicInfo = it
parseRatings()
})
</script> </script>
<!-- Display all parsed ratings --> <!-- Display all parsed ratings -->