[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}>
<div>
<Route path="/"><Home /></Route>
<Route path="/mai/rating"><MaimaiRating /></Route>
<Route path="/u/:userId/mai/rating" component={MaimaiRating}></Route>
</div>
</Router>

View File

@ -3,6 +3,22 @@
import {getMaimai, getMult} from "../libs/maimai";
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() {
if (!data || !musicInfo) return
parsedRatings = {
@ -44,16 +60,6 @@
} | null = 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>
<!-- Display all parsed ratings -->