mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-08-25 01:59:35 +08:00
fix: sync media type when selecting media
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
ManualTransferPayload,
|
ManualTransferPayload,
|
||||||
ManualTransferPreviewData,
|
ManualTransferPreviewData,
|
||||||
ManualTransferPreviewItem,
|
ManualTransferPreviewItem,
|
||||||
|
MediaInfo,
|
||||||
StorageConf,
|
StorageConf,
|
||||||
TransferDirectoryConf,
|
TransferDirectoryConf,
|
||||||
TransferForm,
|
TransferForm,
|
||||||
@@ -123,6 +124,20 @@ interface TargetDirectoryOption {
|
|||||||
|
|
||||||
const AUTO_TARGET_PATH_VALUE = '__moviepilot_auto_target_path__'
|
const AUTO_TARGET_PATH_VALUE = '__moviepilot_auto_target_path__'
|
||||||
|
|
||||||
|
// 媒体类型映射到手动整理接口接受的类型名。
|
||||||
|
function resolveTransferMediaType(type?: string) {
|
||||||
|
const normalizedType = type?.trim().toLowerCase()
|
||||||
|
if (!normalizedType) return undefined
|
||||||
|
|
||||||
|
const movieTypes = ['电影', 'movie']
|
||||||
|
if (movieTypes.includes(normalizedType)) return '电影'
|
||||||
|
|
||||||
|
const tvTypes = ['电视剧', 'tv', 'series']
|
||||||
|
if (tvTypes.includes(normalizedType)) return '电视剧'
|
||||||
|
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
// 生成文件项稳定键,用于去重和状态同步。
|
// 生成文件项稳定键,用于去重和状态同步。
|
||||||
function getFileItemKey(item?: FileItem) {
|
function getFileItemKey(item?: FileItem) {
|
||||||
return [item?.storage ?? '', item?.type ?? '', item?.path ?? ''].join('|')
|
return [item?.storage ?? '', item?.type ?? '', item?.path ?? ''].join('|')
|
||||||
@@ -298,6 +313,14 @@ const transferForm = reactive<TransferForm>({
|
|||||||
episode_group: null,
|
episode_group: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 处理媒体搜索结果选择,同步搜索结果中已识别的媒体类型。
|
||||||
|
function handleMediaSelected(item: Pick<MediaInfo, 'type'>) {
|
||||||
|
const typeName = resolveTransferMediaType(item.type)
|
||||||
|
if (!typeName) return
|
||||||
|
|
||||||
|
transferForm.type_name = typeName
|
||||||
|
}
|
||||||
|
|
||||||
// 所有媒体库目录
|
// 所有媒体库目录
|
||||||
const directories = ref<TransferDirectoryConf[]>([])
|
const directories = ref<TransferDirectoryConf[]>([])
|
||||||
|
|
||||||
@@ -1727,12 +1750,14 @@ onUnmounted(() => {
|
|||||||
v-if="mediaSource === 'themoviedb'"
|
v-if="mediaSource === 'themoviedb'"
|
||||||
v-model="transferForm.tmdbid"
|
v-model="transferForm.tmdbid"
|
||||||
@close="mediaSelectorDialog = false"
|
@close="mediaSelectorDialog = false"
|
||||||
|
@select="handleMediaSelected"
|
||||||
:type="mediaSource"
|
:type="mediaSource"
|
||||||
/>
|
/>
|
||||||
<MediaIdSelector
|
<MediaIdSelector
|
||||||
v-else
|
v-else
|
||||||
v-model="transferForm.doubanid"
|
v-model="transferForm.doubanid"
|
||||||
@close="mediaSelectorDialog = false"
|
@close="mediaSelectorDialog = false"
|
||||||
|
@select="handleMediaSelected"
|
||||||
:type="mediaSource"
|
:type="mediaSource"
|
||||||
/>
|
/>
|
||||||
</VDialog>
|
</VDialog>
|
||||||
|
|||||||
@@ -8,15 +8,22 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
interface TmdbItem {
|
interface TmdbItem {
|
||||||
|
// 媒体标题
|
||||||
title: string
|
title: string
|
||||||
|
// 媒体简介,包含类型标签
|
||||||
overview: string
|
overview: string
|
||||||
|
// TMDB ID
|
||||||
tmdbid: number
|
tmdbid: number
|
||||||
|
// 豆瓣 ID
|
||||||
doubanid: string
|
doubanid: string
|
||||||
|
// 海报地址
|
||||||
poster: string
|
poster: string
|
||||||
|
// 媒体类型
|
||||||
|
type?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// update:modelValue 事件
|
// update:modelValue 事件
|
||||||
const emit = defineEmits(['update:modelValue', 'close'])
|
const emit = defineEmits(['update:modelValue', 'select', 'close'])
|
||||||
|
|
||||||
const items = ref<TmdbItem[]>([])
|
const items = ref<TmdbItem[]>([])
|
||||||
|
|
||||||
@@ -29,9 +36,10 @@ const loading = ref(false)
|
|||||||
// ref
|
// ref
|
||||||
const inputKeyword = ref<HTMLElement | null>(null)
|
const inputKeyword = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
// 选中条目
|
// 选中条目并通知父组件同步额外媒体信息。
|
||||||
function selectMedia(item: TmdbItem) {
|
function selectMedia(item: TmdbItem) {
|
||||||
emit('update:modelValue', item.tmdbid || item.doubanid)
|
emit('update:modelValue', item.tmdbid || item.doubanid)
|
||||||
|
emit('select', item)
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +74,7 @@ async function searchMedias() {
|
|||||||
tmdbid: item.tmdb_id || 0,
|
tmdbid: item.tmdb_id || 0,
|
||||||
doubanid: item.douban_id || '',
|
doubanid: item.douban_id || '',
|
||||||
poster: getW500Image(item.poster_path),
|
poster: getW500Image(item.poster_path),
|
||||||
|
type: item.type,
|
||||||
title: `${item.title}(${item.year})`,
|
title: `${item.title}(${item.year})`,
|
||||||
overview: `<span class="text-primary">${item.type}</span> ${item.overview}`,
|
overview: `<span class="text-primary">${item.type}</span> ${item.overview}`,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user