mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-07-13 16:32:04 +08:00
fix: sync media type when selecting media
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
ManualTransferPayload,
|
||||
ManualTransferPreviewData,
|
||||
ManualTransferPreviewItem,
|
||||
MediaInfo,
|
||||
StorageConf,
|
||||
TransferDirectoryConf,
|
||||
TransferForm,
|
||||
@@ -123,6 +124,20 @@ interface TargetDirectoryOption {
|
||||
|
||||
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) {
|
||||
return [item?.storage ?? '', item?.type ?? '', item?.path ?? ''].join('|')
|
||||
@@ -298,6 +313,14 @@ const transferForm = reactive<TransferForm>({
|
||||
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[]>([])
|
||||
|
||||
@@ -1727,12 +1750,14 @@ onUnmounted(() => {
|
||||
v-if="mediaSource === 'themoviedb'"
|
||||
v-model="transferForm.tmdbid"
|
||||
@close="mediaSelectorDialog = false"
|
||||
@select="handleMediaSelected"
|
||||
:type="mediaSource"
|
||||
/>
|
||||
<MediaIdSelector
|
||||
v-else
|
||||
v-model="transferForm.doubanid"
|
||||
@close="mediaSelectorDialog = false"
|
||||
@select="handleMediaSelected"
|
||||
:type="mediaSource"
|
||||
/>
|
||||
</VDialog>
|
||||
|
||||
@@ -8,15 +8,22 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
interface TmdbItem {
|
||||
// 媒体标题
|
||||
title: string
|
||||
// 媒体简介,包含类型标签
|
||||
overview: string
|
||||
// TMDB ID
|
||||
tmdbid: number
|
||||
// 豆瓣 ID
|
||||
doubanid: string
|
||||
// 海报地址
|
||||
poster: string
|
||||
// 媒体类型
|
||||
type?: string
|
||||
}
|
||||
|
||||
// update:modelValue 事件
|
||||
const emit = defineEmits(['update:modelValue', 'close'])
|
||||
const emit = defineEmits(['update:modelValue', 'select', 'close'])
|
||||
|
||||
const items = ref<TmdbItem[]>([])
|
||||
|
||||
@@ -29,9 +36,10 @@ const loading = ref(false)
|
||||
// ref
|
||||
const inputKeyword = ref<HTMLElement | null>(null)
|
||||
|
||||
// 选中条目
|
||||
// 选中条目并通知父组件同步额外媒体信息。
|
||||
function selectMedia(item: TmdbItem) {
|
||||
emit('update:modelValue', item.tmdbid || item.doubanid)
|
||||
emit('select', item)
|
||||
emit('close')
|
||||
}
|
||||
|
||||
@@ -66,6 +74,7 @@ async function searchMedias() {
|
||||
tmdbid: item.tmdb_id || 0,
|
||||
doubanid: item.douban_id || '',
|
||||
poster: getW500Image(item.poster_path),
|
||||
type: item.type,
|
||||
title: `${item.title}(${item.year})`,
|
||||
overview: `<span class="text-primary">${item.type}</span> ${item.overview}`,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user