[O] Encapsulate all music

This commit is contained in:
Azalea
2024-02-12 02:59:25 -05:00
parent 3804db142f
commit 8932a16468
3 changed files with 101 additions and 46 deletions

View File

@@ -1,4 +1,4 @@
import {aqua_host} from "./config";
import {aqua_host, data_host} from "./config";
import type {TrendEntry} from "./generalTypes";
import type {MaimaiUserSummaryEntry} from "./maimaiTypes";
@@ -32,6 +32,10 @@ export async function getMaimai(endpoint: string, params: any) {
}).then(res => res.json())
}
export async function getMaimaiAllMusic(): Promise<{ [key: string]: any }> {
return fetch(`${data_host}/maimai/meta/00/all-music.json`).then(it => it.json())
}
export async function getMaimaiApi(endpoint: string, params: any) {
let url = new URL(`${aqua_host}/api/game/maimai2new/${endpoint}`)
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))