feat 已存在时添加洗版订阅

This commit is contained in:
jxxghp
2023-07-29 08:44:05 +08:00
parent 01e2563784
commit ab4418d215
+16 -33
View File
@@ -64,7 +64,7 @@ function getChipColor(type: string) {
} }
// 添加订阅处理 // 添加订阅处理
// eslint-disable-next-line sonarjs/cognitive-complexity
async function handleAddSubscribe() { async function handleAddSubscribe() {
if (props.media?.type === '电视剧' && props.media?.tmdb_id) { if (props.media?.type === '电视剧' && props.media?.tmdb_id) {
// TMDB电视剧 // TMDB电视剧
@@ -76,23 +76,15 @@ async function handleAddSubscribe() {
return return
} }
if (seasonInfos.value.length === 1) {
// 添加订阅
addSubscribe()
}
else {
// 检查各季的缺失状态 // 检查各季的缺失状态
await checkSeasonsNotExists() await checkSeasonsNotExists()
if (!tmdbFlag.value) if (!tmdbFlag.value)
return return
if (seasonInfos.value.length === 1) {
// 只有1季
if (!seasonsNotExisted.value[1]) {
// 已存在
$toast.warning(`${props.media?.title} 媒体库中已存在!`)
}
else {
// 添加订阅
addSubscribe()
}
}
else {
// 弹出季选择列表,支持多选 // 弹出季选择列表,支持多选
subscribeSeasonDialog.value = true subscribeSeasonDialog.value = true
} }
@@ -100,27 +92,11 @@ async function handleAddSubscribe() {
else if (props.media?.type === '电视剧') { else if (props.media?.type === '电视剧') {
// 豆瓣电视剧,只会有一季 // 豆瓣电视剧,只会有一季
const season = props.media?.season || 1 const season = props.media?.season || 1
// 检查缺失情况
await checkSeasonsNotExists()
if (!tmdbFlag.value)
return
if (!seasonsNotExisted.value[season]) {
// 已存在
$toast.warning(`${props.media?.title} 媒体库中已存在!`)
}
else {
// 添加订阅 // 添加订阅
addSubscribe(season) addSubscribe(season)
} }
}
else { else {
// 电影 // 电影
const exists = await checkMovieExists()
if (exists)
$toast.warning(`${props.media?.title} 媒体库中已存在!`)
else
addSubscribe() addSubscribe()
} }
} }
@@ -137,6 +113,7 @@ async function addSubscribe(season = 0) {
tmdbid: props.media?.tmdb_id, tmdbid: props.media?.tmdb_id,
doubanid: props.media?.douban_id, doubanid: props.media?.douban_id,
season, season,
best_version: isExists.value ? 1 : 0,
}) })
// 订阅状态 // 订阅状态
@@ -151,6 +128,7 @@ async function addSubscribe(season = 0) {
props.media?.title ?? '', props.media?.title ?? '',
season, season,
result.message, result.message,
isExists.value,
) )
} }
catch (error) { catch (error) {
@@ -163,14 +141,19 @@ async function addSubscribe(season = 0) {
function showSubscribeAddToast(result: boolean, function showSubscribeAddToast(result: boolean,
title: string, title: string,
season: number, season: number,
message: string) { message: string,
isExists: boolean) {
if (season) if (season)
title = `${title} ${formatSeason(season.toString())}` title = `${title} ${formatSeason(season.toString())}`
let subname = '订阅'
if (isExists)
subname = '洗版订阅'
if (result) if (result)
$toast.success(`${title} 添加订阅成功!`) $toast.success(`${title} 添加${subname}成功!`)
else else
$toast.error(`${title} 添加订阅失败:${message}`) $toast.error(`${title} 添加${subname}失败:${message}`)
} }
// 调用API取消订阅 // 调用API取消订阅