|
|
@@ -96,24 +96,22 @@ const loadRankingData = async (): Promise<void> => {
|
|
|
|
|
|
// 处理排名(相同分数排名相同)
|
|
|
const processedData: UTSJSONObject[] = []
|
|
|
- let currentRank = 1
|
|
|
-
|
|
|
rawData.forEach((item: UTSJSONObject, index: number) => {
|
|
|
- const item = rawData[index]
|
|
|
-
|
|
|
- // 如果当前项分数与前一项不同,则更新排名
|
|
|
+ let rank = index + 1
|
|
|
+
|
|
|
+ // 如果当前项分数与前一项相同,则排名也相同
|
|
|
if (index > 0) {
|
|
|
const prevScore = (rawData[index - 1]['finalScore'] as number | null) ?? 0
|
|
|
const currentScore = (item['finalScore'] as number | null) ?? 0
|
|
|
|
|
|
- if (currentScore !== prevScore) {
|
|
|
- currentRank = currentRank + 1
|
|
|
+ if (currentScore === prevScore) {
|
|
|
+ // 找到前一个处理后的项的排名
|
|
|
+ rank = (processedData[processedData.length - 1]['rank'] as number)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
processedData.push({
|
|
|
...item,
|
|
|
- 'rank': currentRank
|
|
|
+ 'rank': rank
|
|
|
})
|
|
|
})
|
|
|
rankingList.value = processedData
|