mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-06-01 21:59:54 +08:00
add search pages
This commit is contained in:
66
src/views/discover/TorrentCardListView.vue
Normal file
66
src/views/discover/TorrentCardListView.vue
Normal file
@@ -0,0 +1,66 @@
|
||||
<script lang="ts" setup>
|
||||
import api from "@/api";
|
||||
import { Context } from "@/api/types";
|
||||
import TorrentCard from "@/components/cards/TorrentCard.vue";
|
||||
import NoDataFound from "@/components/NoDataFound.vue";
|
||||
|
||||
// 定义输入参数
|
||||
const props = defineProps({
|
||||
keyword: String,
|
||||
});
|
||||
|
||||
// 数据列表
|
||||
const dataList = ref<Context[]>([]);
|
||||
|
||||
// 是否刷新过
|
||||
const isRefreshed = ref(false);
|
||||
|
||||
// 获取订阅列表数据
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
// 优先按TMDBID精确查询
|
||||
if (props.keyword?.startsWith("tmdb:") || props.keyword?.startsWith("douban:")) {
|
||||
dataList.value = await api.get(`search/media/${props.keyword}`);
|
||||
} else {
|
||||
// 按标题模糊查询
|
||||
dataList.value = await api.get(`search/title/${props.keyword}`);
|
||||
}
|
||||
isRefreshed.value = true;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
// 加载时获取数据
|
||||
onBeforeMount(fetchData);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VProgressCircular
|
||||
class="centered"
|
||||
v-if="!isRefreshed"
|
||||
indeterminate
|
||||
color="primary"
|
||||
></VProgressCircular>
|
||||
<div class="grid gap-3 grid-torrent-card" v-if="dataList.length > 0">
|
||||
<TorrentCard
|
||||
v-for="data in dataList"
|
||||
:key="data.torrent_info.title"
|
||||
:torrent="data"
|
||||
/>
|
||||
</div>
|
||||
<NoDataFound
|
||||
v-if="dataList.length === 0 && isRefreshed"
|
||||
error-code="404"
|
||||
error-title="没有资源"
|
||||
error-description="没有搜索到符合条件的资源。"
|
||||
>
|
||||
</NoDataFound>
|
||||
</template>
|
||||
|
||||
<style type="scss">
|
||||
.grid-torrent-card {
|
||||
grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
|
||||
padding-block-end: 1rem;
|
||||
}
|
||||
</style>
|
||||
@@ -31,7 +31,7 @@ onBeforeMount(fetchData);
|
||||
indeterminate
|
||||
color="primary"
|
||||
></VProgressCircular>
|
||||
<div class="grid gap-3 grid-site-card" v-if="dataList.length > 0">
|
||||
<div class="grid gap-3 grid-plugin-card" v-if="dataList.length > 0">
|
||||
<PluginCard v-for="data in dataList" :key="data.id" :plugin="data" />
|
||||
</div>
|
||||
<NoDataFound
|
||||
|
||||
Reference in New Issue
Block a user