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

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
+3 -2
View File
@@ -748,7 +748,8 @@ export class D1Storage implements IStorage {
async listMusicV2History(userName: string): Promise<MusicV2HistoryRecord[]> {
try {
const results = await this.db
.prepare('SELECT * FROM music_v2_history WHERE username = ? ORDER BY last_played_at DESC')
// 按队列顺序返回;当前播放项由最大 last_played_at 决定
.prepare('SELECT * FROM music_v2_history WHERE username = ? ORDER BY created_at ASC, last_played_at ASC')
.bind(userName)
.all();
@@ -785,7 +786,7 @@ export class D1Storage implements IStorage {
username, song_id, source, songmid, name, artist, album, cover, duration_text, duration_sec,
play_progress_sec, last_played_at, play_count, last_quality, created_at, updated_at
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(username, song_id) DO UPDATE SET
source = excluded.source,
songmid = excluded.songmid,