Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

资源搜索支持指定站点 #244

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/pages/resource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const area = route.query?.area?.toString() ?? ''
// 搜索季
const season = route.query?.season?.toString() ?? ''

// 搜索的站点
const site = route.query?.site?.toString() ?? ''

// 视图类型,从localStorage中读取
const viewType = ref<string>(localStorage.getItem('MPTorrentsViewType') ?? 'card')

Expand Down Expand Up @@ -89,13 +92,15 @@ async function fetchData() {
mtype: type,
area,
season,
site,
},
})
} else {
// 按标题模糊查询
result = await api.get(`search/title`, {
params: {
keyword,
site,
},
})
}
Expand Down
35 changes: 34 additions & 1 deletion src/views/discover/MediaDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useToast } from 'vue-toast-notification'
import PersonCardSlideView from './PersonCardSlideView.vue'
import MediaCardSlideView from './MediaCardSlideView.vue'
import api from '@/api'
import type { MediaInfo, NotExistMediaInfo, Subscribe, TmdbEpisode } from '@/api/types'
import type { MediaInfo, NotExistMediaInfo, Subscribe, TmdbEpisode, Site } from '@/api/types'
import NoDataFound from '@/components/NoDataFound.vue'
import { doneNProgress, startNProgress } from '@/api/nprogress'
import { formatSeason } from '@/@core/utils/formatters'
Expand Down Expand Up @@ -55,6 +55,26 @@ const seasonsSubscribed = ref<{ [key: number]: boolean }>({})
// 订阅编号
const subscribeId = ref<number>()

// 所有站点
const allSites = ref<Site[]>([])

// 搜索的站点
const searchSite = ref<number>()

// 查询所有站点
async function querySites() {
try {
const data: Site[] = await api.get('site/')
// 过滤站点,只有启用的站点才显示
allSites.value = data.filter(item => item.is_active)
searchSite.value = undefined
} catch (error) {
console.log(error)
allSites.value = []
searchSite.value = undefined
}
}

// 获得mediaid
function getMediaId() {
return mediaDetail.value?.tmdb_id
Expand Down Expand Up @@ -404,6 +424,7 @@ function handleSearch(area: string) {
type: mediaDetail.value.type,
area,
season: mediaDetail.value.season,
site: searchSite.value,
},
})
}
Expand Down Expand Up @@ -451,6 +472,7 @@ function onSubscribeEditRemove() {
}

onBeforeMount(() => {
querySites()
getMediaDetail()
})
</script>
Expand Down Expand Up @@ -506,6 +528,17 @@ onBeforeMount(() => {
</span>
</div>
<div class="media-actions">
<VSelect
LongShengWen marked this conversation as resolved.
Show resolved Hide resolved
v-model="searchSite"
class="mb-2 mr-2"
variant="underlined"
:items="allSites"
item-title="name"
item-value="id"
label="指定搜索站点"
width="10rem"
clearable
/>
<VBtn
v-if="(mediaDetail.tmdb_id || mediaDetail.douban_id || mediaDetail.bangumi_id) && mediaDetail.imdb_id"
variant="tonal"
Expand Down