fix search

This commit is contained in:
jxxghp
2023-07-08 13:54:06 +08:00
parent ae270b801e
commit 95c0c35dc4
3 changed files with 18 additions and 6 deletions

View File

@@ -6,7 +6,6 @@ const route = useRoute();
// 查询TMDBID或标题
const keyword = route.params?.keyword?.toString() ?? "";
console.log(keyword);
</script>
<template>

View File

@@ -26,6 +26,13 @@ const router = createRouter({
requiresAuth: true,
},
},
{
path: 'resource',
component: () => import('../pages/resource.vue'),
meta: {
requiresAuth: true,
},
},
{
path: 'resource/:keyword+',
component: () => import('../pages/resource.vue'),

View File

@@ -18,12 +18,18 @@ 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}`);
let keyword = props.keyword?.toString() ?? "";
if (!keyword) {
// 查询上次搜索结果
dataList.value = await api.get("search/last");
} else {
// 按标题模糊查询
dataList.value = await api.get(`search/title/${props.keyword}`);
// 优先按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) {