feat:支持直接搜索站点资源

This commit is contained in:
jxxghp
2024-06-02 21:10:02 +08:00
parent 18d778a1cc
commit 8f970e0008
5 changed files with 80 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "moviepilot",
"version": "1.9.3-1",
"version": "1.9.3-2",
"private": true,
"bin": "dist/service.js",
"scripts": {

View File

@@ -70,18 +70,24 @@ async function handleAddDownload(_site: any = undefined, _media: any = undefined
async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) {
startNProgress()
try {
const result: { [key: string]: any } = await api.post('download/', {
media_in: _media,
torrent_in: _torrent,
})
let result: { [key: string]: any }
if (result.success) {
if (_media) {
result = await api.post('download/', {
media_in: _media,
torrent_in: _torrent,
})
} else {
result = await api.post('download/add', _torrent)
}
if (result && result.success) {
// 添加下载成功
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`)
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 下载成功!`)
downloaded.value.push(_torrent?.enclosure || '')
} else {
// 添加下载失败
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 添加下载失败!`)
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 下载失败${result?.message}`)
}
} catch (error) {
console.error(error)
@@ -127,7 +133,7 @@ onMounted(() => {
</template>
<VCardItem class="py-1">
<VCardTitle class="break-words overflow-visible whitespace-break-spaces">
{{ media?.title }} {{ meta?.season_episode }}
{{ media?.title ?? meta?.name }} {{ meta?.season_episode }}
<span class="text-green-700 ms-2 text-sm">{{ torrent?.seeders }}</span>
<span class="text-orange-700 ms-2 text-sm">{{ torrent?.peers }}</span>
</VCardTitle>

View File

@@ -67,18 +67,24 @@ async function handleAddDownload(_site: any = undefined, _media: any = undefined
async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) {
startNProgress()
try {
const result: { [key: string]: any } = await api.post('download/', {
media_in: _media,
torrent_in: _torrent,
})
let result: { [key: string]: any }
if (result.success) {
if (_media) {
result = await api.post('download/', {
media_in: _media,
torrent_in: _torrent,
})
} else {
result = await api.post('download/add', _torrent)
}
if (result && result.success) {
// 添加下载成功
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`)
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 下载成功!`)
downloaded.value.push(_torrent?.enclosure || '')
} else {
// 添加下载失败
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 添加下载失败!`)
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 下载失败${result?.message}`)
}
} catch (error) {
console.error(error)

View File

@@ -65,7 +65,7 @@ function startLoadingProgress() {
// 停止监听加载进度
function stopLoadingProgress() {
progressEventSource.value?.close()
if (progressEventSource.value) progressEventSource.value?.close()
}
// 设置视图类型
@@ -82,23 +82,28 @@ async function fetchData() {
dataList.value = await api.get('search/last')
} else {
startLoadingProgress()
let result: { [key: string]: any }
// 优先按TMDBID精确查询
if (keyword?.startsWith('tmdb:') || keyword?.startsWith('douban:') || keyword?.startsWith('bangumi:')) {
const result: { [key: string]: any } = await api.get(`search/media/${keyword}`, {
result = await api.get(`search/media/${keyword}`, {
params: {
mtype: type,
area,
season,
},
})
if (result.success) {
dataList.value = result.data
} else {
errorDescription.value = result.message
}
} else {
// 按标题模糊查询
dataList.value = await api.get(`search/title/${keyword}`)
result = await api.get(`search/title`, {
params: {
keyword,
},
})
}
if (result && result.success) {
dataList.value = result.data
} else if (result && result.message) {
errorDescription.value = result.message
}
stopLoadingProgress()
// 从浏览器历史中删除当前搜索
@@ -116,6 +121,11 @@ async function fetchData() {
onMounted(() => {
fetchData()
})
// 卸载时停止加载进度
onUnmounted(() => {
stopLoadingProgress()
})
</script>
<template>

View File

@@ -23,9 +23,6 @@ const searchWord = ref(null)
// ref
const searchWordInput = ref<HTMLElement | null>(null)
// 搜索提示词列表
const searchHintList = ref<string[]>([])
// 所有菜单功能
function getMenus(): NavMenu[] {
let menus: NavMenu[] = []
@@ -146,7 +143,6 @@ const matchedSubscribeItems = computed(() => {
function searchMedia(searchType: string) {
// 搜索类型 media/person
if (!searchWord.value) return
if (!searchHintList.value.includes(searchWord.value)) searchHintList.value.push(searchWord.value)
router.push({
path: '/browse/media/search',
query: {
@@ -157,6 +153,19 @@ function searchMedia(searchType: string) {
emit('close')
}
// 跳转到种子搜索页面
function searchTorrent() {
if (!searchWord.value) return
router.push({
path: '/resource',
query: {
keyword: searchWord.value,
area: 'title',
},
})
emit('close')
}
// 跳转插件页面
function showPlugin(pluginId: string) {
router.push({
@@ -214,7 +223,6 @@ onMounted(() => {
variant="plain"
class="text-high-emphasis"
placeholder="搜索 ..."
:items="searchHintList"
@keydown.enter="searchMedia('media')"
>
<template #prepend>
@@ -227,7 +235,7 @@ onMounted(() => {
<div class="ps h-100">
<VList lines="one" v-if="searchWord">
<!-- 搜索结果 -->
<VListSubheader v-if="searchWord"> 媒体 </VListSubheader>
<VListSubheader v-if="searchWord"> 媒体 & 资源 </VListSubheader>
<VHover>
<template #default="hover">
<VListItem
@@ -238,7 +246,7 @@ onMounted(() => {
@click="searchMedia('media')"
>
<VListItemTitle>
搜索 <span class="font-bold">{{ searchWord }} </span> 相关的电影电视剧 ...
搜索 <span class="font-bold">{{ searchWord }} </span> 相关的电影电视剧 ...
</VListItemTitle>
<template #append>
<VIcon v-if="hover.isHovering" icon="ri-corner-down-left-line" />
@@ -256,7 +264,25 @@ onMounted(() => {
@click="searchMedia('person')"
>
<VListItemTitle>
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的人物 ...
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的演职人员 ...
</VListItemTitle>
<template #append>
<VIcon v-if="hover.isHovering" icon="ri-corner-down-left-line" />
</template>
</VListItem>
</template>
</VHover>
<VHover>
<template #default="hover">
<VListItem
prepend-icon="mdi-search-web"
density="compact"
link
v-bind="hover.props"
@click="searchTorrent"
>
<VListItemTitle>
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的站点资源 ...
</VListItemTitle>
<template #append>
<VIcon v-if="hover.isHovering" icon="ri-corner-down-left-line" />