Fix: Validate songId as number and add user notification for leaderboard submission

This commit is contained in:
2026-01-17 19:29:36 +08:00
parent 9bd2b21d44
commit 0706f99427
2 changed files with 78 additions and 5 deletions

View File

@@ -77,9 +77,16 @@ class Leaderboard {
}
async fetchLeaderboard() {
// Validate songId is a valid number
if (!this.songId || isNaN(parseInt(this.songId))) {
console.error("Invalid song ID for leaderboard:", this.songId)
this.leaderboardData = []
return
}
try {
var response = await loader.ajax(
`${gameConfig.basedir || "/"}api/leaderboard/get?song_id=${this.songId}&difficulty=${this.difficulty}`
`${gameConfig.basedir || "/"}api/leaderboard/get?song_id=${parseInt(this.songId)}&difficulty=${this.difficulty}`
)
var data = JSON.parse(response)
if (data.status === "ok") {
@@ -94,6 +101,7 @@ class Leaderboard {
}
}
changeDifficulty(direction) {
var difficulties = ["easy", "normal", "hard", "oni", "ura"]
var currentIndex = difficulties.indexOf(this.difficulty)