mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-07-21 04:22:09 +08:00
fix subscribe season
This commit is contained in:
112
src/api/types.ts
112
src/api/types.ts
@@ -123,54 +123,80 @@ export interface MediaInfo {
|
||||
}
|
||||
|
||||
|
||||
// TMDB季信息
|
||||
export interface TmdbSeason {
|
||||
air_date?: string
|
||||
episode_count?: number
|
||||
name?: string
|
||||
overview?: string
|
||||
poster_path?: string
|
||||
season_number?: number
|
||||
vote_average?: number
|
||||
}
|
||||
|
||||
// TMDB集信息
|
||||
export interface TmdbEpisodes {
|
||||
air_date?: string
|
||||
episode_number?: number
|
||||
name?: string
|
||||
overview?: string
|
||||
runtime?: number
|
||||
season_number?: number
|
||||
still_path?: string
|
||||
vote_average?: number
|
||||
crew: Object[]
|
||||
guest_stars: Object[]
|
||||
}
|
||||
|
||||
|
||||
// 站点
|
||||
export interface Site {
|
||||
// ID
|
||||
id: number
|
||||
// 站点名称
|
||||
name: string
|
||||
// 站点主域名Key
|
||||
domain: string
|
||||
// 站点地址
|
||||
url: string
|
||||
// 站点优先级
|
||||
pri?:number
|
||||
// RSS地址
|
||||
rss?: string
|
||||
// Cookie
|
||||
cookie?: string
|
||||
// User-Agent
|
||||
ua?: string
|
||||
// 是否使用代理
|
||||
proxy?:number
|
||||
// 过滤规则
|
||||
filter?: string
|
||||
// 是否演染
|
||||
render?:number
|
||||
// 备注
|
||||
note?: string
|
||||
// 流控单位周期
|
||||
limit_interval?:number
|
||||
// 流控次数
|
||||
limit_count?:number
|
||||
// 流控间隔
|
||||
limit_seconds?:number
|
||||
// 是否启用
|
||||
is_active: boolean
|
||||
id: number
|
||||
// 站点名称
|
||||
name: string
|
||||
// 站点主域名Key
|
||||
domain: string
|
||||
// 站点地址
|
||||
url: string
|
||||
// 站点优先级
|
||||
pri?: number
|
||||
// RSS地址
|
||||
rss?: string
|
||||
// Cookie
|
||||
cookie?: string
|
||||
// User-Agent
|
||||
ua?: string
|
||||
// 是否使用代理
|
||||
proxy?: number
|
||||
// 过滤规则
|
||||
filter?: string
|
||||
// 是否演染
|
||||
render?: number
|
||||
// 备注
|
||||
note?: string
|
||||
// 流控单位周期
|
||||
limit_interval?: number
|
||||
// 流控次数
|
||||
limit_count?: number
|
||||
// 流控间隔
|
||||
limit_seconds?: number
|
||||
// 是否启用
|
||||
is_active: boolean
|
||||
}
|
||||
|
||||
|
||||
// 正在下载
|
||||
export interface DownloadingInfo {
|
||||
hash?: string
|
||||
title?: string
|
||||
name?: string
|
||||
year?: string
|
||||
season_episode?: string
|
||||
size?: number
|
||||
progress?: number
|
||||
state?: string
|
||||
dlspeed?: string
|
||||
upspeed?: string
|
||||
media: {[key: string]: any}
|
||||
}
|
||||
hash?: string
|
||||
title?: string
|
||||
name?: string
|
||||
year?: string
|
||||
season_episode?: string
|
||||
size?: number
|
||||
progress?: number
|
||||
state?: string
|
||||
dlspeed?: string
|
||||
upspeed?: string
|
||||
media: { [key: string]: any }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import api from "@/api";
|
||||
import { doneNProgress, startNProgress } from "@/api/nprogress";
|
||||
import { MediaInfo, Subscribe } from "@/api/types";
|
||||
import { MediaInfo, Subscribe, TmdbSeason } from "@/api/types";
|
||||
import { useToast } from "vue-toast-notification";
|
||||
|
||||
// 输入参数
|
||||
@@ -31,8 +31,28 @@ const getChipColor = (type: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 添加订阅
|
||||
const addSubscribe = async () => {
|
||||
const handleAddSubscribe = async () => {
|
||||
// 检查是否多季
|
||||
let season = props.media?.season;
|
||||
if (!season && props.media?.tmdb_id && props.media?.type == "电视剧") {
|
||||
// TMDB且是电视剧
|
||||
let seasons = await getMediaSeasons();
|
||||
if (!seasons) {
|
||||
$toast.error(`${props.media?.title} 查询剧集信息失败!`);
|
||||
return;
|
||||
}
|
||||
// 添加最新季
|
||||
// TODO 弹出季选择列表,支持多选
|
||||
addSubscribe(seasons[seasons.length - 1].season_number);
|
||||
} else {
|
||||
// 电影或者只有1季的电视剧直接添加
|
||||
addSubscribe(season);
|
||||
}
|
||||
};
|
||||
|
||||
// 添加订阅,电视剧的话需要指定季
|
||||
const addSubscribe = async (season: number = 0) => {
|
||||
// 开始处理
|
||||
startNProgress();
|
||||
try {
|
||||
const result: { [key: string]: any } = await api.post("subscribe", {
|
||||
@@ -41,7 +61,7 @@ const addSubscribe = async () => {
|
||||
year: props.media?.year,
|
||||
tmdbid: props.media?.tmdb_id,
|
||||
doubanid: props.media?.douban_id,
|
||||
season: props.media?.season,
|
||||
season: season,
|
||||
});
|
||||
// 订阅状态
|
||||
if (result.success) {
|
||||
@@ -93,12 +113,22 @@ const checkSubscribe = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 查询TMDB的季信息
|
||||
const getMediaSeasons = async () => {
|
||||
try {
|
||||
const result: TmdbSeason[] = await api.get(`tmdb/${props.media?.tmdb_id}/seasons`);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
// 订阅按钮响应
|
||||
const handleSubscribe = () => {
|
||||
if (isSubscribed.value) {
|
||||
removeSubscribe();
|
||||
} else {
|
||||
addSubscribe();
|
||||
handleAddSubscribe();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ const lastUpdateText = ref(
|
||||
|
||||
// 图片加载完成响应
|
||||
const imageLoadHandler = () => {
|
||||
console.log(imageLoaded.value);
|
||||
imageLoaded.value = true;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user