修复关系型数据库保存音乐记录错误,播放记录修改为队列式

This commit is contained in:
mtvpls
2026-05-09 10:25:39 +08:00
parent 2480b4d28b
commit a8cacf3e60
6 changed files with 54 additions and 14 deletions
+6 -1
View File
@@ -807,7 +807,12 @@ export abstract class BaseRedisStorage implements IStorage {
return Object.values(rows || {})
.filter(Boolean)
.map(value => JSON.parse(value as string) as MusicV2HistoryRecord)
.sort((a, b) => b.lastPlayedAt - a.lastPlayedAt);
// 按队列顺序返回;当前播放项由最大 lastPlayedAt 决定
.sort((a, b) => {
const createdAtDiff = (a.createdAt || 0) - (b.createdAt || 0);
if (createdAtDiff !== 0) return createdAtDiff;
return (a.lastPlayedAt || 0) - (b.lastPlayedAt || 0);
});
}
async upsertMusicV2History(userName: string, record: MusicV2HistoryRecord): Promise<void> {