mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 15:36:49 +08:00
feat: add subtitle search functionality and download feature
- Added subtitle search results support in zh-TW locale. - Enhanced resource page to handle subtitle search results, including new computed properties and methods for managing subtitle data. - Introduced SubtitleCard and SubtitleItem components for displaying subtitle information. - Created AddSubtitleDownloadDialog for managing subtitle downloads with directory selection and media ID options. - Implemented subtitle download caching mechanism to track downloaded subtitles.
This commit is contained in:
@@ -768,6 +768,52 @@ export interface TorrentInfo {
|
|||||||
category: string
|
category: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 字幕信息
|
||||||
|
export interface SubtitleInfo {
|
||||||
|
// 站点ID
|
||||||
|
site?: number
|
||||||
|
// 站点名称
|
||||||
|
site_name?: string
|
||||||
|
// 站点Cookie
|
||||||
|
site_cookie?: string
|
||||||
|
// 站点UA
|
||||||
|
site_ua?: string
|
||||||
|
// 站点是否使用代理
|
||||||
|
site_proxy?: boolean
|
||||||
|
// 站点优先级
|
||||||
|
site_order?: number
|
||||||
|
// 字幕标题
|
||||||
|
title?: string
|
||||||
|
// 字幕描述
|
||||||
|
description?: string
|
||||||
|
// 字幕下载链接
|
||||||
|
enclosure?: string
|
||||||
|
// 详情页面
|
||||||
|
page_url?: string
|
||||||
|
// 语言
|
||||||
|
language?: string
|
||||||
|
// 语言图标
|
||||||
|
language_icon?: string
|
||||||
|
// 字幕大小
|
||||||
|
size?: number
|
||||||
|
// 发布时间
|
||||||
|
pubdate?: string
|
||||||
|
// 已过时间
|
||||||
|
date_elapsed?: string
|
||||||
|
// 点击/下载次数
|
||||||
|
grabs?: number
|
||||||
|
// 上传者
|
||||||
|
uploader?: string
|
||||||
|
// 举报页面
|
||||||
|
report_url?: string
|
||||||
|
// 种子ID
|
||||||
|
torrent_id?: string
|
||||||
|
// 字幕ID
|
||||||
|
subtitle_id?: string
|
||||||
|
// 下载文件名
|
||||||
|
file_name?: string
|
||||||
|
}
|
||||||
|
|
||||||
// 识别元数据
|
// 识别元数据
|
||||||
export interface MetaInfo {
|
export interface MetaInfo {
|
||||||
// 是否处理的文件
|
// 是否处理的文件
|
||||||
|
|||||||
@@ -0,0 +1,210 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { PropType } from 'vue'
|
||||||
|
import { formatDateDifference, formatFileSize } from '@/@core/utils/formatters'
|
||||||
|
import api from '@/api'
|
||||||
|
import type { SubtitleInfo } from '@/api/types'
|
||||||
|
import { getCachedSiteIcon } from '@/utils/siteIconCache'
|
||||||
|
import { downloadedSubtitleMap, markSubtitleDownloaded } from '@/utils/subtitleDownloadCache'
|
||||||
|
import { openSharedDialog } from '@/composables/useSharedDialog'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
|
const AddSubtitleDownloadDialog = defineAsyncComponent(() => import('../dialog/AddSubtitleDownloadDialog.vue'))
|
||||||
|
|
||||||
|
// 多语言支持
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
// 输入参数
|
||||||
|
const props = defineProps({
|
||||||
|
subtitle: Object as PropType<SubtitleInfo>,
|
||||||
|
width: String,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字幕信息
|
||||||
|
const subtitle = ref(props.subtitle)
|
||||||
|
|
||||||
|
// 站点图标
|
||||||
|
const siteIcon = ref('')
|
||||||
|
|
||||||
|
const isDownloaded = computed(() => Boolean(subtitle.value?.enclosure && downloadedSubtitleMap[subtitle.value.enclosure]))
|
||||||
|
|
||||||
|
// 查询站点图标
|
||||||
|
async function getSiteIcon() {
|
||||||
|
if (!subtitle.value?.site) {
|
||||||
|
siteIcon.value = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
siteIcon.value = await getCachedSiteIcon(subtitle.value.site, async () => {
|
||||||
|
try {
|
||||||
|
const response = await api.get(`site/icon/${subtitle.value?.site}`)
|
||||||
|
|
||||||
|
return response?.data?.icon || ''
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load site icon:', error)
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load site icon:', error)
|
||||||
|
siteIcon.value = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加字幕下载成功
|
||||||
|
function addDownloadSuccess(url: string) {
|
||||||
|
markSubtitleDownloaded(url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加字幕下载失败
|
||||||
|
function addDownloadError(error: string) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 询问并下载字幕
|
||||||
|
async function handleAddDownload() {
|
||||||
|
openSharedDialog(
|
||||||
|
AddSubtitleDownloadDialog,
|
||||||
|
{
|
||||||
|
title: subtitle.value?.title,
|
||||||
|
subtitle: subtitle.value,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
done: addDownloadSuccess,
|
||||||
|
error: addDownloadError,
|
||||||
|
},
|
||||||
|
{ closeOn: ['close', 'done', 'error'] },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开字幕详情页面
|
||||||
|
function openSubtitleDetail() {
|
||||||
|
if (!subtitle.value?.page_url) return
|
||||||
|
window.open(subtitle.value.page_url, '_blank')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开字幕举报页面
|
||||||
|
function openReportPage() {
|
||||||
|
if (!subtitle.value?.report_url) return
|
||||||
|
window.open(subtitle.value.report_url, '_blank')
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.subtitle,
|
||||||
|
value => {
|
||||||
|
subtitle.value = value
|
||||||
|
getSiteIcon()
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="h-full">
|
||||||
|
<VCard
|
||||||
|
:width="props.width || '100%'"
|
||||||
|
:variant="isDownloaded ? 'outlined' : 'flat'"
|
||||||
|
@click="handleAddDownload"
|
||||||
|
class="h-full cursor-pointer transition-transform hover:-translate-y-1 duration-300 d-flex flex-column overflow-hidden subtitle-card"
|
||||||
|
:class="{ 'border-success border-2 opacity-85': isDownloaded }"
|
||||||
|
hover
|
||||||
|
>
|
||||||
|
<VCardItem class="pt-3 pb-0">
|
||||||
|
<div class="d-flex justify-space-between align-center flex-wrap gap-2 mb-2">
|
||||||
|
<div class="d-flex align-center min-w-0">
|
||||||
|
<VImg
|
||||||
|
v-if="siteIcon"
|
||||||
|
:src="siteIcon"
|
||||||
|
:alt="subtitle?.site_name"
|
||||||
|
class="mr-2 rounded"
|
||||||
|
width="20"
|
||||||
|
height="20"
|
||||||
|
/>
|
||||||
|
<VAvatar v-else size="20" class="mr-2 text-caption bg-surface-variant" color="surface-variant">
|
||||||
|
{{ subtitle?.site_name?.substring(0, 1) }}
|
||||||
|
</VAvatar>
|
||||||
|
<span class="font-weight-bold text-body-2 text-truncate">{{ subtitle?.site_name }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex align-center gap-2">
|
||||||
|
<VChip v-if="subtitle?.language" size="x-small" color="info" variant="tonal" class="rounded-sm">
|
||||||
|
<VImg
|
||||||
|
v-if="subtitle?.language_icon"
|
||||||
|
:src="subtitle.language_icon"
|
||||||
|
:alt="subtitle.language"
|
||||||
|
width="14"
|
||||||
|
height="14"
|
||||||
|
class="me-1"
|
||||||
|
/>
|
||||||
|
{{ subtitle.language }}
|
||||||
|
</VChip>
|
||||||
|
<VChip v-if="isDownloaded" size="x-small" color="success" variant="tonal" class="rounded-sm">
|
||||||
|
{{ t('dialog.addSubtitleDownload.downloaded') }}
|
||||||
|
</VChip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</VCardItem>
|
||||||
|
|
||||||
|
<VCardText class="d-flex flex-column flex-grow-1 pa-3 overflow-hidden">
|
||||||
|
<div class="text-subtitle-2 text-high-emphasis font-weight-medium mb-2 break-all" :title="subtitle?.title">
|
||||||
|
{{ subtitle?.title }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="subtitle?.description"
|
||||||
|
class="text-body-2 text-medium-emphasis mb-2 break-all"
|
||||||
|
:title="subtitle?.description"
|
||||||
|
>
|
||||||
|
{{ subtitle.description }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex flex-wrap align-center gap-2 mb-2">
|
||||||
|
<span v-if="subtitle?.pubdate || subtitle?.date_elapsed" class="d-flex align-center text-sm text-medium-emphasis">
|
||||||
|
<VIcon size="small" color="grey" icon="mdi-clock-outline" class="me-1"></VIcon>
|
||||||
|
{{ subtitle?.date_elapsed || formatDateDifference(subtitle.pubdate || '') }}
|
||||||
|
</span>
|
||||||
|
<span v-if="subtitle?.grabs !== undefined" class="d-flex align-center text-sm text-medium-emphasis">
|
||||||
|
<VIcon size="small" color="primary" icon="mdi-download-outline" class="me-1"></VIcon>
|
||||||
|
{{ subtitle.grabs }}
|
||||||
|
</span>
|
||||||
|
<span v-if="subtitle?.uploader" class="d-flex align-center text-sm text-medium-emphasis">
|
||||||
|
<VIcon size="small" color="grey" icon="mdi-account-outline" class="me-1"></VIcon>
|
||||||
|
{{ subtitle.uploader }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex flex-wrap gap-1">
|
||||||
|
<VChip v-if="subtitle?.torrent_id" size="x-small" variant="tonal" class="rounded-sm">
|
||||||
|
TID {{ subtitle.torrent_id }}
|
||||||
|
</VChip>
|
||||||
|
<VChip v-if="subtitle?.subtitle_id" size="x-small" variant="tonal" class="rounded-sm">
|
||||||
|
SID {{ subtitle.subtitle_id }}
|
||||||
|
</VChip>
|
||||||
|
</div>
|
||||||
|
</VCardText>
|
||||||
|
|
||||||
|
<VCardActions class="border-t border-opacity-10 mt-auto pa-2">
|
||||||
|
<VChip v-if="subtitle?.size" color="primary" size="x-small" variant="elevated" class="rounded-sm">
|
||||||
|
{{ formatFileSize(subtitle.size) }}
|
||||||
|
</VChip>
|
||||||
|
<VSpacer />
|
||||||
|
<VBtn v-if="subtitle?.report_url" icon size="small" variant="text" color="warning" @click.stop="openReportPage">
|
||||||
|
<VIcon icon="mdi-alert-outline"></VIcon>
|
||||||
|
</VBtn>
|
||||||
|
<VBtn v-if="subtitle?.page_url" icon size="small" variant="text" color="primary" @click.stop="openSubtitleDetail">
|
||||||
|
<VIcon icon="mdi-information-outline"></VIcon>
|
||||||
|
</VBtn>
|
||||||
|
</VCardActions>
|
||||||
|
</VCard>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.subtitle-card {
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle-card:hover {
|
||||||
|
border-color: rgba(var(--v-theme-primary), 0.3);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,213 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { PropType } from 'vue'
|
||||||
|
import { formatDateDifference, formatFileSize } from '@/@core/utils/formatters'
|
||||||
|
import api from '@/api'
|
||||||
|
import type { SubtitleInfo } from '@/api/types'
|
||||||
|
import { getCachedSiteIcon } from '@/utils/siteIconCache'
|
||||||
|
import { downloadedSubtitleMap, markSubtitleDownloaded } from '@/utils/subtitleDownloadCache'
|
||||||
|
import { openSharedDialog } from '@/composables/useSharedDialog'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
|
const AddSubtitleDownloadDialog = defineAsyncComponent(() => import('../dialog/AddSubtitleDownloadDialog.vue'))
|
||||||
|
|
||||||
|
// 多语言支持
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
// 输入参数
|
||||||
|
const props = defineProps({
|
||||||
|
subtitle: Object as PropType<SubtitleInfo>,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 字幕信息
|
||||||
|
const subtitle = ref(props.subtitle)
|
||||||
|
|
||||||
|
// 站点图标
|
||||||
|
const siteIcon = ref('')
|
||||||
|
|
||||||
|
const isDownloaded = computed(() => Boolean(subtitle.value?.enclosure && downloadedSubtitleMap[subtitle.value.enclosure]))
|
||||||
|
|
||||||
|
// 查询站点图标
|
||||||
|
async function getSiteIcon() {
|
||||||
|
if (!subtitle.value?.site) {
|
||||||
|
siteIcon.value = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
siteIcon.value = await getCachedSiteIcon(subtitle.value.site, async () => {
|
||||||
|
try {
|
||||||
|
const response = await api.get(`site/icon/${subtitle.value?.site}`)
|
||||||
|
|
||||||
|
return response?.data?.icon || ''
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load site icon:', error)
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load site icon:', error)
|
||||||
|
siteIcon.value = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 询问并下载字幕
|
||||||
|
async function handleAddDownload() {
|
||||||
|
openSharedDialog(
|
||||||
|
AddSubtitleDownloadDialog,
|
||||||
|
{
|
||||||
|
title: subtitle.value?.title,
|
||||||
|
subtitle: subtitle.value,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
done: addDownloadSuccess,
|
||||||
|
error: addDownloadError,
|
||||||
|
},
|
||||||
|
{ closeOn: ['close', 'done', 'error'] },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加字幕下载成功
|
||||||
|
function addDownloadSuccess(url: string) {
|
||||||
|
markSubtitleDownloaded(url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加字幕下载失败
|
||||||
|
function addDownloadError(error: string) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开字幕详情页面
|
||||||
|
function openSubtitleDetail() {
|
||||||
|
if (!subtitle.value?.page_url) return
|
||||||
|
window.open(subtitle.value.page_url, '_blank')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开字幕举报页面
|
||||||
|
function openReportPage() {
|
||||||
|
if (!subtitle.value?.report_url) return
|
||||||
|
window.open(subtitle.value.report_url, '_blank')
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.subtitle,
|
||||||
|
value => {
|
||||||
|
subtitle.value = value
|
||||||
|
getSiteIcon()
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="w-100">
|
||||||
|
<VListItem
|
||||||
|
:value="subtitle?.enclosure"
|
||||||
|
class="pa-3 mb-2 rounded subtitle-item transition-all duration-300 hover:-translate-y-1 overflow-hidden"
|
||||||
|
:class="{ 'border-start border-success border-3 opacity-85': isDownloaded }"
|
||||||
|
@click="handleAddDownload"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
<div class="d-flex flex-column align-center pr-3" :title="subtitle?.site_name">
|
||||||
|
<VImg
|
||||||
|
v-if="siteIcon"
|
||||||
|
:src="siteIcon"
|
||||||
|
:alt="subtitle?.site_name"
|
||||||
|
class="rounded mb-1 site-icon"
|
||||||
|
width="32"
|
||||||
|
height="32"
|
||||||
|
/>
|
||||||
|
<VAvatar
|
||||||
|
v-else
|
||||||
|
size="32"
|
||||||
|
class="mb-1 text-caption bg-primary-lighten-4 text-primary font-weight-bold site-icon"
|
||||||
|
>
|
||||||
|
{{ subtitle?.site_name?.substring(0, 1) }}
|
||||||
|
</VAvatar>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<VListItemTitle class="whitespace-normal">
|
||||||
|
<div class="d-flex flex-row flex-wrap align-center gap-2 mb-2">
|
||||||
|
<span class="text-h6 font-weight-bold me-1">{{ subtitle?.site_name }}</span>
|
||||||
|
<VChip v-if="subtitle?.language" size="x-small" color="info" variant="tonal" class="rounded-sm">
|
||||||
|
<VImg
|
||||||
|
v-if="subtitle?.language_icon"
|
||||||
|
:src="subtitle.language_icon"
|
||||||
|
:alt="subtitle.language"
|
||||||
|
width="14"
|
||||||
|
height="14"
|
||||||
|
class="me-1"
|
||||||
|
/>
|
||||||
|
{{ subtitle.language }}
|
||||||
|
</VChip>
|
||||||
|
<VChip v-if="isDownloaded" size="x-small" color="success" variant="tonal" class="rounded-sm">
|
||||||
|
{{ t('dialog.addSubtitleDownload.downloaded') }}
|
||||||
|
</VChip>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-subtitle-2 font-weight-medium mb-2 break-all" :title="subtitle?.title">
|
||||||
|
{{ subtitle?.title }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="subtitle?.description" class="text-body-2 text-medium-emphasis mb-2 break-all" :title="subtitle.description">
|
||||||
|
{{ subtitle.description }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex flex-wrap gap-2 mb-2">
|
||||||
|
<span v-if="subtitle?.pubdate || subtitle?.date_elapsed" class="d-flex align-center text-sm text-medium-emphasis">
|
||||||
|
<VIcon size="small" color="grey" icon="mdi-clock-outline" class="me-1"></VIcon>
|
||||||
|
{{ subtitle?.date_elapsed || formatDateDifference(subtitle.pubdate || '') }}
|
||||||
|
</span>
|
||||||
|
<span v-if="subtitle?.grabs !== undefined" class="d-flex align-center text-sm text-medium-emphasis">
|
||||||
|
<VIcon size="small" color="primary" icon="mdi-download-outline" class="me-1"></VIcon>
|
||||||
|
{{ subtitle.grabs }}
|
||||||
|
</span>
|
||||||
|
<span v-if="subtitle?.uploader" class="d-flex align-center text-sm text-medium-emphasis">
|
||||||
|
<VIcon size="small" color="grey" icon="mdi-account-outline" class="me-1"></VIcon>
|
||||||
|
{{ subtitle.uploader }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</VListItemTitle>
|
||||||
|
|
||||||
|
<template #append>
|
||||||
|
<div class="d-flex flex-column align-end gap-2">
|
||||||
|
<VChip v-if="subtitle?.size" color="primary" size="x-small" variant="elevated" class="rounded-sm">
|
||||||
|
{{ formatFileSize(subtitle.size) }}
|
||||||
|
</VChip>
|
||||||
|
<div class="d-flex align-center">
|
||||||
|
<VBtn
|
||||||
|
v-if="subtitle?.report_url"
|
||||||
|
icon
|
||||||
|
size="small"
|
||||||
|
variant="text"
|
||||||
|
color="warning"
|
||||||
|
@click.stop="openReportPage"
|
||||||
|
>
|
||||||
|
<VIcon icon="mdi-alert-outline"></VIcon>
|
||||||
|
</VBtn>
|
||||||
|
<VBtn
|
||||||
|
v-if="subtitle?.page_url"
|
||||||
|
icon
|
||||||
|
size="small"
|
||||||
|
variant="text"
|
||||||
|
color="primary"
|
||||||
|
@click.stop="openSubtitleDetail"
|
||||||
|
>
|
||||||
|
<VIcon icon="mdi-information-outline"></VIcon>
|
||||||
|
</VBtn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</VListItem>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.subtitle-item {
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle-item:hover {
|
||||||
|
border-color: rgba(var(--v-theme-primary), 0.3);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useToast } from 'vue-toastification'
|
||||||
|
import api from '@/api'
|
||||||
|
import { doneNProgress, startNProgress } from '@/api/nprogress'
|
||||||
|
import type { SubtitleInfo, TransferDirectoryConf } from '@/api/types'
|
||||||
|
import { formatFileSize } from '@/@core/utils/formatters'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import MediaIdSelector from '../misc/MediaIdSelector.vue'
|
||||||
|
import { numberValidator } from '@/@validators'
|
||||||
|
import { useGlobalSettingsStore } from '@/stores'
|
||||||
|
|
||||||
|
// 多语言支持
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
// 从 provide 中获取全局设置
|
||||||
|
const globalSettingsStore = useGlobalSettingsStore()
|
||||||
|
const globalSettings = globalSettingsStore.globalSettings
|
||||||
|
|
||||||
|
// 当前识别类型
|
||||||
|
const mediaSource = ref(globalSettings.RECOGNIZE_SOURCE || 'themoviedb')
|
||||||
|
|
||||||
|
// 输入参数
|
||||||
|
const props = defineProps({
|
||||||
|
title: String,
|
||||||
|
subtitle: Object as PropType<SubtitleInfo>,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 定义成功和失败事件
|
||||||
|
const emit = defineEmits(['done', 'error', 'close'])
|
||||||
|
|
||||||
|
// 提示框
|
||||||
|
const $toast = useToast()
|
||||||
|
|
||||||
|
// 选择的保存目录
|
||||||
|
const selectedDirectory = ref<string | null>(null)
|
||||||
|
|
||||||
|
// 所有目录设置
|
||||||
|
const directories = ref<TransferDirectoryConf[]>([])
|
||||||
|
|
||||||
|
// 是否正在加载
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
// 是否显示高级选项
|
||||||
|
const showAdvancedOptions = ref(false)
|
||||||
|
|
||||||
|
// TMDB ID
|
||||||
|
const tmdbid = ref<number | undefined>(undefined)
|
||||||
|
|
||||||
|
// 豆瓣ID
|
||||||
|
const doubanId = ref<string | undefined>(undefined)
|
||||||
|
|
||||||
|
// TMDB选择对话框
|
||||||
|
const mediaSelectorDialog = ref(false)
|
||||||
|
|
||||||
|
// 计算按钮图标
|
||||||
|
const icon = computed(() => (loading.value ? 'mdi-progress-download' : 'mdi-download'))
|
||||||
|
|
||||||
|
// 计算按钮文字
|
||||||
|
const buttonText = computed(() =>
|
||||||
|
loading.value ? t('dialog.addSubtitleDownload.downloading') : t('dialog.addSubtitleDownload.startDownload'),
|
||||||
|
)
|
||||||
|
|
||||||
|
// 加载目录设置
|
||||||
|
async function loadDirectories() {
|
||||||
|
try {
|
||||||
|
const result: { [key: string]: any } = await api.get('system/setting/Directories')
|
||||||
|
directories.value = result.data?.value ?? []
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertToUri(item: TransferDirectoryConf) {
|
||||||
|
if (!item.download_path) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
if (item.storage === 'local') {
|
||||||
|
return item.download_path
|
||||||
|
}
|
||||||
|
return item.storage + ':' + item.download_path
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取保存目录
|
||||||
|
const targetDirectories = computed(() => {
|
||||||
|
const downloadDirectories = directories.value
|
||||||
|
.map(item => convertToUri(item))
|
||||||
|
.filter((item): item is string => item !== undefined)
|
||||||
|
return [...new Set(downloadDirectories)]
|
||||||
|
})
|
||||||
|
|
||||||
|
// 下载字幕
|
||||||
|
async function addSubtitleDownload() {
|
||||||
|
startNProgress()
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const payload: any = {
|
||||||
|
subtitle_in: props.subtitle,
|
||||||
|
save_path: selectedDirectory.value,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tmdbid.value) {
|
||||||
|
payload.tmdbid = tmdbid.value
|
||||||
|
}
|
||||||
|
if (doubanId.value) {
|
||||||
|
payload.doubanid = doubanId.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: { [key: string]: any } = await api.post('download/subtitle', payload)
|
||||||
|
|
||||||
|
if (result && result.success) {
|
||||||
|
$toast.success(
|
||||||
|
t('dialog.addSubtitleDownload.downloadSuccess', {
|
||||||
|
site: props.subtitle?.site_name,
|
||||||
|
title: props.subtitle?.title,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
emit('done', props.subtitle?.enclosure)
|
||||||
|
} else {
|
||||||
|
$toast.error(
|
||||||
|
t('dialog.addSubtitleDownload.downloadFailed', {
|
||||||
|
site: props.subtitle?.site_name,
|
||||||
|
title: props.subtitle?.title,
|
||||||
|
message: result?.message,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
emit('error', result?.message)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
emit('error', String(error))
|
||||||
|
}
|
||||||
|
loading.value = false
|
||||||
|
doneNProgress()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadDirectories()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<VDialog max-width="35rem" scrollable>
|
||||||
|
<VCard>
|
||||||
|
<VCardItem class="py-2">
|
||||||
|
<template #prepend>
|
||||||
|
<VIcon icon="mdi-subtitles-outline" class="me-2" />
|
||||||
|
</template>
|
||||||
|
<VCardTitle>{{ t('dialog.addSubtitleDownload.confirmDownload') }}</VCardTitle>
|
||||||
|
<VCardSubtitle>{{ subtitle?.site_name }} - {{ title }}</VCardSubtitle>
|
||||||
|
</VCardItem>
|
||||||
|
<VDialogCloseBtn @click="emit('close')" />
|
||||||
|
<VDivider />
|
||||||
|
<VCardText>
|
||||||
|
<VList lines="one">
|
||||||
|
<VListItem>
|
||||||
|
<template #prepend>
|
||||||
|
<VIcon icon="mdi-web"></VIcon>
|
||||||
|
</template>
|
||||||
|
<VListItemTitle>
|
||||||
|
<span class="whitespace-break-spaces me-2">{{ subtitle?.title }}</span>
|
||||||
|
</VListItemTitle>
|
||||||
|
</VListItem>
|
||||||
|
<VListItem v-if="subtitle?.description">
|
||||||
|
<template #prepend>
|
||||||
|
<VIcon icon="mdi-text-box-outline"></VIcon>
|
||||||
|
</template>
|
||||||
|
<VListItemTitle>
|
||||||
|
<span class="text-body-2 whitespace-break-spaces">{{ subtitle?.description }}</span>
|
||||||
|
</VListItemTitle>
|
||||||
|
</VListItem>
|
||||||
|
<VListItem v-if="subtitle?.language || subtitle?.uploader">
|
||||||
|
<template #prepend>
|
||||||
|
<VIcon icon="mdi-translate"></VIcon>
|
||||||
|
</template>
|
||||||
|
<VListItemTitle>
|
||||||
|
<span class="text-body-2">
|
||||||
|
{{ subtitle?.language || t('common.unknown') }}
|
||||||
|
<span v-if="subtitle?.uploader" class="text-medium-emphasis ms-2">{{ subtitle.uploader }}</span>
|
||||||
|
</span>
|
||||||
|
</VListItemTitle>
|
||||||
|
</VListItem>
|
||||||
|
<VListItem v-if="subtitle?.size">
|
||||||
|
<template #prepend>
|
||||||
|
<VIcon icon="mdi-database"></VIcon>
|
||||||
|
</template>
|
||||||
|
<VListItemTitle>
|
||||||
|
<VChip variant="tonal" label>
|
||||||
|
{{ formatFileSize(subtitle?.size || 0) }}
|
||||||
|
</VChip>
|
||||||
|
</VListItemTitle>
|
||||||
|
</VListItem>
|
||||||
|
</VList>
|
||||||
|
<VRow class="px-5">
|
||||||
|
<VCol cols="12">
|
||||||
|
<VCombobox
|
||||||
|
v-model="selectedDirectory"
|
||||||
|
:items="targetDirectories"
|
||||||
|
:label="t('dialog.addSubtitleDownload.saveDirectory')"
|
||||||
|
:placeholder="t('dialog.addSubtitleDownload.autoPlaceholder')"
|
||||||
|
variant="underlined"
|
||||||
|
density="comfortable"
|
||||||
|
prepend-inner-icon="mdi-folder"
|
||||||
|
/>
|
||||||
|
</VCol>
|
||||||
|
</VRow>
|
||||||
|
<VRow class="px-5 mt-2">
|
||||||
|
<VCol cols="12">
|
||||||
|
<VBtn
|
||||||
|
variant="text"
|
||||||
|
:prepend-icon="showAdvancedOptions ? 'mdi-chevron-up' : 'mdi-chevron-down'"
|
||||||
|
@click="showAdvancedOptions = !showAdvancedOptions"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
showAdvancedOptions
|
||||||
|
? t('dialog.addDownload.hideAdvancedOptions')
|
||||||
|
: t('dialog.addDownload.showAdvancedOptions')
|
||||||
|
}}
|
||||||
|
</VBtn>
|
||||||
|
</VCol>
|
||||||
|
</VRow>
|
||||||
|
<VRow v-show="showAdvancedOptions" class="px-5">
|
||||||
|
<VCol cols="12">
|
||||||
|
<VTextField
|
||||||
|
v-if="mediaSource === 'themoviedb'"
|
||||||
|
v-model="tmdbid"
|
||||||
|
:label="t('dialog.reorganize.tmdbId')"
|
||||||
|
:placeholder="t('dialog.reorganize.mediaIdPlaceholder')"
|
||||||
|
:rules="[numberValidator]"
|
||||||
|
append-inner-icon="mdi-magnify"
|
||||||
|
:hint="t('dialog.reorganize.mediaIdHint')"
|
||||||
|
persistent-hint
|
||||||
|
prepend-inner-icon="mdi-identifier"
|
||||||
|
variant="underlined"
|
||||||
|
density="comfortable"
|
||||||
|
@click:append-inner="mediaSelectorDialog = true"
|
||||||
|
/>
|
||||||
|
<VTextField
|
||||||
|
v-else
|
||||||
|
v-model="doubanId"
|
||||||
|
:label="t('dialog.reorganize.doubanId')"
|
||||||
|
:placeholder="t('dialog.reorganize.mediaIdPlaceholder')"
|
||||||
|
:rules="[numberValidator]"
|
||||||
|
append-inner-icon="mdi-magnify"
|
||||||
|
:hint="t('dialog.reorganize.mediaIdHint')"
|
||||||
|
persistent-hint
|
||||||
|
prepend-inner-icon="mdi-identifier"
|
||||||
|
variant="underlined"
|
||||||
|
density="comfortable"
|
||||||
|
@click:append-inner="mediaSelectorDialog = true"
|
||||||
|
/>
|
||||||
|
</VCol>
|
||||||
|
</VRow>
|
||||||
|
</VCardText>
|
||||||
|
<VCardText class="text-center">
|
||||||
|
<VBtn variant="elevated" :disabled="loading" @click="addSubtitleDownload" :prepend-icon="icon" class="px-5">
|
||||||
|
{{ buttonText }}
|
||||||
|
</VBtn>
|
||||||
|
</VCardText>
|
||||||
|
</VCard>
|
||||||
|
<VDialog v-model="mediaSelectorDialog" width="40rem" scrollable max-height="85vh">
|
||||||
|
<MediaIdSelector
|
||||||
|
v-if="mediaSource === 'themoviedb'"
|
||||||
|
v-model="tmdbid"
|
||||||
|
@close="mediaSelectorDialog = false"
|
||||||
|
:type="mediaSource"
|
||||||
|
/>
|
||||||
|
<MediaIdSelector v-else v-model="doubanId" @close="mediaSelectorDialog = false" :type="mediaSource" />
|
||||||
|
</VDialog>
|
||||||
|
</VDialog>
|
||||||
|
</template>
|
||||||
@@ -79,6 +79,7 @@ const SubscribeItems = ref<Subscribe[]>([])
|
|||||||
const chooseSiteDialog = ref(false)
|
const chooseSiteDialog = ref(false)
|
||||||
const selectedSites = ref<number[]>([])
|
const selectedSites = ref<number[]>([])
|
||||||
const allSites = ref<Site[]>([])
|
const allSites = ref<Site[]>([])
|
||||||
|
const siteSearchType = ref<'torrent' | 'subtitle'>('torrent')
|
||||||
|
|
||||||
// 定义事件
|
// 定义事件
|
||||||
const emit = defineEmits(['close', 'update:modelValue'])
|
const emit = defineEmits(['close', 'update:modelValue'])
|
||||||
@@ -247,7 +248,8 @@ async function queryAllSites() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 打开站点选择对话框
|
// 打开站点选择对话框
|
||||||
const openSiteDialog = () => {
|
const openSiteDialog = (type: 'torrent' | 'subtitle' = 'torrent') => {
|
||||||
|
siteSearchType.value = type
|
||||||
chooseSiteDialog.value = true
|
chooseSiteDialog.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,6 +267,10 @@ const matchedSubscribeItems = computed(() => {
|
|||||||
function searchSites(sites: number[]) {
|
function searchSites(sites: number[]) {
|
||||||
chooseSiteDialog.value = false
|
chooseSiteDialog.value = false
|
||||||
selectedSites.value = sites
|
selectedSites.value = sites
|
||||||
|
if (siteSearchType.value === 'subtitle') {
|
||||||
|
searchSubtitle()
|
||||||
|
return
|
||||||
|
}
|
||||||
searchTorrent()
|
searchTorrent()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,6 +285,7 @@ function searchTorrent() {
|
|||||||
query: {
|
query: {
|
||||||
keyword: searchWord.value,
|
keyword: searchWord.value,
|
||||||
area: 'title',
|
area: 'title',
|
||||||
|
result_type: 'torrent',
|
||||||
sites: selectedSites.value.join(','),
|
sites: selectedSites.value.join(','),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -287,6 +294,23 @@ function searchTorrent() {
|
|||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 搜索字幕资源
|
||||||
|
function searchSubtitle() {
|
||||||
|
if (!searchWord.value) return
|
||||||
|
saveRecentSearches(searchWord.value)
|
||||||
|
router.push({
|
||||||
|
path: '/resource',
|
||||||
|
query: {
|
||||||
|
keyword: searchWord.value,
|
||||||
|
area: 'title',
|
||||||
|
result_type: 'subtitle',
|
||||||
|
sites: selectedSites.value.join(','),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
dialog.value = false
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
|
||||||
// 跳转媒体搜索页面
|
// 跳转媒体搜索页面
|
||||||
function searchMedia(searchType: string) {
|
function searchMedia(searchType: string) {
|
||||||
// 搜索类型 media/person
|
// 搜索类型 media/person
|
||||||
@@ -537,6 +561,33 @@ onMounted(() => {
|
|||||||
{{ subscribe.type }}
|
{{ subscribe.type }}
|
||||||
</VListItemSubtitle>
|
</VListItemSubtitle>
|
||||||
</VListItem>
|
</VListItem>
|
||||||
|
|
||||||
|
<VListItem density="comfortable" link @click="searchSubtitle" class="search-result-item mx-2 my-1">
|
||||||
|
<template #prepend>
|
||||||
|
<div class="result-icon-wrapper">
|
||||||
|
<VIcon icon="mdi-subtitles-outline" size="small" color="medium-emphasis" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<VListItemTitle class="font-weight-medium text-body-2">{{
|
||||||
|
t('dialog.searchBar.searchSubtitlesInSites')
|
||||||
|
}}</VListItemTitle>
|
||||||
|
<VListItemSubtitle class="text-caption text-medium-emphasis">
|
||||||
|
{{ t('common.search') }} <span class="primary-text font-weight-medium">{{ searchWord }}</span>
|
||||||
|
{{ t('dialog.searchBar.relatedSubtitles') }}
|
||||||
|
</VListItemSubtitle>
|
||||||
|
<template #append>
|
||||||
|
<VBtn
|
||||||
|
v-if="hasManagePermission"
|
||||||
|
size="x-small"
|
||||||
|
variant="tonal"
|
||||||
|
color="primary"
|
||||||
|
rounded="pill"
|
||||||
|
@click.stop="openSiteDialog('subtitle')"
|
||||||
|
>
|
||||||
|
{{ t('dialog.searchBar.selectSites') }}
|
||||||
|
</VBtn>
|
||||||
|
</template>
|
||||||
|
</VListItem>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 匹配的菜单/功能 -->
|
<!-- 匹配的菜单/功能 -->
|
||||||
@@ -622,7 +673,7 @@ onMounted(() => {
|
|||||||
variant="tonal"
|
variant="tonal"
|
||||||
color="primary"
|
color="primary"
|
||||||
rounded="pill"
|
rounded="pill"
|
||||||
@click.stop="openSiteDialog"
|
@click.stop="openSiteDialog('torrent')"
|
||||||
>
|
>
|
||||||
{{ t('dialog.searchBar.selectSites') }}
|
{{ t('dialog.searchBar.selectSites') }}
|
||||||
</VBtn>
|
</VBtn>
|
||||||
|
|||||||
@@ -1107,6 +1107,7 @@ export default {
|
|||||||
},
|
},
|
||||||
resource: {
|
resource: {
|
||||||
searchResults: 'Resource Search Results',
|
searchResults: 'Resource Search Results',
|
||||||
|
subtitleSearchResults: 'Subtitle Search Results',
|
||||||
keyword: 'Keyword',
|
keyword: 'Keyword',
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
year: 'Year',
|
year: 'Year',
|
||||||
@@ -2318,7 +2319,9 @@ export default {
|
|||||||
subscribeShareSearch: 'Related subscription shares',
|
subscribeShareSearch: 'Related subscription shares',
|
||||||
siteResources: 'Site Resources',
|
siteResources: 'Site Resources',
|
||||||
searchInSites: 'Search for torrent resources in sites',
|
searchInSites: 'Search for torrent resources in sites',
|
||||||
|
searchSubtitlesInSites: 'Search for subtitle resources in sites',
|
||||||
relatedResources: 'Related Resources',
|
relatedResources: 'Related Resources',
|
||||||
|
relatedSubtitles: 'Related Subtitles',
|
||||||
searchTip: 'You can search for movies, TV shows, actors, resources, etc.',
|
searchTip: 'You can search for movies, TV shows, actors, resources, etc.',
|
||||||
emptySearchHint: 'Enter keywords to search',
|
emptySearchHint: 'Enter keywords to search',
|
||||||
escClose: 'Close',
|
escClose: 'Close',
|
||||||
@@ -2350,6 +2353,16 @@ export default {
|
|||||||
showAdvancedOptions: 'Show Advanced Options',
|
showAdvancedOptions: 'Show Advanced Options',
|
||||||
hideAdvancedOptions: 'Hide Advanced Options',
|
hideAdvancedOptions: 'Hide Advanced Options',
|
||||||
},
|
},
|
||||||
|
addSubtitleDownload: {
|
||||||
|
confirmDownload: 'Confirm Subtitle Download',
|
||||||
|
saveDirectory: 'Save Directory (Auto)',
|
||||||
|
autoPlaceholder: 'Leave empty for auto-match',
|
||||||
|
downloading: 'Downloading...',
|
||||||
|
startDownload: 'Download Subtitle',
|
||||||
|
downloaded: 'Downloaded',
|
||||||
|
downloadSuccess: '{site} {title} subtitle downloaded successfully!',
|
||||||
|
downloadFailed: '{site} {title} subtitle download failed: {message}!',
|
||||||
|
},
|
||||||
subscribeShare: {
|
subscribeShare: {
|
||||||
shareSubscription: 'Share Subscription',
|
shareSubscription: 'Share Subscription',
|
||||||
season: 'Season {number}',
|
season: 'Season {number}',
|
||||||
|
|||||||
@@ -1102,6 +1102,7 @@ export default {
|
|||||||
},
|
},
|
||||||
resource: {
|
resource: {
|
||||||
searchResults: '资源搜索结果',
|
searchResults: '资源搜索结果',
|
||||||
|
subtitleSearchResults: '字幕搜索结果',
|
||||||
keyword: '关键词',
|
keyword: '关键词',
|
||||||
title: '标题',
|
title: '标题',
|
||||||
year: '年份',
|
year: '年份',
|
||||||
@@ -2274,7 +2275,9 @@ export default {
|
|||||||
subscribeShareSearch: '相关的订阅分享',
|
subscribeShareSearch: '相关的订阅分享',
|
||||||
siteResources: '站点资源',
|
siteResources: '站点资源',
|
||||||
searchInSites: '在站点中搜索种子资源',
|
searchInSites: '在站点中搜索种子资源',
|
||||||
|
searchSubtitlesInSites: '在站点中搜索字幕资源',
|
||||||
relatedResources: '相关资源',
|
relatedResources: '相关资源',
|
||||||
|
relatedSubtitles: '相关字幕',
|
||||||
searchTip: '可搜索电影、电视剧、演员、资源等',
|
searchTip: '可搜索电影、电视剧、演员、资源等',
|
||||||
emptySearchHint: '输入关键字开始搜索',
|
emptySearchHint: '输入关键字开始搜索',
|
||||||
escClose: '关闭',
|
escClose: '关闭',
|
||||||
@@ -2306,6 +2309,16 @@ export default {
|
|||||||
showAdvancedOptions: '显示高级选项',
|
showAdvancedOptions: '显示高级选项',
|
||||||
hideAdvancedOptions: '隐藏高级选项',
|
hideAdvancedOptions: '隐藏高级选项',
|
||||||
},
|
},
|
||||||
|
addSubtitleDownload: {
|
||||||
|
confirmDownload: '确认下载字幕',
|
||||||
|
saveDirectory: '保存目录(自动)',
|
||||||
|
autoPlaceholder: '留空自动匹配',
|
||||||
|
downloading: '下载中...',
|
||||||
|
startDownload: '下载字幕',
|
||||||
|
downloaded: '已下载',
|
||||||
|
downloadSuccess: '{site} {title} 字幕下载成功!',
|
||||||
|
downloadFailed: '{site} {title} 字幕下载失败:{message}!',
|
||||||
|
},
|
||||||
subscribeShare: {
|
subscribeShare: {
|
||||||
shareSubscription: '分享订阅',
|
shareSubscription: '分享订阅',
|
||||||
season: '第 {number} 季',
|
season: '第 {number} 季',
|
||||||
|
|||||||
@@ -1102,6 +1102,7 @@ export default {
|
|||||||
},
|
},
|
||||||
resource: {
|
resource: {
|
||||||
searchResults: '資源搜索結果',
|
searchResults: '資源搜索結果',
|
||||||
|
subtitleSearchResults: '字幕搜索結果',
|
||||||
keyword: '關鍵詞',
|
keyword: '關鍵詞',
|
||||||
title: '標題',
|
title: '標題',
|
||||||
year: '年份',
|
year: '年份',
|
||||||
@@ -2275,7 +2276,9 @@ export default {
|
|||||||
subscribeShareSearch: '相關的訂閱分享',
|
subscribeShareSearch: '相關的訂閱分享',
|
||||||
siteResources: '站點資源',
|
siteResources: '站點資源',
|
||||||
searchInSites: '在站點中搜索種子資源',
|
searchInSites: '在站點中搜索種子資源',
|
||||||
|
searchSubtitlesInSites: '在站點中搜索字幕資源',
|
||||||
relatedResources: '相關資源',
|
relatedResources: '相關資源',
|
||||||
|
relatedSubtitles: '相關字幕',
|
||||||
searchTip: '可搜索電影、電視劇、演員、資源等',
|
searchTip: '可搜索電影、電視劇、演員、資源等',
|
||||||
emptySearchHint: '輸入關鍵字開始搜索',
|
emptySearchHint: '輸入關鍵字開始搜索',
|
||||||
escClose: '關閉',
|
escClose: '關閉',
|
||||||
@@ -2307,6 +2310,16 @@ export default {
|
|||||||
showAdvancedOptions: '顯示高級選項',
|
showAdvancedOptions: '顯示高級選項',
|
||||||
hideAdvancedOptions: '隱藏高級選項',
|
hideAdvancedOptions: '隱藏高級選項',
|
||||||
},
|
},
|
||||||
|
addSubtitleDownload: {
|
||||||
|
confirmDownload: '確認下載字幕',
|
||||||
|
saveDirectory: '保存目錄(自動)',
|
||||||
|
autoPlaceholder: '留空自動匹配',
|
||||||
|
downloading: '下載中...',
|
||||||
|
startDownload: '下載字幕',
|
||||||
|
downloaded: '已下載',
|
||||||
|
downloadSuccess: '{site} {title} 字幕下載成功!',
|
||||||
|
downloadFailed: '{site} {title} 字幕下載失敗:{message}!',
|
||||||
|
},
|
||||||
subscribeShare: {
|
subscribeShare: {
|
||||||
shareSubscription: '分享訂閱',
|
shareSubscription: '分享訂閱',
|
||||||
season: '第 {number} 季',
|
season: '第 {number} 季',
|
||||||
|
|||||||
+218
-20
@@ -3,9 +3,11 @@ import { debounce } from 'lodash-es'
|
|||||||
import type { LocationQuery } from 'vue-router'
|
import type { LocationQuery } from 'vue-router'
|
||||||
import NoDataFound from '@/components/NoDataFound.vue'
|
import NoDataFound from '@/components/NoDataFound.vue'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import type { Context } from '@/api/types'
|
import type { Context, SubtitleInfo } from '@/api/types'
|
||||||
import TorrentCard from '@/components/cards/TorrentCard.vue'
|
import TorrentCard from '@/components/cards/TorrentCard.vue'
|
||||||
import TorrentItem from '@/components/cards/TorrentItem.vue'
|
import TorrentItem from '@/components/cards/TorrentItem.vue'
|
||||||
|
import SubtitleCard from '@/components/cards/SubtitleCard.vue'
|
||||||
|
import SubtitleItem from '@/components/cards/SubtitleItem.vue'
|
||||||
import ProgressiveCardGrid from '@/components/misc/ProgressiveCardGrid.vue'
|
import ProgressiveCardGrid from '@/components/misc/ProgressiveCardGrid.vue'
|
||||||
import TorrentFilterBar from '@/components/filter/TorrentFilterBar.vue'
|
import TorrentFilterBar from '@/components/filter/TorrentFilterBar.vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
@@ -42,13 +44,14 @@ interface SearchParams {
|
|||||||
year: string
|
year: string
|
||||||
season: string
|
season: string
|
||||||
sites: string
|
sites: string
|
||||||
|
result_type: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LastSearchContextResponse {
|
interface LastSearchContextResponse {
|
||||||
success?: boolean
|
success?: boolean
|
||||||
data?: {
|
data?: {
|
||||||
params?: Partial<SearchParams>
|
params?: Partial<SearchParams>
|
||||||
results?: Context[]
|
results?: Array<Context | SubtitleInfo>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +66,7 @@ function createSearchParams(query: LocationQuery): SearchParams {
|
|||||||
year: query?.year?.toString() ?? '',
|
year: query?.year?.toString() ?? '',
|
||||||
season: query?.season?.toString() ?? '',
|
season: query?.season?.toString() ?? '',
|
||||||
sites: query?.sites?.toString() ?? '',
|
sites: query?.sites?.toString() ?? '',
|
||||||
|
result_type: query?.result_type?.toString() === 'subtitle' ? 'subtitle' : 'torrent',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +79,7 @@ function normalizeSearchParams(params?: Partial<SearchParams> | null): SearchPar
|
|||||||
year: params?.year?.toString() ?? '',
|
year: params?.year?.toString() ?? '',
|
||||||
season: params?.season?.toString() ?? '',
|
season: params?.season?.toString() ?? '',
|
||||||
sites: params?.sites?.toString() ?? '',
|
sites: params?.sites?.toString() ?? '',
|
||||||
|
result_type: params?.result_type?.toString() === 'subtitle' ? 'subtitle' : 'torrent',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +194,12 @@ const season = computed(() => activeSearchParams.value.season)
|
|||||||
// 搜索站点,以,分离多个
|
// 搜索站点,以,分离多个
|
||||||
const sites = computed(() => activeSearchParams.value.sites)
|
const sites = computed(() => activeSearchParams.value.sites)
|
||||||
|
|
||||||
|
// 搜索结果类型
|
||||||
|
const resultType = computed(() => (activeSearchParams.value.result_type === 'subtitle' ? 'subtitle' : 'torrent'))
|
||||||
|
|
||||||
|
// 是否为字幕搜索
|
||||||
|
const isSubtitleSearch = computed(() => resultType.value === 'subtitle')
|
||||||
|
|
||||||
// 视图类型,从localStorage中读取
|
// 视图类型,从localStorage中读取
|
||||||
const viewType = ref<string>(localStorage.getItem('MPTorrentsViewType') ?? 'card')
|
const viewType = ref<string>(localStorage.getItem('MPTorrentsViewType') ?? 'card')
|
||||||
|
|
||||||
@@ -218,6 +229,9 @@ const enableFilterAnimation = ref(true)
|
|||||||
// 原始数据列表(未筛选)
|
// 原始数据列表(未筛选)
|
||||||
const rawDataList = ref<Array<Context>>([])
|
const rawDataList = ref<Array<Context>>([])
|
||||||
|
|
||||||
|
// 原始字幕数据列表
|
||||||
|
const rawSubtitleDataList = ref<Array<SubtitleInfo>>([])
|
||||||
|
|
||||||
// 筛选后的数据列表(用于行视图)
|
// 筛选后的数据列表(用于行视图)
|
||||||
const filteredRowDataList = ref<Array<Context>>([])
|
const filteredRowDataList = ref<Array<Context>>([])
|
||||||
|
|
||||||
@@ -298,15 +312,21 @@ const searchStreamDoneCloseDelay = 1500
|
|||||||
|
|
||||||
const streamTotalCount = ref(0)
|
const streamTotalCount = ref(0)
|
||||||
const streamPreviewDataList = ref<Array<Context>>([])
|
const streamPreviewDataList = ref<Array<Context>>([])
|
||||||
|
const streamPreviewSubtitleDataList = ref<Array<SubtitleInfo>>([])
|
||||||
|
|
||||||
const displayResourceCount = computed(() =>
|
const displayResourceCount = computed(() =>
|
||||||
progressActive.value ? streamTotalCount.value : torrentFilter.totalFilteredCount.value,
|
progressActive.value
|
||||||
|
? streamTotalCount.value
|
||||||
|
: isSubtitleSearch.value
|
||||||
|
? rawSubtitleDataList.value.length
|
||||||
|
: torrentFilter.totalFilteredCount.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
// 搜索中只显示进度区域,避免结果抬头和进度条同时占用顶部空间。
|
// 搜索中只显示进度区域,避免结果抬头和进度条同时占用顶部空间。
|
||||||
const showResultHeader = computed(() => isRefreshed.value && !progressActive.value)
|
const showResultHeader = computed(() => isRefreshed.value && !progressActive.value)
|
||||||
|
|
||||||
let pendingStreamItems: Array<Context> = []
|
let pendingStreamItems: Array<Context> = []
|
||||||
|
let pendingSubtitleStreamItems: Array<SubtitleInfo> = []
|
||||||
let streamFlushTimer: ReturnType<typeof setTimeout> | null = null
|
let streamFlushTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
let streamFinalResultApplied = false
|
let streamFinalResultApplied = false
|
||||||
let pendingProgressText: string | null = null
|
let pendingProgressText: string | null = null
|
||||||
@@ -324,6 +344,8 @@ watch(
|
|||||||
|
|
||||||
// 应用筛选
|
// 应用筛选
|
||||||
function applyFilter() {
|
function applyFilter() {
|
||||||
|
if (isSubtitleSearch.value) return
|
||||||
|
|
||||||
if (viewType.value === 'row') {
|
if (viewType.value === 'row') {
|
||||||
filteredRowDataList.value = torrentFilter.filterRowData(rawDataList.value)
|
filteredRowDataList.value = torrentFilter.filterRowData(rawDataList.value)
|
||||||
} else {
|
} else {
|
||||||
@@ -432,10 +454,12 @@ function clearStreamFlushTimer() {
|
|||||||
function clearStreamPreviewState(resetFinalState: boolean = false) {
|
function clearStreamPreviewState(resetFinalState: boolean = false) {
|
||||||
clearStreamFlushTimer()
|
clearStreamFlushTimer()
|
||||||
pendingStreamItems = []
|
pendingStreamItems = []
|
||||||
|
pendingSubtitleStreamItems = []
|
||||||
pendingProgressText = null
|
pendingProgressText = null
|
||||||
pendingProgressValue = null
|
pendingProgressValue = null
|
||||||
pendingStreamTotalCount = null
|
pendingStreamTotalCount = null
|
||||||
streamPreviewDataList.value = []
|
streamPreviewDataList.value = []
|
||||||
|
streamPreviewSubtitleDataList.value = []
|
||||||
if (resetFinalState) {
|
if (resetFinalState) {
|
||||||
streamFinalResultApplied = false
|
streamFinalResultApplied = false
|
||||||
}
|
}
|
||||||
@@ -459,6 +483,15 @@ function flushBufferedStreamState() {
|
|||||||
pendingProgressValue = null
|
pendingProgressValue = null
|
||||||
pendingStreamTotalCount = null
|
pendingStreamTotalCount = null
|
||||||
|
|
||||||
|
if (pendingSubtitleStreamItems.length) {
|
||||||
|
streamPreviewSubtitleDataList.value = [...pendingSubtitleStreamItems, ...streamPreviewSubtitleDataList.value].slice(
|
||||||
|
0,
|
||||||
|
streamPreviewLimit,
|
||||||
|
)
|
||||||
|
pendingSubtitleStreamItems = []
|
||||||
|
isRefreshed.value = true
|
||||||
|
}
|
||||||
|
|
||||||
if (!pendingStreamItems.length) return
|
if (!pendingStreamItems.length) return
|
||||||
|
|
||||||
streamPreviewDataList.value = [...pendingStreamItems, ...streamPreviewDataList.value].slice(0, streamPreviewLimit)
|
streamPreviewDataList.value = [...pendingStreamItems, ...streamPreviewDataList.value].slice(0, streamPreviewLimit)
|
||||||
@@ -493,9 +526,18 @@ function setSearchParam(params: URLSearchParams, key: string, value: unknown) {
|
|||||||
// 构建搜索流URL
|
// 构建搜索流URL
|
||||||
function buildSearchStreamUrl(params: SearchParams, requestToken?: string) {
|
function buildSearchStreamUrl(params: SearchParams, requestToken?: string) {
|
||||||
const isMediaSearch = /^[a-zA-Z]+:/.test(params.keyword)
|
const isMediaSearch = /^[a-zA-Z]+:/.test(params.keyword)
|
||||||
const url = getApiUrl(isMediaSearch ? `search/media/${encodeURIComponent(params.keyword)}/stream` : 'search/title/stream')
|
const url = getApiUrl(
|
||||||
|
params.result_type === 'subtitle'
|
||||||
|
? 'search/subtitle/title/stream'
|
||||||
|
: isMediaSearch
|
||||||
|
? `search/media/${encodeURIComponent(params.keyword)}/stream`
|
||||||
|
: 'search/title/stream',
|
||||||
|
)
|
||||||
|
|
||||||
if (isMediaSearch) {
|
if (params.result_type === 'subtitle') {
|
||||||
|
setSearchParam(url.searchParams, 'keyword', params.keyword)
|
||||||
|
setSearchParam(url.searchParams, 'sites', params.sites)
|
||||||
|
} else if (isMediaSearch) {
|
||||||
setSearchParam(url.searchParams, 'mtype', params.type)
|
setSearchParam(url.searchParams, 'mtype', params.type)
|
||||||
setSearchParam(url.searchParams, 'area', params.area)
|
setSearchParam(url.searchParams, 'area', params.area)
|
||||||
setSearchParam(url.searchParams, 'title', params.title)
|
setSearchParam(url.searchParams, 'title', params.title)
|
||||||
@@ -518,6 +560,7 @@ function buildSearchStreamUrl(params: SearchParams, requestToken?: string) {
|
|||||||
function resetSearchResults() {
|
function resetSearchResults() {
|
||||||
clearStreamPreviewState(true)
|
clearStreamPreviewState(true)
|
||||||
rawDataList.value = []
|
rawDataList.value = []
|
||||||
|
rawSubtitleDataList.value = []
|
||||||
originalDataList.value = []
|
originalDataList.value = []
|
||||||
streamTotalCount.value = 0
|
streamTotalCount.value = 0
|
||||||
aiRecommended.value = false
|
aiRecommended.value = false
|
||||||
@@ -531,7 +574,8 @@ function resetSearchResults() {
|
|||||||
|
|
||||||
// 判断当前页面是否已经完成过一次带关键词的空结果搜索,避免 keep-alive 返回时自动重搜。
|
// 判断当前页面是否已经完成过一次带关键词的空结果搜索,避免 keep-alive 返回时自动重搜。
|
||||||
function hasLoadedEmptySearchResult() {
|
function hasLoadedEmptySearchResult() {
|
||||||
return isRefreshed.value && !progressActive.value && rawDataList.value.length === 0 && hasSearchKeyword(activeSearchParams.value)
|
const dataLength = isSubtitleSearch.value ? rawSubtitleDataList.value.length : rawDataList.value.length
|
||||||
|
return isRefreshed.value && !progressActive.value && dataLength === 0 && hasSearchKeyword(activeSearchParams.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新搜索进度
|
// 更新搜索进度
|
||||||
@@ -558,6 +602,7 @@ function updateSearchProgress(eventData: { [key: string]: any }, flushNow: boole
|
|||||||
function setStreamResults(items: Context[]) {
|
function setStreamResults(items: Context[]) {
|
||||||
clearStreamPreviewState()
|
clearStreamPreviewState()
|
||||||
rawDataList.value = items
|
rawDataList.value = items
|
||||||
|
rawSubtitleDataList.value = []
|
||||||
originalDataList.value = items
|
originalDataList.value = items
|
||||||
if (!progressActive.value) {
|
if (!progressActive.value) {
|
||||||
streamTotalCount.value = items.length
|
streamTotalCount.value = items.length
|
||||||
@@ -566,6 +611,18 @@ function setStreamResults(items: Context[]) {
|
|||||||
applyFilter()
|
applyFilter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置字幕搜索结果
|
||||||
|
function setSubtitleStreamResults(items: SubtitleInfo[]) {
|
||||||
|
clearStreamPreviewState()
|
||||||
|
rawSubtitleDataList.value = items
|
||||||
|
rawDataList.value = []
|
||||||
|
originalDataList.value = []
|
||||||
|
if (!progressActive.value) {
|
||||||
|
streamTotalCount.value = items.length
|
||||||
|
}
|
||||||
|
isRefreshed.value = true
|
||||||
|
}
|
||||||
|
|
||||||
// 追加流式搜索预览结果
|
// 追加流式搜索预览结果
|
||||||
function appendStreamResults(items: Context[]) {
|
function appendStreamResults(items: Context[]) {
|
||||||
if (!items.length) return
|
if (!items.length) return
|
||||||
@@ -577,12 +634,30 @@ function appendStreamResults(items: Context[]) {
|
|||||||
scheduleStreamFlush()
|
scheduleStreamFlush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 追加流式字幕搜索预览结果
|
||||||
|
function appendSubtitleStreamResults(items: SubtitleInfo[]) {
|
||||||
|
if (!items.length) return
|
||||||
|
|
||||||
|
pendingSubtitleStreamItems.unshift(...items)
|
||||||
|
if (pendingSubtitleStreamItems.length > streamPreviewBufferLimit) {
|
||||||
|
pendingSubtitleStreamItems = pendingSubtitleStreamItems.slice(0, streamPreviewBufferLimit)
|
||||||
|
}
|
||||||
|
scheduleStreamFlush()
|
||||||
|
}
|
||||||
|
|
||||||
function applyFinalStreamResults(items: Context[]) {
|
function applyFinalStreamResults(items: Context[]) {
|
||||||
streamFinalResultApplied = true
|
streamFinalResultApplied = true
|
||||||
flushBufferedStreamState()
|
flushBufferedStreamState()
|
||||||
setStreamResults(items)
|
setStreamResults(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 应用最终字幕搜索结果
|
||||||
|
function applyFinalSubtitleStreamResults(items: SubtitleInfo[]) {
|
||||||
|
streamFinalResultApplied = true
|
||||||
|
flushBufferedStreamState()
|
||||||
|
setSubtitleStreamResults(items)
|
||||||
|
}
|
||||||
|
|
||||||
// 获取磁力链接的key
|
// 获取磁力链接的key
|
||||||
function getTorrentItemKey(item: Context, index: number) {
|
function getTorrentItemKey(item: Context, index: number) {
|
||||||
return (
|
return (
|
||||||
@@ -593,6 +668,16 @@ function getTorrentItemKey(item: Context, index: number) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取字幕结果的key
|
||||||
|
function getSubtitleItemKey(item: SubtitleInfo, index: number) {
|
||||||
|
return (
|
||||||
|
item.enclosure ||
|
||||||
|
item.page_url ||
|
||||||
|
`${item.site_name || ''}-${item.subtitle_id || ''}-${item.title || ''}` ||
|
||||||
|
`subtitle-${index}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// 处理搜索流消息
|
// 处理搜索流消息
|
||||||
function handleSearchStreamMessage(eventData: { [key: string]: any }) {
|
function handleSearchStreamMessage(eventData: { [key: string]: any }) {
|
||||||
if (eventData.type === 'error') {
|
if (eventData.type === 'error') {
|
||||||
@@ -601,6 +686,23 @@ function handleSearchStreamMessage(eventData: { [key: string]: any }) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSubtitleSearch.value) {
|
||||||
|
const subtitleItems = Array.isArray(eventData.items) ? (eventData.items as SubtitleInfo[]) : []
|
||||||
|
if (eventData.type === 'append') {
|
||||||
|
updateSearchProgress(eventData)
|
||||||
|
appendSubtitleStreamResults(subtitleItems)
|
||||||
|
} else if (eventData.type === 'replace') {
|
||||||
|
updateSearchProgress(eventData, true)
|
||||||
|
applyFinalSubtitleStreamResults(subtitleItems)
|
||||||
|
} else if (eventData.type === 'done' && subtitleItems.length > 0 && !streamFinalResultApplied) {
|
||||||
|
updateSearchProgress(eventData, true)
|
||||||
|
applyFinalSubtitleStreamResults(subtitleItems)
|
||||||
|
} else {
|
||||||
|
updateSearchProgress(eventData)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const items = Array.isArray(eventData.items) ? (eventData.items as Context[]) : []
|
const items = Array.isArray(eventData.items) ? (eventData.items as Context[]) : []
|
||||||
if (eventData.type === 'append') {
|
if (eventData.type === 'append') {
|
||||||
updateSearchProgress(eventData)
|
updateSearchProgress(eventData)
|
||||||
@@ -620,14 +722,26 @@ function handleSearchStreamMessage(eventData: { [key: string]: any }) {
|
|||||||
async function searchByRequest(params: SearchParams, requestToken?: string) {
|
async function searchByRequest(params: SearchParams, requestToken?: string) {
|
||||||
const items = await requestSearchResults(params, requestToken)
|
const items = await requestSearchResults(params, requestToken)
|
||||||
streamTotalCount.value = items.length
|
streamTotalCount.value = items.length
|
||||||
setStreamResults(items)
|
if (params.result_type === 'subtitle') {
|
||||||
|
setSubtitleStreamResults(items as SubtitleInfo[])
|
||||||
|
} else {
|
||||||
|
setStreamResults(items as Context[])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 静默刷新使用普通请求,保留当前结果直到新数据完整返回,避免返回页面时露出搜索进度态。
|
// 静默刷新使用普通请求,保留当前结果直到新数据完整返回,避免返回页面时露出搜索进度态。
|
||||||
async function requestSearchResults(params: SearchParams, requestToken?: string) {
|
async function requestSearchResults(params: SearchParams, requestToken?: string) {
|
||||||
let result: { [key: string]: any }
|
let result: { [key: string]: any }
|
||||||
// 如果keyword的格式是 xxxx:xxxxx 且:前面的xxxx为字符,则按照媒体ID格式搜索
|
// 如果keyword的格式是 xxxx:xxxxx 且:前面的xxxx为字符,则按照媒体ID格式搜索
|
||||||
if (/^[a-zA-Z]+:/.test(params.keyword)) {
|
if (params.result_type === 'subtitle') {
|
||||||
|
result = await api.get('search/subtitle/title', {
|
||||||
|
params: {
|
||||||
|
keyword: params.keyword,
|
||||||
|
sites: params.sites,
|
||||||
|
_ts: requestToken,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} else if (/^[a-zA-Z]+:/.test(params.keyword)) {
|
||||||
result = await api.get(`search/media/${params.keyword}`, {
|
result = await api.get(`search/media/${params.keyword}`, {
|
||||||
params: {
|
params: {
|
||||||
mtype: params.type,
|
mtype: params.type,
|
||||||
@@ -651,7 +765,7 @@ async function requestSearchResults(params: SearchParams, requestToken?: string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result && result.success) {
|
if (result && result.success) {
|
||||||
return (result.data || []) as Context[]
|
return (result.data || []) as Array<Context | SubtitleInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
errorDescription.value = result?.message || t('resource.noResourceFound')
|
errorDescription.value = result?.message || t('resource.noResourceFound')
|
||||||
@@ -744,19 +858,28 @@ async function fetchData(options: { force?: boolean; params?: SearchParams; sile
|
|||||||
rememberSearchParams(currentSearchParams)
|
rememberSearchParams(currentSearchParams)
|
||||||
}
|
}
|
||||||
const requestToken = options.force || Boolean(currentSearchParams.keyword) ? createSearchRequestToken() : undefined
|
const requestToken = options.force || Boolean(currentSearchParams.keyword) ? createSearchRequestToken() : undefined
|
||||||
const silentRefresh = Boolean(options.silent && isRefreshed.value && rawDataList.value.length > 0)
|
const hasCurrentResults = isSubtitleSearch.value ? rawSubtitleDataList.value.length > 0 : rawDataList.value.length > 0
|
||||||
|
const silentRefresh = Boolean(options.silent && isRefreshed.value && hasCurrentResults)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
enableFilterAnimation.value = true
|
enableFilterAnimation.value = true
|
||||||
if (!hasSearchKeyword(currentSearchParams)) {
|
if (!hasSearchKeyword(currentSearchParams)) {
|
||||||
// 查询上次搜索结果,并同步可重放的搜索参数
|
// 查询上次搜索结果,并同步可重放的搜索参数
|
||||||
const results = await fetchLastSearchContext()
|
const results = await fetchLastSearchContext()
|
||||||
setStreamResults(results || [])
|
if (activeSearchParams.value.result_type === 'subtitle') {
|
||||||
|
setSubtitleStreamResults((results || []) as SubtitleInfo[])
|
||||||
|
} else {
|
||||||
|
setStreamResults((results || []) as Context[])
|
||||||
|
}
|
||||||
} else if (silentRefresh) {
|
} else if (silentRefresh) {
|
||||||
// keep-alive 重新进入时后台刷新,旧结果继续显示,等新结果完整返回后一次性替换。
|
// keep-alive 重新进入时后台刷新,旧结果继续显示,等新结果完整返回后一次性替换。
|
||||||
const results = await requestSearchResults(currentSearchParams, requestToken)
|
const results = await requestSearchResults(currentSearchParams, requestToken)
|
||||||
streamTotalCount.value = results.length
|
streamTotalCount.value = results.length
|
||||||
setStreamResults(results)
|
if (currentSearchParams.result_type === 'subtitle') {
|
||||||
|
setSubtitleStreamResults(results as SubtitleInfo[])
|
||||||
|
} else {
|
||||||
|
setStreamResults(results as Context[])
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
resetSearchResults()
|
resetSearchResults()
|
||||||
startLoadingProgress()
|
startLoadingProgress()
|
||||||
@@ -1054,6 +1177,13 @@ async function checkAiRecommendStatus() {
|
|||||||
|
|
||||||
// 计算当前显示的数据是否有数据
|
// 计算当前显示的数据是否有数据
|
||||||
const hasData = computed(() => {
|
const hasData = computed(() => {
|
||||||
|
if (isSubtitleSearch.value) {
|
||||||
|
if (progressActive.value) {
|
||||||
|
return streamPreviewSubtitleDataList.value.length > 0 || rawSubtitleDataList.value.length > 0
|
||||||
|
}
|
||||||
|
return rawSubtitleDataList.value.length > 0
|
||||||
|
}
|
||||||
|
|
||||||
if (progressActive.value) {
|
if (progressActive.value) {
|
||||||
return streamPreviewDataList.value.length > 0 || rawDataList.value.length > 0
|
return streamPreviewDataList.value.length > 0 || rawDataList.value.length > 0
|
||||||
}
|
}
|
||||||
@@ -1071,6 +1201,7 @@ watchEffect(() => {
|
|||||||
// 需要满足:AI 功能启用、数据已加载、尚未检查
|
// 需要满足:AI 功能启用、数据已加载、尚未检查
|
||||||
if (
|
if (
|
||||||
aiRecommendEnabled.value &&
|
aiRecommendEnabled.value &&
|
||||||
|
!isSubtitleSearch.value &&
|
||||||
originalDataList.value.length > 0 &&
|
originalDataList.value.length > 0 &&
|
||||||
!progressActive.value &&
|
!progressActive.value &&
|
||||||
!aiStatusChecked.value
|
!aiStatusChecked.value
|
||||||
@@ -1187,7 +1318,7 @@ onUnmounted(() => {
|
|||||||
<div v-if="showResultHeader" class="resource-page-header d-flex justify-space-between align-center mb-4">
|
<div v-if="showResultHeader" class="resource-page-header d-flex justify-space-between align-center mb-4">
|
||||||
<div class="resource-page-header__copy">
|
<div class="resource-page-header__copy">
|
||||||
<VPageContentTitle
|
<VPageContentTitle
|
||||||
:title="t('resource.searchResults')"
|
:title="isSubtitleSearch ? t('resource.subtitleSearchResults') : t('resource.searchResults')"
|
||||||
class="resource-page-header__title my-0"
|
class="resource-page-header__title my-0"
|
||||||
style="margin-block: 0"
|
style="margin-block: 0"
|
||||||
/>
|
/>
|
||||||
@@ -1210,7 +1341,7 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
<!-- AI操作按钮组 -->
|
<!-- AI操作按钮组 -->
|
||||||
<div
|
<div
|
||||||
v-if="aiRecommendEnabled && originalDataList.length > 0"
|
v-if="!isSubtitleSearch && aiRecommendEnabled && originalDataList.length > 0"
|
||||||
class="ai-action-group"
|
class="ai-action-group"
|
||||||
:class="{ 'ai-action-group--active': showingAiResults }"
|
:class="{ 'ai-action-group--active': showingAiResults }"
|
||||||
>
|
>
|
||||||
@@ -1255,7 +1386,7 @@ onUnmounted(() => {
|
|||||||
<div v-if="isRefreshed && hasData" class="search-results-container">
|
<div v-if="isRefreshed && hasData" class="search-results-container">
|
||||||
<!-- 筛选栏 -->
|
<!-- 筛选栏 -->
|
||||||
<TorrentFilterBar
|
<TorrentFilterBar
|
||||||
v-if="!progressActive"
|
v-if="!progressActive && !isSubtitleSearch"
|
||||||
:filter-form="torrentFilter.filterForm"
|
:filter-form="torrentFilter.filterForm"
|
||||||
:filter-options="torrentFilter.filterOptions"
|
:filter-options="torrentFilter.filterOptions"
|
||||||
:sort-field="torrentFilter.sortField.value"
|
:sort-field="torrentFilter.sortField.value"
|
||||||
@@ -1278,7 +1409,29 @@ onUnmounted(() => {
|
|||||||
<!-- 卡片视图模式 -->
|
<!-- 卡片视图模式 -->
|
||||||
<div v-if="viewType === 'card'" key="card">
|
<div v-if="viewType === 'card'" key="card">
|
||||||
<div
|
<div
|
||||||
v-if="progressActive && streamPreviewDataList.length > 0"
|
v-if="isSubtitleSearch && progressActive && streamPreviewSubtitleDataList.length > 0"
|
||||||
|
class="grid gap-4 grid-torrent-card items-start"
|
||||||
|
>
|
||||||
|
<SubtitleCard
|
||||||
|
v-for="(item, index) in streamPreviewSubtitleDataList"
|
||||||
|
:key="getSubtitleItemKey(item, index)"
|
||||||
|
:subtitle="item"
|
||||||
|
class="stream-result-item"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<ProgressiveCardGrid
|
||||||
|
v-else-if="isSubtitleSearch && rawSubtitleDataList.length > 0"
|
||||||
|
:items="rawSubtitleDataList"
|
||||||
|
:get-item-key="getSubtitleItemKey"
|
||||||
|
:min-item-width="300"
|
||||||
|
:estimated-item-height="320"
|
||||||
|
>
|
||||||
|
<template #default="{ item }">
|
||||||
|
<SubtitleCard :subtitle="item" />
|
||||||
|
</template>
|
||||||
|
</ProgressiveCardGrid>
|
||||||
|
<div
|
||||||
|
v-else-if="!isSubtitleSearch && progressActive && streamPreviewDataList.length > 0"
|
||||||
class="grid gap-4 grid-torrent-card items-start"
|
class="grid gap-4 grid-torrent-card items-start"
|
||||||
>
|
>
|
||||||
<TorrentCard
|
<TorrentCard
|
||||||
@@ -1300,7 +1453,14 @@ onUnmounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
</ProgressiveCardGrid>
|
</ProgressiveCardGrid>
|
||||||
<!-- 无结果时显示 -->
|
<!-- 无结果时显示 -->
|
||||||
<div v-if="!progressActive && filteredCardDataList.length === 0" class="no-results">
|
<div
|
||||||
|
v-if="
|
||||||
|
!progressActive &&
|
||||||
|
((isSubtitleSearch && rawSubtitleDataList.length === 0) ||
|
||||||
|
(!isSubtitleSearch && filteredCardDataList.length === 0))
|
||||||
|
"
|
||||||
|
class="no-results"
|
||||||
|
>
|
||||||
<VIcon icon="mdi-file-search-outline" size="64" color="grey-lighten-1" />
|
<VIcon icon="mdi-file-search-outline" size="64" color="grey-lighten-1" />
|
||||||
<div class="text-h6 text-grey mt-4">{{ t('torrent.noResults') }}</div>
|
<div class="text-h6 text-grey mt-4">{{ t('torrent.noResults') }}</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1310,11 +1470,49 @@ onUnmounted(() => {
|
|||||||
<div v-else-if="viewType === 'row'" key="row">
|
<div v-else-if="viewType === 'row'" key="row">
|
||||||
<VCard class="resource-list-container">
|
<VCard class="resource-list-container">
|
||||||
<!-- 无结果时显示 -->
|
<!-- 无结果时显示 -->
|
||||||
<div v-if="!progressActive && filteredRowDataList.length === 0" class="no-results">
|
<div
|
||||||
|
v-if="
|
||||||
|
!progressActive &&
|
||||||
|
((isSubtitleSearch && rawSubtitleDataList.length === 0) ||
|
||||||
|
(!isSubtitleSearch && filteredRowDataList.length === 0))
|
||||||
|
"
|
||||||
|
class="no-results"
|
||||||
|
>
|
||||||
<VIcon icon="mdi-file-search-outline" size="64" color="grey-lighten-1" />
|
<VIcon icon="mdi-file-search-outline" size="64" color="grey-lighten-1" />
|
||||||
<div class="text-h6 text-grey mt-4">{{ t('torrent.noResults') }}</div>
|
<div class="text-h6 text-grey mt-4">{{ t('torrent.noResults') }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="progressActive && streamPreviewDataList.length > 0" class="resource-list overflow-visible">
|
<div
|
||||||
|
v-else-if="isSubtitleSearch && progressActive && streamPreviewSubtitleDataList.length > 0"
|
||||||
|
class="resource-list overflow-visible"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(item, index) in streamPreviewSubtitleDataList"
|
||||||
|
:key="getSubtitleItemKey(item, index)"
|
||||||
|
class="stream-result-item"
|
||||||
|
>
|
||||||
|
<SubtitleItem :subtitle="item" />
|
||||||
|
<VDivider v-if="index < streamPreviewSubtitleDataList.length - 1" class="my-2" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="isSubtitleSearch && rawSubtitleDataList.length > 0" class="resource-list">
|
||||||
|
<ProgressiveCardGrid
|
||||||
|
:items="rawSubtitleDataList"
|
||||||
|
:columns="1"
|
||||||
|
:gap="8"
|
||||||
|
:estimated-item-height="190"
|
||||||
|
:overscan-rows="6"
|
||||||
|
:get-item-key="getSubtitleItemKey"
|
||||||
|
>
|
||||||
|
<template #default="{ item, index }">
|
||||||
|
<SubtitleItem :subtitle="item" />
|
||||||
|
<VDivider v-if="index < rawSubtitleDataList.length - 1" class="my-2" />
|
||||||
|
</template>
|
||||||
|
</ProgressiveCardGrid>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else-if="!isSubtitleSearch && progressActive && streamPreviewDataList.length > 0"
|
||||||
|
class="resource-list overflow-visible"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
v-for="(item, index) in streamPreviewDataList"
|
v-for="(item, index) in streamPreviewDataList"
|
||||||
:key="getTorrentItemKey(item, index)"
|
:key="getTorrentItemKey(item, index)"
|
||||||
@@ -1324,7 +1522,7 @@ onUnmounted(() => {
|
|||||||
<VDivider v-if="index < streamPreviewDataList.length - 1" class="my-2" />
|
<VDivider v-if="index < streamPreviewDataList.length - 1" class="my-2" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="filteredRowDataList.length > 0" class="resource-list">
|
<div v-else-if="!isSubtitleSearch && filteredRowDataList.length > 0" class="resource-list">
|
||||||
<ProgressiveCardGrid
|
<ProgressiveCardGrid
|
||||||
:items="filteredRowDataList"
|
:items="filteredRowDataList"
|
||||||
:columns="1"
|
:columns="1"
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { reactive } from 'vue'
|
||||||
|
|
||||||
|
const downloadedSubtitleMap = reactive<Record<string, boolean>>({})
|
||||||
|
|
||||||
|
export function markSubtitleDownloaded(url?: string | null) {
|
||||||
|
if (!url) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadedSubtitleMap[url] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
export { downloadedSubtitleMap }
|
||||||
Reference in New Issue
Block a user