mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-06 08:06:43 +08:00
feat(SearchBar): 添加站点搜索功能,支持多选和过滤
This commit is contained in:
@@ -31,6 +31,9 @@ const year = route.query?.year
|
|||||||
// 搜索季
|
// 搜索季
|
||||||
const season = route.query?.season?.toString() ?? ''
|
const season = route.query?.season?.toString() ?? ''
|
||||||
|
|
||||||
|
// 搜索站点,以,分离多个
|
||||||
|
const sites = route.query?.sites?.toString() ?? ''
|
||||||
|
|
||||||
// 视图类型,从localStorage中读取
|
// 视图类型,从localStorage中读取
|
||||||
const viewType = ref<string>(localStorage.getItem('MPTorrentsViewType') ?? 'card')
|
const viewType = ref<string>(localStorage.getItem('MPTorrentsViewType') ?? 'card')
|
||||||
|
|
||||||
@@ -97,6 +100,7 @@ async function fetchData() {
|
|||||||
title,
|
title,
|
||||||
year,
|
year,
|
||||||
season,
|
season,
|
||||||
|
sites,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -104,6 +108,7 @@ async function fetchData() {
|
|||||||
result = await api.get(`search/title`, {
|
result = await api.get(`search/title`, {
|
||||||
params: {
|
params: {
|
||||||
keyword,
|
keyword,
|
||||||
|
sites,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import type { Plugin, Subscribe } from '@/api/types'
|
import type { Plugin, Site, Subscribe } from '@/api/types'
|
||||||
import { SystemNavMenus, SettingTabs } from '@/router/menu'
|
import { SystemNavMenus, SettingTabs } from '@/router/menu'
|
||||||
import { NavMenu } from '@/@layouts/types'
|
import { NavMenu } from '@/@layouts/types'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
@@ -123,6 +123,12 @@ const matchedPluginItems = computed(() => {
|
|||||||
// 所有订阅数据
|
// 所有订阅数据
|
||||||
const SubscribeItems = ref<Subscribe[]>([])
|
const SubscribeItems = ref<Subscribe[]>([])
|
||||||
|
|
||||||
|
// 所有站点
|
||||||
|
const allSites = ref<Site[]>([])
|
||||||
|
|
||||||
|
// 选中的站点
|
||||||
|
const selectedSites = ref<number[]>([])
|
||||||
|
|
||||||
// 获取订阅列表数据
|
// 获取订阅列表数据
|
||||||
async function fetchSubscribes() {
|
async function fetchSubscribes() {
|
||||||
try {
|
try {
|
||||||
@@ -132,6 +138,29 @@ async function fetchSubscribes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询所有站点
|
||||||
|
async function querySites() {
|
||||||
|
try {
|
||||||
|
const data: Site[] = await api.get('site/')
|
||||||
|
|
||||||
|
// 过滤站点,只有启用的站点才显示
|
||||||
|
allSites.value = data.filter(item => item.is_active)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询用户选中的站点
|
||||||
|
async function querySelectedSites() {
|
||||||
|
try {
|
||||||
|
const result: { [key: string]: any } = await api.get('system/setting/IndexerSites')
|
||||||
|
|
||||||
|
selectedSites.value = result.data?.value ?? []
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 匹配的订阅列表
|
// 匹配的订阅列表
|
||||||
const matchedSubscribeItems = computed(() => {
|
const matchedSubscribeItems = computed(() => {
|
||||||
if (!searchWord.value) return []
|
if (!searchWord.value) return []
|
||||||
@@ -165,6 +194,7 @@ function searchTorrent() {
|
|||||||
query: {
|
query: {
|
||||||
keyword: searchWord.value,
|
keyword: searchWord.value,
|
||||||
area: 'title',
|
area: 'title',
|
||||||
|
sites: selectedSites.value.join(','),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
emit('close')
|
emit('close')
|
||||||
@@ -228,6 +258,8 @@ onMounted(() => {
|
|||||||
fetchInstalledPlugins()
|
fetchInstalledPlugins()
|
||||||
fetchSubscribes()
|
fetchSubscribes()
|
||||||
loadRecentSearches()
|
loadRecentSearches()
|
||||||
|
querySites()
|
||||||
|
querySelectedSites()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
@@ -304,10 +336,28 @@ onMounted(() => {
|
|||||||
</VHover>
|
</VHover>
|
||||||
<VHover>
|
<VHover>
|
||||||
<template #default="hover">
|
<template #default="hover">
|
||||||
<VListItem prepend-icon="mdi-search-web" link v-bind="hover.props" @click="searchTorrent">
|
<VListItem
|
||||||
|
prepend-icon="mdi-file-search"
|
||||||
|
link
|
||||||
|
v-bind="hover.props"
|
||||||
|
@click="searchTorrent"
|
||||||
|
:ripple="false"
|
||||||
|
>
|
||||||
<VListItemTitle class="break-words whitespace-break-spaces">
|
<VListItemTitle class="break-words whitespace-break-spaces">
|
||||||
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的【站点资源】 ...
|
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的【站点资源】 ...
|
||||||
</VListItemTitle>
|
</VListItemTitle>
|
||||||
|
<VChipGroup v-if="hover.isHovering" v-model="selectedSites" column multiple @click.stop>
|
||||||
|
<VChip
|
||||||
|
v-for="site in allSites"
|
||||||
|
:key="site.id"
|
||||||
|
:color="selectedSites.includes(site.id) ? 'primary' : ''"
|
||||||
|
filter
|
||||||
|
variant="outlined"
|
||||||
|
:value="site.id"
|
||||||
|
>
|
||||||
|
{{ site.name }}
|
||||||
|
</VChip>
|
||||||
|
</VChipGroup>
|
||||||
<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" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user