From f377ac3fcc964364a1f1f87a23abcec3481ccc6b Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 9 Apr 2024 13:20:54 +0800 Subject: [PATCH] fix search --- src/pages/resource.vue | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pages/resource.vue b/src/pages/resource.vue index bca26b7c..c8b384f8 100644 --- a/src/pages/resource.vue +++ b/src/pages/resource.vue @@ -36,6 +36,12 @@ const progressValue = ref(0) // 加载进度SSE const progressEventSource = ref() +// 错误标题 +const errorTitle = ref('没有数据') + +// 错误描述 +const errorDescription = ref('未搜索到任何资源') + // 使用SSE监听加载进度 function startLoadingProgress() { progressText.value = '正在搜索,请稍候...' @@ -76,12 +82,17 @@ async function fetchData() { startLoadingProgress() // 优先按TMDBID精确查询 if (keyword?.startsWith('tmdb:') || keyword?.startsWith('douban:') || keyword?.startsWith('bangumi:')) { - dataList.value = await api.get(`search/media/${keyword}`, { + const result: {[key: string]: any} = await api.get(`search/media/${keyword}`, { params: { mtype: type, area, }, }) + if (result.success){ + dataList.value = result.data + } else { + errorDescription.value = result.message + } } else { // 按标题模糊查询 @@ -112,9 +123,8 @@ onMounted(() => {