This commit is contained in:
jxxghp
2023-07-29 15:13:19 +08:00
parent abf15ff4c8
commit ab2b5d17ab

View File

@@ -1,7 +1,6 @@
<script lang="ts" setup>
import type { PropType, Ref } from 'vue'
import { useToast } from 'vue-toast-notification'
import { formatSeason } from '@/@core/utils/formatters'
import api from '@/api'
import { doneNProgress, startNProgress } from '@/api/nprogress'
import type { MediaInfo, NotExistMediaInfo, Subscribe, TmdbSeason } from '@/api/types'
@@ -119,16 +118,11 @@ async function addSubscribe(season = 0) {
if (result.success) {
// 订阅成功
isSubscribed.value = true
$toast.success(`${result.message}`)
}
else {
$toast.error(`${result.message}`)
}
// 提示
showSubscribeAddToast(
result.success,
props.media?.title ?? '',
season,
result.message,
isExists.value,
)
}
catch (error) {
console.error(error)
@@ -136,25 +130,6 @@ async function addSubscribe(season = 0) {
doneNProgress()
}
// 弹出添加订阅提示
function showSubscribeAddToast(result: boolean,
title: string,
season: number,
message: string,
isExists: boolean) {
if (season)
title = `${title} ${formatSeason(season.toString())}`
let subname = '订阅'
if (isExists)
subname = '洗版订阅'
if (result)
$toast.success(`${title} 添加${subname}成功!`)
else
$toast.error(`${title} 添加${subname}失败:${message}`)
}
// 调用API取消订阅
async function removeSubscribe() {
// 开始处理
@@ -288,19 +263,6 @@ function handleSubscribe() {
handleAddSubscribe()
}
// 拼装详情页链接
function getDetailLink() {
let link = ''
if (props.media?.douban_id)
link = `https://movie.douban.com/subject/${props.media?.douban_id}/`
else if (props.media?.type === '电影')
link = `https://www.themoviedb.org/movie/${props.media?.tmdb_id}`
else if (props.media?.type === '电视剧')
link = `https://www.themoviedb.org/tv/${props.media?.tmdb_id}`
return link
}
// 计算存在状态的颜色
function getExistColor(season: number) {
const state = seasonsNotExisted.value[season]