diff --git a/package.json b/package.json index 82e409ff..fd0fcc62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moviepilot", - "version": "1.9.3-1", + "version": "1.9.3-2", "private": true, "bin": "dist/service.js", "scripts": { diff --git a/src/components/cards/TorrentCard.vue b/src/components/cards/TorrentCard.vue index 3abbe04b..3f641ca2 100644 --- a/src/components/cards/TorrentCard.vue +++ b/src/components/cards/TorrentCard.vue @@ -70,18 +70,24 @@ async function handleAddDownload(_site: any = undefined, _media: any = undefined async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) { startNProgress() try { - const result: { [key: string]: any } = await api.post('download/', { - media_in: _media, - torrent_in: _torrent, - }) + let result: { [key: string]: any } - if (result.success) { + if (_media) { + result = await api.post('download/', { + media_in: _media, + torrent_in: _torrent, + }) + } else { + result = await api.post('download/add', _torrent) + } + + if (result && result.success) { // 添加下载成功 - $toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`) + $toast.success(`${_torrent?.site_name} ${_torrent?.title} 下载成功!`) downloaded.value.push(_torrent?.enclosure || '') } else { // 添加下载失败 - $toast.error(`${_torrent?.site_name} ${_torrent?.title} 添加下载失败!`) + $toast.error(`${_torrent?.site_name} ${_torrent?.title} 下载失败:${result?.message}!`) } } catch (error) { console.error(error) @@ -127,7 +133,7 @@ onMounted(() => { - {{ media?.title }} {{ meta?.season_episode }} + {{ media?.title ?? meta?.name }} {{ meta?.season_episode }} ↑{{ torrent?.seeders }} ↓{{ torrent?.peers }} diff --git a/src/components/cards/TorrentItem.vue b/src/components/cards/TorrentItem.vue index c44e46be..7d3124ee 100644 --- a/src/components/cards/TorrentItem.vue +++ b/src/components/cards/TorrentItem.vue @@ -67,18 +67,24 @@ async function handleAddDownload(_site: any = undefined, _media: any = undefined async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) { startNProgress() try { - const result: { [key: string]: any } = await api.post('download/', { - media_in: _media, - torrent_in: _torrent, - }) + let result: { [key: string]: any } - if (result.success) { + if (_media) { + result = await api.post('download/', { + media_in: _media, + torrent_in: _torrent, + }) + } else { + result = await api.post('download/add', _torrent) + } + + if (result && result.success) { // 添加下载成功 - $toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`) + $toast.success(`${_torrent?.site_name} ${_torrent?.title} 下载成功!`) downloaded.value.push(_torrent?.enclosure || '') } else { // 添加下载失败 - $toast.error(`${_torrent?.site_name} ${_torrent?.title} 添加下载失败!`) + $toast.error(`${_torrent?.site_name} ${_torrent?.title} 下载失败:${result?.message}!`) } } catch (error) { console.error(error) diff --git a/src/pages/resource.vue b/src/pages/resource.vue index f1a7359b..394863a3 100644 --- a/src/pages/resource.vue +++ b/src/pages/resource.vue @@ -65,7 +65,7 @@ function startLoadingProgress() { // 停止监听加载进度 function stopLoadingProgress() { - progressEventSource.value?.close() + if (progressEventSource.value) progressEventSource.value?.close() } // 设置视图类型 @@ -82,23 +82,28 @@ async function fetchData() { dataList.value = await api.get('search/last') } else { startLoadingProgress() + let result: { [key: string]: any } // 优先按TMDBID精确查询 if (keyword?.startsWith('tmdb:') || keyword?.startsWith('douban:') || keyword?.startsWith('bangumi:')) { - const result: { [key: string]: any } = await api.get(`search/media/${keyword}`, { + result = await api.get(`search/media/${keyword}`, { params: { mtype: type, area, season, }, }) - if (result.success) { - dataList.value = result.data - } else { - errorDescription.value = result.message - } } else { // 按标题模糊查询 - dataList.value = await api.get(`search/title/${keyword}`) + result = await api.get(`search/title`, { + params: { + keyword, + }, + }) + } + if (result && result.success) { + dataList.value = result.data + } else if (result && result.message) { + errorDescription.value = result.message } stopLoadingProgress() // 从浏览器历史中删除当前搜索 @@ -116,6 +121,11 @@ async function fetchData() { onMounted(() => { fetchData() }) + +// 卸载时停止加载进度 +onUnmounted(() => { + stopLoadingProgress() +})