mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-06 16:16:42 +08:00
feat:支持直接搜索站点资源
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "moviepilot",
|
"name": "moviepilot",
|
||||||
"version": "1.9.3-1",
|
"version": "1.9.3-2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"bin": "dist/service.js",
|
"bin": "dist/service.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -70,18 +70,24 @@ async function handleAddDownload(_site: any = undefined, _media: any = undefined
|
|||||||
async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) {
|
async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) {
|
||||||
startNProgress()
|
startNProgress()
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('download/', {
|
let result: { [key: string]: any }
|
||||||
media_in: _media,
|
|
||||||
torrent_in: _torrent,
|
|
||||||
})
|
|
||||||
|
|
||||||
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 || '')
|
downloaded.value.push(_torrent?.enclosure || '')
|
||||||
} else {
|
} else {
|
||||||
// 添加下载失败
|
// 添加下载失败
|
||||||
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 添加下载失败!`)
|
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 下载失败:${result?.message}!`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
@@ -127,7 +133,7 @@ onMounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
<VCardItem class="py-1">
|
<VCardItem class="py-1">
|
||||||
<VCardTitle class="break-words overflow-visible whitespace-break-spaces">
|
<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-green-700 ms-2 text-sm">↑{{ torrent?.seeders }}</span>
|
||||||
<span class="text-orange-700 ms-2 text-sm">↓{{ torrent?.peers }}</span>
|
<span class="text-orange-700 ms-2 text-sm">↓{{ torrent?.peers }}</span>
|
||||||
</VCardTitle>
|
</VCardTitle>
|
||||||
|
|||||||
@@ -67,18 +67,24 @@ async function handleAddDownload(_site: any = undefined, _media: any = undefined
|
|||||||
async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) {
|
async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) {
|
||||||
startNProgress()
|
startNProgress()
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('download/', {
|
let result: { [key: string]: any }
|
||||||
media_in: _media,
|
|
||||||
torrent_in: _torrent,
|
|
||||||
})
|
|
||||||
|
|
||||||
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 || '')
|
downloaded.value.push(_torrent?.enclosure || '')
|
||||||
} else {
|
} else {
|
||||||
// 添加下载失败
|
// 添加下载失败
|
||||||
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 添加下载失败!`)
|
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 下载失败:${result?.message}!`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|||||||
+18
-8
@@ -65,7 +65,7 @@ function startLoadingProgress() {
|
|||||||
|
|
||||||
// 停止监听加载进度
|
// 停止监听加载进度
|
||||||
function stopLoadingProgress() {
|
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')
|
dataList.value = await api.get('search/last')
|
||||||
} else {
|
} else {
|
||||||
startLoadingProgress()
|
startLoadingProgress()
|
||||||
|
let result: { [key: string]: any }
|
||||||
// 优先按TMDBID精确查询
|
// 优先按TMDBID精确查询
|
||||||
if (keyword?.startsWith('tmdb:') || keyword?.startsWith('douban:') || keyword?.startsWith('bangumi:')) {
|
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: {
|
params: {
|
||||||
mtype: type,
|
mtype: type,
|
||||||
area,
|
area,
|
||||||
season,
|
season,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (result.success) {
|
|
||||||
dataList.value = result.data
|
|
||||||
} else {
|
|
||||||
errorDescription.value = result.message
|
|
||||||
}
|
|
||||||
} else {
|
} 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()
|
stopLoadingProgress()
|
||||||
// 从浏览器历史中删除当前搜索
|
// 从浏览器历史中删除当前搜索
|
||||||
@@ -116,6 +121,11 @@ async function fetchData() {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchData()
|
fetchData()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 卸载时停止加载进度
|
||||||
|
onUnmounted(() => {
|
||||||
|
stopLoadingProgress()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -23,9 +23,6 @@ const searchWord = ref(null)
|
|||||||
// ref
|
// ref
|
||||||
const searchWordInput = ref<HTMLElement | null>(null)
|
const searchWordInput = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
// 搜索提示词列表
|
|
||||||
const searchHintList = ref<string[]>([])
|
|
||||||
|
|
||||||
// 所有菜单功能
|
// 所有菜单功能
|
||||||
function getMenus(): NavMenu[] {
|
function getMenus(): NavMenu[] {
|
||||||
let menus: NavMenu[] = []
|
let menus: NavMenu[] = []
|
||||||
@@ -146,7 +143,6 @@ const matchedSubscribeItems = computed(() => {
|
|||||||
function searchMedia(searchType: string) {
|
function searchMedia(searchType: string) {
|
||||||
// 搜索类型 media/person
|
// 搜索类型 media/person
|
||||||
if (!searchWord.value) return
|
if (!searchWord.value) return
|
||||||
if (!searchHintList.value.includes(searchWord.value)) searchHintList.value.push(searchWord.value)
|
|
||||||
router.push({
|
router.push({
|
||||||
path: '/browse/media/search',
|
path: '/browse/media/search',
|
||||||
query: {
|
query: {
|
||||||
@@ -157,6 +153,19 @@ function searchMedia(searchType: string) {
|
|||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 跳转到种子搜索页面
|
||||||
|
function searchTorrent() {
|
||||||
|
if (!searchWord.value) return
|
||||||
|
router.push({
|
||||||
|
path: '/resource',
|
||||||
|
query: {
|
||||||
|
keyword: searchWord.value,
|
||||||
|
area: 'title',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
|
||||||
// 跳转插件页面
|
// 跳转插件页面
|
||||||
function showPlugin(pluginId: string) {
|
function showPlugin(pluginId: string) {
|
||||||
router.push({
|
router.push({
|
||||||
@@ -214,7 +223,6 @@ onMounted(() => {
|
|||||||
variant="plain"
|
variant="plain"
|
||||||
class="text-high-emphasis"
|
class="text-high-emphasis"
|
||||||
placeholder="搜索 ..."
|
placeholder="搜索 ..."
|
||||||
:items="searchHintList"
|
|
||||||
@keydown.enter="searchMedia('media')"
|
@keydown.enter="searchMedia('media')"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
@@ -227,7 +235,7 @@ onMounted(() => {
|
|||||||
<div class="ps h-100">
|
<div class="ps h-100">
|
||||||
<VList lines="one" v-if="searchWord">
|
<VList lines="one" v-if="searchWord">
|
||||||
<!-- 搜索结果 -->
|
<!-- 搜索结果 -->
|
||||||
<VListSubheader v-if="searchWord"> 媒体 </VListSubheader>
|
<VListSubheader v-if="searchWord"> 媒体 & 资源 </VListSubheader>
|
||||||
<VHover>
|
<VHover>
|
||||||
<template #default="hover">
|
<template #default="hover">
|
||||||
<VListItem
|
<VListItem
|
||||||
@@ -238,7 +246,7 @@ onMounted(() => {
|
|||||||
@click="searchMedia('media')"
|
@click="searchMedia('media')"
|
||||||
>
|
>
|
||||||
<VListItemTitle>
|
<VListItemTitle>
|
||||||
搜索 <span class="font-bold">{{ searchWord }} </span> 相关的电影、电视剧 ...
|
搜索 <span class="font-bold">{{ searchWord }} </span> 相关的【电影、电视剧】 ...
|
||||||
</VListItemTitle>
|
</VListItemTitle>
|
||||||
<template #append>
|
<template #append>
|
||||||
<VIcon v-if="hover.isHovering" icon="ri-corner-down-left-line" />
|
<VIcon v-if="hover.isHovering" icon="ri-corner-down-left-line" />
|
||||||
@@ -256,7 +264,25 @@ onMounted(() => {
|
|||||||
@click="searchMedia('person')"
|
@click="searchMedia('person')"
|
||||||
>
|
>
|
||||||
<VListItemTitle>
|
<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>
|
</VListItemTitle>
|
||||||
<template #append>
|
<template #append>
|
||||||
<VIcon v-if="hover.isHovering" icon="ri-corner-down-left-line" />
|
<VIcon v-if="hover.isHovering" icon="ri-corner-down-left-line" />
|
||||||
|
|||||||
Reference in New Issue
Block a user