fix: 修复 getAllScoreSaberScores 函数中的 allSongs 初始化方式,确保正确创建 SongData 切片

This commit is contained in:
lixiangwuxian 2025-07-12 22:52:49 +08:00
parent bffb3b8975
commit e32f4c13fe

View File

@ -630,7 +630,8 @@ func getRecent10Scores(playerID string) ([]ScoreSaberPlayerScore, error) {
// 获取玩家的所有分数并转换为 SongData // 获取玩家的所有分数并转换为 SongData
func getAllScoreSaberScores(playerID string) ([]SongData, error) { func getAllScoreSaberScores(playerID string) ([]SongData, error) {
var allSongs []SongData // var allSongs []SongData
allSongs := make([]SongData, 40)
cwd, _ := os.Getwd() cwd, _ := os.Getwd()
// 获取Best30 // 获取Best30
@ -669,7 +670,7 @@ func getAllScoreSaberScores(playerID string) ([]SongData, error) {
defer util.ReportPanicToDev() defer util.ReportPanicToDev()
defer wgAll.Done() defer wgAll.Done()
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
for _, score := range recentScores { for i, score := range recentScores {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer util.ReportPanicToDev() defer util.ReportPanicToDev()
@ -680,7 +681,7 @@ func getAllScoreSaberScores(playerID string) ([]SongData, error) {
return return
} }
songData.IsBest30 = false songData.IsBest30 = false
allSongs = append(allSongs, songData) allSongs[i+30] = songData
}() }()
wg.Wait() wg.Wait()
} }