diff --git a/package.json b/package.json index eb76c688..1b9459bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moviepilot", - "version": "1.5.5", + "version": "1.5.6", "private": true, "bin": "dist/service.js", "scripts": { @@ -107,4 +107,4 @@ "resolutions": { "postcss": "8" } -} +} \ No newline at end of file diff --git a/src/@core/utils/index.ts b/src/@core/utils/index.ts index 3da0fb91..e74b1717 100644 --- a/src/@core/utils/index.ts +++ b/src/@core/utils/index.ts @@ -33,7 +33,7 @@ export function isToday(date: Date) { ) } -// 计算时间差,返回xx天xx小时xx分钟 +// 计算时间差,返回xx天/xx小时/xx分钟/xx秒 export function calculateTimeDifference(inputTime: string): string { if (!inputTime) return '' @@ -64,6 +64,38 @@ export function calculateTimeDifference(inputTime: string): string { } } +// 计算时间差,返回xx天xx小时xx分钟 +export function calculateTimeDiff(inputTime: string): string { + if (!inputTime) + return '' + + // 使用当前时区 + const inputDate = new Date(inputTime) + const currentDate = new Date() + + const timeDifference = currentDate.getTime() - inputDate.getTime() + const secondsDifference = Math.floor(timeDifference / 1000) + + const days = Math.floor(secondsDifference / 86400) + const hours = Math.floor(secondsDifference % 86400 / 3600) + const minutes = Math.floor(secondsDifference % 86400 % 3600 / 60) + const secones = Math.floor(secondsDifference % 60) + + if (days > 0) + return `${days}天${hours}小时${minutes}分钟` + + else if (hours > 0) + return `${hours}小时${minutes}分钟` + + else if (minutes > 0) + return `${minutes}分钟` + + else if (secones > 0) + return `${secones}秒` + + return '' +} + // 判断一个数组subArray是不是在另一个数组mainArray中 export function isContained(subArray: any[], mainArray: any[]): boolean { return subArray.every(element => mainArray.includes(element)) diff --git a/src/api/types.ts b/src/api/types.ts index 598533f5..f4d17fcb 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -651,6 +651,13 @@ export interface TorrentInfo { // 促销描述 volume_factor: string + + // 免费时间 + freedate: string + + // 剩余免费时间 + freedate_diff: string + } // 识别元数据 diff --git a/src/components/cards/SiteCard.vue b/src/components/cards/SiteCard.vue index afdc8fbe..8d496f21 100644 --- a/src/components/cards/SiteCard.vue +++ b/src/components/cards/SiteCard.vue @@ -412,6 +412,23 @@ onMounted(() => {
{{ item.raw.description }}
+ + H&R + + + {{ item.raw?.freedate_diff }} + { v-if="torrent?.labels" class="pb-3 pt-0 pe-12" > + + H&R + + + {{ torrent?.freedate_diff }} + { v-if="torrent?.labels" class="pt-2" > + + H&R + + + {{ torrent?.freedate_diff }} +