mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-08-28 19:47:49 +08:00
fix(reorganize): 切换类型时数据源自动回退自动并隐藏媒体ID输入框,补充 mediaId 翻译
This commit is contained in:
@@ -489,14 +489,17 @@ watch([() => transferForm.type_name, () => mediaSource.value], ([typeName, sourc
|
||||
episodeGroups.value = []
|
||||
})
|
||||
|
||||
// 音乐默认使用 MusicBrainz;已显式选择其它音乐源时保留用户选择。
|
||||
// 切换媒体类型时,若当前数据源与新类型不兼容则回退到自动,
|
||||
// 避免音乐源在影视整理中残留;音乐类型未显式选择来源时由 mediaSource 兜底为 MusicBrainz。
|
||||
watch(
|
||||
() => transferForm.type_name,
|
||||
typeName => {
|
||||
if (typeName === '音乐' && !isMusicMediaSource(transferForm.media_source ?? undefined)) {
|
||||
transferForm.media_source = 'musicbrainz'
|
||||
const isMusicType = typeName === '音乐'
|
||||
const sourceIsMusic = isMusicMediaSource(transferForm.media_source ?? undefined)
|
||||
if (isMusicType !== sourceIsMusic) {
|
||||
transferForm.media_source = null
|
||||
}
|
||||
transferForm.music_type = typeName === '音乐' ? (transferForm.music_type ?? 'recording') : null
|
||||
transferForm.music_type = isMusicType ? (transferForm.music_type ?? 'recording') : null
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1519,10 +1522,13 @@ onUnmounted(() => {
|
||||
prepend-inner-icon="mdi-music-box-multiple"
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12" :md="transferForm.type_name === '音乐' ? 3 : 4">
|
||||
<VCol
|
||||
v-if="transferForm.type_name !== ''"
|
||||
cols="12"
|
||||
:md="transferForm.type_name === '音乐' ? 3 : 4"
|
||||
>
|
||||
<VTextField
|
||||
v-model="transferForm.media_id"
|
||||
:disabled="transferForm.type_name === ''"
|
||||
:label="mediaIdLabel"
|
||||
:placeholder="t('dialog.reorganize.mediaIdPlaceholder')"
|
||||
:rules="[validateMediaId]"
|
||||
|
||||
@@ -477,6 +477,36 @@ describe('ReorganizeDialog payloads and lifecycle', () => {
|
||||
expect(screen.getByLabelText<HTMLSelectElement>('数据源')).toHaveDisplayValue('自动')
|
||||
})
|
||||
|
||||
it('resets the data source to auto and hides the media id input after switching media type', async () => {
|
||||
await renderDialog()
|
||||
|
||||
// 类型为自动时隐藏媒体ID输入框
|
||||
expect(screen.queryByLabelText('TheMovieDb编号')).not.toBeInTheDocument()
|
||||
|
||||
// 切换到音乐:显示媒体ID输入框,数据源保持自动(音乐由媒体ID标签兜底为 MusicBrainz)
|
||||
await selectOption('类型', 3)
|
||||
await waitFor(() => expect(screen.getByLabelText('MusicBrainz ID')).toBeInTheDocument())
|
||||
expect(screen.getByLabelText<HTMLSelectElement>('数据源')).toHaveDisplayValue('自动')
|
||||
|
||||
// 切回电影:数据源自动回退为自动,媒体ID输入框随类型重新显示
|
||||
await selectOption('类型', 1)
|
||||
await waitFor(() => expect(screen.getByLabelText('TheMovieDb编号')).toBeInTheDocument())
|
||||
expect(screen.getByLabelText<HTMLSelectElement>('数据源')).toHaveDisplayValue('自动')
|
||||
})
|
||||
|
||||
it('resets a stale music source back to auto when switching away from music type', async () => {
|
||||
await renderDialog()
|
||||
|
||||
// 先手动选择音乐源(触发类型联动为音乐)
|
||||
await selectOption('数据源', 5)
|
||||
await waitFor(() => expect(screen.getByLabelText<HTMLSelectElement>('类型')).toHaveDisplayValue('音乐'))
|
||||
|
||||
// 切回电影后,音乐源不应残留
|
||||
await selectOption('类型', 1)
|
||||
await waitFor(() => expect(screen.getByLabelText<HTMLSelectElement>('数据源')).toHaveDisplayValue('自动'))
|
||||
expect(screen.getByLabelText<HTMLSelectElement>('类型')).toHaveDisplayValue('电影')
|
||||
})
|
||||
|
||||
it('deduplicates selected files and submits nullable automatic target fields in one background request', async () => {
|
||||
const bodies: unknown[] = []
|
||||
const backgrounds: string[] = []
|
||||
@@ -702,6 +732,8 @@ describe('ReorganizeDialog payloads and lifecycle', () => {
|
||||
const user = userEvent.setup()
|
||||
await renderDialog()
|
||||
|
||||
// 类型为自动时媒体ID输入框隐藏,先选择类型再查询媒体编号
|
||||
await selectOption('类型', 2)
|
||||
await user.click(screen.getByRole('button', { name: '查询媒体编号' }))
|
||||
await user.click(screen.getByRole('button', { name: '选择电视剧' }))
|
||||
await waitFor(() => expect(screen.getByRole('option', { name: '播出顺序' })).toBeInTheDocument())
|
||||
|
||||
@@ -3345,6 +3345,7 @@ export default {
|
||||
doubanId: 'Douban ID',
|
||||
bangumiId: 'Bangumi ID',
|
||||
anilistId: 'AniList ID',
|
||||
mediaId: 'Media ID',
|
||||
mediaIdHint: 'Query media ID by name, leave empty for auto recognition',
|
||||
mediaIdPlaceholder: 'Leave empty for auto recognition',
|
||||
mediaIdInvalid: 'Invalid media ID format',
|
||||
|
||||
@@ -3289,6 +3289,7 @@ export default {
|
||||
doubanId: '豆瓣编号',
|
||||
bangumiId: 'Bangumi编号',
|
||||
anilistId: 'AniList编号',
|
||||
mediaId: '媒体 ID',
|
||||
mediaIdHint: '按名称查询媒体编号,留空自动识别',
|
||||
mediaIdPlaceholder: '留空自动识别',
|
||||
mediaIdInvalid: '媒体ID格式无效',
|
||||
|
||||
@@ -3287,6 +3287,7 @@ export default {
|
||||
doubanId: '豆瓣編號',
|
||||
bangumiId: 'Bangumi編號',
|
||||
anilistId: 'AniList編號',
|
||||
mediaId: '媒體 ID',
|
||||
mediaIdHint: '按名稱查詢媒體編號,留空自動識別',
|
||||
mediaIdPlaceholder: '留空自動識別',
|
||||
mediaIdInvalid: '媒體ID格式無效',
|
||||
|
||||
Reference in New Issue
Block a user