diff --git a/src/@core/utils/formatters.ts b/src/@core/utils/formatters.ts index df62adc9..aab5eded 100644 --- a/src/@core/utils/formatters.ts +++ b/src/@core/utils/formatters.ts @@ -47,4 +47,23 @@ export const formatDateToMonthShort = (value: string, toTimeForCurrentDay = true export const prefixWithPlus = (value: number) => value > 0 ? `+${value}` : value +// 格式化为Sxx export const formatSeason = (value: string) => value ? `S${value.padStart(2, '0')}` : '' + +// 格式化为xx[TGMK]B +export const formatFileSize = (bytes: number) => { + if (bytes < 0) { + throw new Error("字节数不能为负数。"); + } + + const units = ["B", "KB", "MB", "GB", "TB"]; + let size = bytes; + let unitIndex = 0; + + while (size >= 1024 && unitIndex < units.length - 1) { + size /= 1024; + unitIndex++; + } + + return `${size.toFixed(2)} ${units[unitIndex]}`; +} diff --git a/src/api/types.ts b/src/api/types.ts index 6e50b7d7..0b40b3ea 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -1,3 +1,4 @@ + // 订阅 export interface Subscribe { id: number; @@ -253,3 +254,140 @@ export interface Plugin { installed?: boolean } + +// 种子信息 +export interface TorrentInfo { + // 站点ID + site?: number + // 站点名称 + site_name?: string + // 站点Cookie + site_cookie?: string + // 站点UA + site_ua?: string + // 站点是否使用代理 + site_proxy: boolean + // 站点优先级 + site_order: number + // 种子名称 + title?: string + // 种子副标题 + description?: string + // IMDB ID + imdbid: string + // 种子链接 + enclosure?: string + // 详情页面 + page_url?: string + // 种子大小 + size: number + // 做种者 + seeders: number + // 下载者 + peers: number + // 完成者 + grabs: number + // 发布时间 + pubdate?: string + // 已过时间 + date_elapsed?: string + // 上传因子 + uploadvolumefactor: number + // 下载因子 + downloadvolumefactor: number + // HR + hit_and_run: boolean + // 种子标签 + labels: string[] + // 种子优先级 + pri_order: number +} + + +// 识别元数据 +export interface MetaInfo { + // 是否处理的文件 + isfile: boolean + // 原字符串 + org_string?: string + // 副标题 + subtitle?: string + // 类型 电影、电视剧 + type: string + // 识别的中文名 + cn_name?: string + // 识别的英文名 + en_name?: string + // 年份 + year?: string + // 总季数 + total_seasons: number + // 识别的开始季 数字 + begin_season?: number + // 识别的结束季 数字 + end_season?: number + // 总集数 + total_episodes: number + // 识别的开始集 + begin_episode?: number + // 识别的结束集 + end_episode?: number + // Partx Cd Dvd Disk Disc + part?: string + // 识别的资源类型 + resource_type?: string + // 识别的效果 + resource_effect?: string + // 识别的分辨率 + resource_pix?: string + // 识别的制作组/字幕组 + resource_team?: string + // 视频编码 + video_encode?: string + // 音频编码 + audio_encode?: string + // 名称(自动中英文) + name: string + // SXX-SXX + season: string + // SXX-SXX 有季号才返回 + sea: string + // begin_season 的数字,电视剧没有季的返回1 + season_seq: string + // 季的数组 + season_list: number[] + // Exx-Exx + episode: string + // 集的数组 + episode_list: number[] + // ExxExx + episodes: string + //xx-xx + episode_seqs: string + // begin_episode 的数字 + episode_seq: string + // SxxExx + season_episode: string + // 资源类型字符串,含分辨率 + resource_term: string + // 资源类型字符串,不含分辨率 + edtion: string + // 发布组/字幕组字符串 + release_group: string + // 视频编码 + video_term: string + // 音频编码 + audio_term: string + +} + + +// 上下文信息 +export interface Context { + // 元信息 + meta_info: MetaInfo, + // 媒体信息 + media_info: MediaInfo, + // 种子信息 + torrent_info: TorrentInfo, +} diff --git a/src/components/cards/MediaCard.vue b/src/components/cards/MediaCard.vue index b9e3bfc0..0e175fdb 100644 --- a/src/components/cards/MediaCard.vue +++ b/src/components/cards/MediaCard.vue @@ -3,8 +3,8 @@ import { formatSeason } from "@/@core/utils/formatters"; import api from "@/api"; import { doneNProgress, startNProgress } from "@/api/nprogress"; import { MediaInfo, NotExistMediaInfo, Subscribe, TmdbSeason } from "@/api/types"; +import router from "@/router"; import { useToast } from "vue-toast-notification"; - // 输入参数 const props = defineProps({ media: Object as PropType, @@ -231,7 +231,7 @@ const checkSeasonsNotExists = async () => { }); } } catch (error) { - $toast.error(`${props.media?.title}无法识别到themoviedb媒体信息!`); + $toast.error(`${props.media?.title}无法识别TMDB媒体信息!`); tmdbFlag.value = false; } // 处理完成 @@ -318,6 +318,17 @@ const openDetailWindow = () => { window.open(getDetailLink(), "_blank"); }; +// 开始搜索 +const handleSearch = () => { + router.push( + `/resource/${ + props.media?.tmdb_id + ? `tmdb:${props.media?.tmdb_id}` + : `douban:${props.media?.douban_id}` + }` + ); +}; + // 装载时检查是否已订阅 onBeforeMount(handleCheckSubscribe); @@ -394,7 +405,7 @@ const seasonsSelected = ref([]); {{ props.media?.overview }}

- + +import { Context } from "@/api/types"; + +// 输入参数 +const props = defineProps({ + torrent: Object as PropType, + width: String, + height: String, +}); + + diff --git a/src/pages/resource.vue b/src/pages/resource.vue index e519b417..d95113ac 100644 --- a/src/pages/resource.vue +++ b/src/pages/resource.vue @@ -1,3 +1,16 @@ - + + + diff --git a/src/router/index.ts b/src/router/index.ts index 955d99d2..3741b7d1 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -27,8 +27,9 @@ const router = createRouter({ }, }, { - path: 'resource', + path: 'resource/:keyword+', component: () => import('../pages/resource.vue'), + props: true, meta: { requiresAuth: true, }, diff --git a/src/views/discover/TorrentCardListView.vue b/src/views/discover/TorrentCardListView.vue new file mode 100644 index 00000000..6dfdb817 --- /dev/null +++ b/src/views/discover/TorrentCardListView.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/src/views/setting/PluginCardListView.vue b/src/views/setting/PluginCardListView.vue index 5dde3c46..e33101dd 100644 --- a/src/views/setting/PluginCardListView.vue +++ b/src/views/setting/PluginCardListView.vue @@ -31,7 +31,7 @@ onBeforeMount(fetchData); indeterminate color="primary" > -
+