mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-14 05:27:26 +08:00
[O] Encapsulate all music
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import {aqua_host} from "./config";
|
import {aqua_host, data_host} from "./config";
|
||||||
import type {TrendEntry} from "./generalTypes";
|
import type {TrendEntry} from "./generalTypes";
|
||||||
import type {MaimaiUserSummaryEntry} from "./maimaiTypes";
|
import type {MaimaiUserSummaryEntry} from "./maimaiTypes";
|
||||||
|
|
||||||
@@ -32,6 +32,10 @@ export async function getMaimai(endpoint: string, params: any) {
|
|||||||
}).then(res => res.json())
|
}).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) {
|
export async function getMaimaiApi(endpoint: string, params: any) {
|
||||||
let url = new URL(`${aqua_host}/api/game/maimai2new/${endpoint}`)
|
let url = new URL(`${aqua_host}/api/game/maimai2new/${endpoint}`)
|
||||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
|
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
|
||||||
|
|||||||
@@ -5,39 +5,22 @@ export interface Rating {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ParsedRating extends Rating {
|
export interface ParsedRating extends Rating {
|
||||||
music: {
|
music: MaimaiMusic,
|
||||||
name: string,
|
|
||||||
composer: string,
|
|
||||||
bpm: number,
|
|
||||||
ver: number,
|
|
||||||
note: {
|
|
||||||
lv: number
|
|
||||||
designer: string
|
|
||||||
lv_id: number
|
|
||||||
notes: number
|
|
||||||
}
|
|
||||||
},
|
|
||||||
calc: number,
|
calc: number,
|
||||||
rank: string
|
rank: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MaiUserPreviewData {
|
export interface MaimaiMusic {
|
||||||
userName: string
|
name: string,
|
||||||
userId: number
|
composer: string,
|
||||||
trophyId: number
|
bpm: number,
|
||||||
totalAwake: number
|
ver: number,
|
||||||
playerRating: number
|
note: {
|
||||||
partnerId: number
|
lv: number
|
||||||
nameplateId: number
|
designer: string
|
||||||
lastRomVersion: string
|
lv_id: number
|
||||||
lastPlayDate: string
|
notes: number
|
||||||
lastLoginDate: string
|
}
|
||||||
lastGameId: string
|
|
||||||
lastDataVersion: string
|
|
||||||
isNetMember: boolean
|
|
||||||
isLogin: boolean
|
|
||||||
iconId: number
|
|
||||||
frameId: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MaimaiUserSummaryEntry {
|
export interface MaimaiUserSummaryEntry {
|
||||||
@@ -59,5 +42,74 @@ export interface MaimaiUserSummaryEntry {
|
|||||||
lastVersion: string
|
lastVersion: string
|
||||||
best35: string
|
best35: string
|
||||||
best15: string
|
best15: string
|
||||||
recent: Rating[]
|
recent: MaimaiUserPlaylog[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MaimaiUserPlaylog {
|
||||||
|
id: number;
|
||||||
|
musicId: number;
|
||||||
|
level: number;
|
||||||
|
trackNo: number;
|
||||||
|
vsRank: number;
|
||||||
|
achievement: number;
|
||||||
|
deluxscore: number;
|
||||||
|
scoreRank: number;
|
||||||
|
maxCombo: number;
|
||||||
|
totalCombo: number;
|
||||||
|
maxSync: number;
|
||||||
|
totalSync: number;
|
||||||
|
tapCriticalPerfect: number;
|
||||||
|
tapPerfect: number;
|
||||||
|
tapGreat: number;
|
||||||
|
tapGood: number;
|
||||||
|
tapMiss: number;
|
||||||
|
holdCriticalPerfect: number;
|
||||||
|
holdPerfect: number;
|
||||||
|
holdGreat: number;
|
||||||
|
holdGood: number;
|
||||||
|
holdMiss: number;
|
||||||
|
slideCriticalPerfect: number;
|
||||||
|
slidePerfect: number;
|
||||||
|
slideGreat: number;
|
||||||
|
slideGood: number;
|
||||||
|
slideMiss: number;
|
||||||
|
touchCriticalPerfect: number;
|
||||||
|
touchPerfect: number;
|
||||||
|
touchGreat: number;
|
||||||
|
touchGood: number;
|
||||||
|
touchMiss: number;
|
||||||
|
breakCriticalPerfect: number;
|
||||||
|
breakPerfect: number;
|
||||||
|
breakGreat: number;
|
||||||
|
breakGood: number;
|
||||||
|
breakMiss: number;
|
||||||
|
isTap: boolean;
|
||||||
|
isHold: boolean;
|
||||||
|
isSlide: boolean;
|
||||||
|
isTouch: boolean;
|
||||||
|
isBreak: boolean;
|
||||||
|
isCriticalDisp: boolean;
|
||||||
|
isFastLateDisp: boolean;
|
||||||
|
fastCount: number;
|
||||||
|
lateCount: number;
|
||||||
|
isAchieveNewRecord: boolean;
|
||||||
|
isDeluxscoreNewRecord: boolean;
|
||||||
|
comboStatus: number;
|
||||||
|
syncStatus: number;
|
||||||
|
isClear: boolean;
|
||||||
|
beforeRating: number;
|
||||||
|
afterRating: number;
|
||||||
|
beforeGrade: number;
|
||||||
|
afterGrade: number;
|
||||||
|
afterGradeRank: number;
|
||||||
|
beforeDeluxRating: number;
|
||||||
|
afterDeluxRating: number;
|
||||||
|
isPlayTutorial: boolean;
|
||||||
|
isEventMode: boolean;
|
||||||
|
isFreedomMode: boolean;
|
||||||
|
playMode: number;
|
||||||
|
isNewFree: boolean;
|
||||||
|
trialPlayAchievement: number;
|
||||||
|
extNum1: number;
|
||||||
|
extNum2: number;
|
||||||
}
|
}
|
||||||
@@ -1,31 +1,30 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {data_host} from "../libs/config";
|
import {data_host} from "../libs/config";
|
||||||
import {getMaimai, getMult} from "../libs/maimai";
|
import {getMaimaiAllMusic, getMaimai, getMult} from "../libs/maimai";
|
||||||
import type {ParsedRating, Rating} from "../libs/maimaiTypes";
|
import type {ParsedRating, Rating} from "../libs/maimaiTypes";
|
||||||
|
|
||||||
export let userId: any
|
export let userId: any
|
||||||
userId = +userId
|
userId = +userId
|
||||||
|
|
||||||
if (!userId) console.error("No user ID provided")
|
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 => {
|
Promise.all([
|
||||||
musicInfo = it
|
getMaimai("GetUserRatingApi", {userId}),
|
||||||
parseRatings()
|
getMaimaiAllMusic().then(it => it.json())
|
||||||
})
|
]).then(([rating, music]) => {
|
||||||
}
|
data = rating
|
||||||
|
musicInfo = music
|
||||||
|
|
||||||
|
if (!data || !musicInfo) {
|
||||||
|
console.error("Failed to fetch data")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
function parseRatings() {
|
|
||||||
if (!data || !musicInfo) return
|
|
||||||
parsedRatings = {
|
parsedRatings = {
|
||||||
old: parseRating(data.userRating.ratingList),
|
old: parseRating(data.userRating.ratingList),
|
||||||
new: parseRating(data.userRating.newRatingList)
|
new: parseRating(data.userRating.newRatingList)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
function parseRating(arr: Rating[]) {
|
function parseRating(arr: Rating[]) {
|
||||||
return arr.map(x => {
|
return arr.map(x => {
|
||||||
|
|||||||
Reference in New Issue
Block a user