mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 15:36:49 +08:00
fix: 避免音乐专辑副标题重复标题
This commit is contained in:
@@ -80,6 +80,7 @@ async function searchMedias() {
|
|||||||
item.bangumi_id?.toString() ||
|
item.bangumi_id?.toString() ||
|
||||||
item.anilist_id?.toString()
|
item.anilist_id?.toString()
|
||||||
if (!mediaId) continue
|
if (!mediaId) continue
|
||||||
|
const musicAlbum = item.music_type === 'album' || item.album === item.title ? undefined : item.album
|
||||||
items.value.push({
|
items.value.push({
|
||||||
id: mediaId,
|
id: mediaId,
|
||||||
poster: getW500Image(item.cover_url || item.poster_path),
|
poster: getW500Image(item.cover_url || item.poster_path),
|
||||||
@@ -87,7 +88,7 @@ async function searchMedias() {
|
|||||||
title: item.year ? `${item.title}(${item.year})` : item.title || '',
|
title: item.year ? `${item.title}(${item.year})` : item.title || '',
|
||||||
overview:
|
overview:
|
||||||
item.type === '音乐'
|
item.type === '音乐'
|
||||||
? `<span class="text-primary">${item.type}</span> ${[item.artist, item.album].filter(Boolean).join(' · ')}`
|
? `<span class="text-primary">${item.type}</span> ${[item.artist, musicAlbum].filter(Boolean).join(' · ')}`
|
||||||
: `<span class="text-primary">${item.type}</span> ${item.overview || ''}`,
|
: `<span class="text-primary">${item.type}</span> ${item.overview || ''}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,4 +56,47 @@ describe('MediaIdSelector layout', () => {
|
|||||||
const results = container.querySelector('.media-id-selector__results')
|
const results = container.querySelector('.media-id-selector__results')
|
||||||
expect(results).toBeInstanceOf(HTMLElement)
|
expect(results).toBeInstanceOf(HTMLElement)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('omits the repeated album title for albums while keeping it for recordings', async () => {
|
||||||
|
mocks.apiGet.mockResolvedValue([
|
||||||
|
{
|
||||||
|
album: '叶惠美',
|
||||||
|
artist: '周杰伦',
|
||||||
|
media_id: 'album-1',
|
||||||
|
music_type: 'album',
|
||||||
|
title: '叶惠美',
|
||||||
|
type: '音乐',
|
||||||
|
year: 2003,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
album: '叶惠美',
|
||||||
|
artist: '周杰伦',
|
||||||
|
media_id: 'recording-1',
|
||||||
|
music_type: 'recording',
|
||||||
|
title: '以父之名',
|
||||||
|
type: '音乐',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const { container } = await renderWithProviders(MediaIdSelector, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
VDialogCloseBtn: {
|
||||||
|
props: ['innerClass'],
|
||||||
|
template: '<button type="button" :class="innerClass"><slot /></button>',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const input = screen.getByPlaceholderText('输入媒体名称')
|
||||||
|
await fireEvent.update(input, '周杰伦')
|
||||||
|
await fireEvent.keyDown(input, { key: 'Enter' })
|
||||||
|
expect(await screen.findByText('叶惠美(2003)')).toBeInTheDocument()
|
||||||
|
|
||||||
|
const subtitles = Array.from(container.querySelectorAll('.v-list-item-subtitle')).map(item =>
|
||||||
|
item.textContent?.trim(),
|
||||||
|
)
|
||||||
|
expect(subtitles).toEqual(['音乐 周杰伦', '音乐 周杰伦 · 叶惠美'])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user