From d5b1b3fd5fd82b1e2be6e6cf2f438c90ef1e0106 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Thu, 2 Jul 2026 12:42:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=A8=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B=E7=A7=BB=E5=8A=A8=E6=AD=8C?= =?UTF-8?q?=E6=9B=B2=E6=97=B6=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E9=A1=BA=E5=BA=8F=E4=B8=8D=E5=AF=B9=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=88#2842=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 2 +- src/main/worker/dbService/modules/list/index.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 86e4252d..c9331ea6 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -10,4 +10,4 @@ - 修复某些情况下开放 API 获取到的音量为 0 的问题 (#2790) - 修复 mg 图片、歌词获取 - 修复某些 tx 歌单打开失败的问题 (#1060, @ght-000) -- 修复在某些情况下添加歌曲时可能导致保存的歌曲顺序不对的问题(#2842) +- 修复在某些情况下添加、移动歌曲时可能导致保存的歌曲顺序不对的问题(#2842) diff --git a/src/main/worker/dbService/modules/list/index.ts b/src/main/worker/dbService/modules/list/index.ts index 8f283d8f..79214d38 100644 --- a/src/main/worker/dbService/modules/list/index.ts +++ b/src/main/worker/dbService/modules/list/index.ts @@ -275,10 +275,14 @@ export const musicsMove = (fromId: string, toId: string, musicInfos: LX.Music.Mu arrUnshift(toList, musicInfos) break case 'bottom': - default: - moveMusicInfo(fromId, ids, toDBMusicInfo(musicInfos, toId, toList.length)) + default:{ + // 如果是添加到最后,那么取最后一个歌曲的原始位置 + 1 作为新歌曲的原始位置,否则新歌曲的原始位置为 position + // 因为原始 pos 可能比 targetList.length 大,所以不能直接用 targetList.length 作为新歌曲的原始位置 + const order = toList.length ? (getMusicInfoOrder(toId, toList.at(-1)!.id)?.order ?? toList.length) + 1 : 0 + moveMusicInfo(fromId, ids, toDBMusicInfo(musicInfos, toId, order)) arrPush(toList, musicInfos) break + } } listSet = new Set(ids)