Skip to content

Commit d3dd84d

Browse files
committed
fix: 优化在线歌词选择逻辑
1 parent ab3c56c commit d3dd84d

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

‎src/services/lyric/loader.spec.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,30 @@ describe("lyric loader", () => {
483483
expect(media.activeLyric?.platform).toBe("netease");
484484
expect(media.parsedLyric[0].words[0].word).toContain("网易云普通LRC歌词");
485485
});
486+
487+
it("跟随自身:当前展示他站高优先级时,切换为跟随自身必须替换为自身平台歌词", async () => {
488+
const settings = useSettingsStore();
489+
const media = useMediaStore();
490+
const track = createTrack("song_self_switch");
491+
media.track = track;
492+
493+
mockResolveOnlineByPreference.mockResolvedValue({
494+
source: { source: "online", format: "qrc", platform: "qqmusic" },
495+
input: { content: "[1000,1000]他站优质QRC(1000,1000)" },
496+
});
497+
await loadForTrack(null);
498+
expect(media.activeLyric?.format).toBe("qrc");
499+
500+
mockResolveOnlineByPreference.mockResolvedValue({
501+
source: { source: "online", format: "lrc", platform: "netease" },
502+
input: { content: "[00:01.00]自身平台普通LRC歌词" },
503+
});
504+
settings.lyric.lyricSourcePreference = "self";
505+
506+
await vi.waitFor(() => {
507+
expect(media.activeLyric?.format).toBe("lrc");
508+
});
509+
expect(media.activeLyric?.platform).toBe("netease");
510+
expect(media.parsedLyric[0].words[0].word).toContain("自身平台普通LRC歌词");
511+
});
486512
});

‎src/services/lyric/loader.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ const applyOnline = (
197197
}
198198
// 尝试提交在线歌词
199199
const preference = useSettingsStore().lyric.lyricSourcePreference;
200-
const isExplicit = preference !== "auto" && preference !== "self";
201-
// 非显式指定模式(智能选择)下,若当前已展示更优歌词(如候选抢占或插件优选),不降级覆盖
200+
// 仅自动模式是智能选择,其余(含跟随自身)均为用户显式指令,来源权威高于格式优劣
201+
const isExplicit = preference !== "auto";
202+
// 自动模式下,若当前已展示更优歌词(如候选抢占或插件优选),不降级覆盖
202203
if (!isExplicit && current && !isBetterFormat(online.source.format, current.format)) {
203204
return;
204205
}

0 commit comments

Comments
 (0)