mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
fix subscribe
This commit is contained in:
@@ -31,3 +31,29 @@ export const isToday = (date: Date) => {
|
|||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const calculateTimeDifference = (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);
|
||||||
|
|
||||||
|
if (secondsDifference < 60) {
|
||||||
|
return `${secondsDifference}秒`;
|
||||||
|
} else if (secondsDifference < 3600) {
|
||||||
|
const minutes = Math.floor(secondsDifference / 60);
|
||||||
|
return `${minutes}分钟`;
|
||||||
|
} else if (secondsDifference < 86400) {
|
||||||
|
const hours = Math.floor(secondsDifference / 3600);
|
||||||
|
return `${hours}小时`;
|
||||||
|
} else {
|
||||||
|
const days = Math.floor(secondsDifference / 86400);
|
||||||
|
return `${days}天`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,19 +1,33 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { calculateTimeDifference } from "@/@core/utils";
|
||||||
|
import { formatSeason } from "@/@core/utils/formatters";
|
||||||
import api from "@/api";
|
import api from "@/api";
|
||||||
import { Subscribe } from "@/api/types";
|
import { Subscribe } from "@/api/types";
|
||||||
import { formatSeason } from "@core/utils/formatters";
|
import { useToast } from "vue-toast-notification";
|
||||||
|
|
||||||
// 输入参数
|
// 输入参数
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
media: Object as PropType<Subscribe>,
|
media: Object as PropType<Subscribe>,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 提示框
|
||||||
|
const $toast = useToast();
|
||||||
|
|
||||||
// 是否显示卡片
|
// 是否显示卡片
|
||||||
const cardState = ref(true);
|
const cardState = ref(true);
|
||||||
|
|
||||||
// 图片是否加载完成
|
// 图片是否加载完成
|
||||||
const imageLoaded = ref(false);
|
const imageLoaded = ref(false);
|
||||||
|
|
||||||
|
// 上一次更新时间
|
||||||
|
const lastUpdateText = ref(
|
||||||
|
`${
|
||||||
|
props.media?.last_update
|
||||||
|
? `${calculateTimeDifference(props.media?.last_update || "")}前`
|
||||||
|
: ""
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
|
||||||
// 图片加载完成响应
|
// 图片加载完成响应
|
||||||
const imageLoadHandler = () => {
|
const imageLoadHandler = () => {
|
||||||
console.log(imageLoaded.value);
|
console.log(imageLoaded.value);
|
||||||
@@ -67,6 +81,21 @@ const removeSubscribe = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 搜索订阅
|
||||||
|
const searchSubscribe = async () => {
|
||||||
|
try {
|
||||||
|
const result: { [key: string]: any } = await api.get(
|
||||||
|
`subscribe/search/${props.media?.id}`
|
||||||
|
);
|
||||||
|
// 提示
|
||||||
|
if (result.success) {
|
||||||
|
$toast.success(`${props.media?.name} 提交搜索请求成功!`);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 弹出菜单
|
// 弹出菜单
|
||||||
const dropdownItems = ref([
|
const dropdownItems = ref([
|
||||||
{
|
{
|
||||||
@@ -77,8 +106,16 @@ const dropdownItems = ref([
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "取消订阅",
|
title: "搜索",
|
||||||
value: 2,
|
value: 2,
|
||||||
|
props: {
|
||||||
|
prependIcon: "mdi-magnify",
|
||||||
|
click: searchSubscribe,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "取消订阅",
|
||||||
|
value: 3,
|
||||||
props: {
|
props: {
|
||||||
prependIcon: "mdi-trash-can-outline",
|
prependIcon: "mdi-trash-can-outline",
|
||||||
color: "error",
|
color: "error",
|
||||||
@@ -144,8 +181,8 @@ const dropdownItems = ref([
|
|||||||
<span class="text-subtitle-2 me-4" :class="getTextClass()">{{
|
<span class="text-subtitle-2 me-4" :class="getTextClass()">{{
|
||||||
props.media?.vote
|
props.media?.vote
|
||||||
}}</span>
|
}}</span>
|
||||||
|
|
||||||
<IconBtn
|
<IconBtn
|
||||||
|
v-bind="props"
|
||||||
icon="mdi-progress-clock"
|
icon="mdi-progress-clock"
|
||||||
:color="getTextColor()"
|
:color="getTextColor()"
|
||||||
class="me-1"
|
class="me-1"
|
||||||
@@ -165,7 +202,7 @@ const dropdownItems = ref([
|
|||||||
v-if="props.media?.username"
|
v-if="props.media?.username"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
class="text-subtitle-2"
|
class="text-subtitle-2 me-4"
|
||||||
:class="getTextClass()"
|
:class="getTextClass()"
|
||||||
v-if="props.media?.username"
|
v-if="props.media?.username"
|
||||||
>
|
>
|
||||||
@@ -173,7 +210,12 @@ const dropdownItems = ref([
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</VCardText>
|
</VCardText>
|
||||||
|
<VCardText
|
||||||
|
class="absolute right-0 bottom-0 d-flex align-center p-2"
|
||||||
|
v-if="lastUpdateText"
|
||||||
|
>
|
||||||
|
<VIcon icon="mdi-download" class="me-1" /> {{ lastUpdateText }}
|
||||||
|
</VCardText>
|
||||||
<VProgressLinear
|
<VProgressLinear
|
||||||
v-if="getPercentage() > 0"
|
v-if="getPercentage() > 0"
|
||||||
:model-value="getPercentage()"
|
:model-value="getPercentage()"
|
||||||
|
|||||||
Reference in New Issue
Block a user