feat(music): support album subscription semantics

This commit is contained in:
jxxghp
2026-08-09 20:43:33 +08:00
parent dd6f644f05
commit 98a9f87768
11 changed files with 182 additions and 21 deletions
+11
View File
@@ -81,6 +81,17 @@ describe('music utils', () => {
})
})
it('does not build a resource route for an artist browsing entity', () => {
expect(
buildMusicResourceRoute({
source: 'musicbrainz',
media_id: 'artist-1',
music_type: 'artist',
title: 'Queen',
} as never),
).toBeUndefined()
})
it('keeps the entity type inside the list key so albums and tracks never collide', () => {
const track = getMusicKey({ source: 'musicbrainz', media_id: 'same-id' })
const album = getMusicKey({ source: 'musicbrainz', media_id: 'same-id', music_type: 'album' })
+2
View File
@@ -63,6 +63,8 @@ export function buildMusicResourceRoute(
item: MediaInfo | MusicAlbumInfo,
sites: number[] = [],
): RouteLocationRaw | undefined {
// 艺术家是浏览入口,不是可直接下载的媒体实体。
if ((item as MusicRouteTarget).music_type === 'artist') return undefined
const source = getMusicSource(item as MusicRouteTarget)
if (!source || !item.media_id) return undefined
return {