fix torrent cards

This commit is contained in:
jxxghp
2023-07-08 16:31:30 +08:00
parent 378f81967b
commit a2731c8281
4 changed files with 77 additions and 14 deletions
+2
View File
@@ -322,6 +322,8 @@ export interface TorrentInfo {
labels: string[] labels: string[]
// 种子优先级 // 种子优先级
pri_order: number pri_order: number
// 促销描述
volume_factor: string
} }
+1
View File
@@ -185,6 +185,7 @@ onMounted(() => {
:width="props.width" :width="props.width"
:flat="!siteForm.is_active" :flat="!siteForm.is_active"
class="overflow-hidden" class="overflow-hidden"
@click="siteInfoDialog = true"
> >
<template #image> <template #image>
<VAvatar class="absolute right-2 bottom-2" variant="flat" rounded="0"> <VAvatar class="absolute right-2 bottom-2" variant="flat" rounded="0">
+1 -1
View File
@@ -165,7 +165,7 @@ const subscribeForm = reactive({
</script> </script>
<template> <template>
<VCard :key="props.media?.id" v-if="cardState"> <VCard :key="props.media?.id" v-if="cardState" @click="subscribeInfoDialog = true">
<template #image> <template #image>
<VImg <VImg
:src="props.media?.backdrop || props.media?.poster" :src="props.media?.backdrop || props.media?.poster"
+73 -13
View File
@@ -2,6 +2,7 @@
import api from "@/api"; import api from "@/api";
import { Context } from "@/api/types"; import { Context } from "@/api/types";
import { useToast } from "vue-toast-notification"; import { useToast } from "vue-toast-notification";
import { useConfirm } from "vuetify-use-dialog";
// 输入参数 // 输入参数
const props = defineProps({ const props = defineProps({
@@ -13,6 +14,9 @@ const props = defineProps({
// 提示框 // 提示框
const $toast = useToast(); const $toast = useToast();
// 确认框
const createConfirm = useConfirm();
// 种子信息 // 种子信息
const torrent = ref(props.torrent?.torrent_info); const torrent = ref(props.torrent?.torrent_info);
// 媒体信息 // 媒体信息
@@ -32,13 +36,29 @@ const getSiteIcon = async () => {
} }
}; };
// 询问并添加下载
const handleAddDownload = async () => {
const isConfirmed = await createConfirm({
title: "确认",
content: `是否确认下载 ${torrent.value?.title} ?`,
confirmationText: "确认",
cancellationText: "取消",
dialogProps: {
maxWidth: 600,
},
});
if (!isConfirmed) return;
addDownload();
};
// 添加下载 // 添加下载
const addDownload = async () => { const addDownload = async () => {
try { try {
const result: { [key: string]: Any } = await api.post("download/add", { const result: { [key: string]: any } = await api.post("download", {
torrent_info: torrent?.value, media_in: media?.value,
media_info: media?.value, torrent_in: torrent?.value,
meta_info: meta?.value,
}); });
if (result.success) { if (result.success) {
// 添加下载成功 // 添加下载成功
@@ -53,29 +73,24 @@ const addDownload = async () => {
} }
}; };
// 打开种子详情
const openTorrentDetail = () => {
window.open(torrent?.value?.page_url, "_blank");
};
// 装载时查询站点图标 // 装载时查询站点图标
onMounted(() => { onMounted(() => {
getSiteIcon(); getSiteIcon();
}); });
</script> </script>
<template> <template>
<VCard :width="props.width" :height="props.height"> <VCard :width="props.width" :height="props.height" @click="handleAddDownload">
<template #image> <template #image>
<VAvatar class="absolute right-2 bottom-2" variant="flat" rounded="0"> <VAvatar class="absolute right-2 bottom-2" variant="flat" rounded="0">
<VImg :src="siteIcon" /> <VImg :src="siteIcon" />
</VAvatar> </VAvatar>
</template> </template>
<VCardTitle @click="addDownload"> <VCardTitle>
{{ media?.title }} {{ meta?.season_episode }} {{ media?.title }} {{ meta?.season_episode }}
<span class="text-green-700 ms-2 text-sm">{{ torrent?.seeders }}</span> <span class="text-green-700 ms-2 text-sm">{{ torrent?.seeders }}</span>
<span class="text-orange-700 ms-2 text-sm">{{ torrent?.peers }}</span> <span class="text-orange-700 ms-2 text-sm">{{ torrent?.peers }}</span>
</VCardTitle> </VCardTitle>
<VCardText @click="openTorrentDetail"> <VCardText>
{{ torrent?.title }} {{ torrent?.title }}
</VCardText> </VCardText>
<VCardText>{{ torrent?.description }}</VCardText> <VCardText>{{ torrent?.description }}</VCardText>
@@ -85,9 +100,54 @@ onMounted(() => {
size="small" size="small"
v-for="label in torrent?.labels" v-for="label in torrent?.labels"
color="primary" color="primary"
class="me-1" class="me-1 mb-1"
>{{ label }}</VChip >{{ label }}</VChip
> >
<VChip
v-if="meta?.resource_type"
variant="elevated"
size="small"
color="error"
class="me-1 mb-1"
>
{{ meta?.resource_type }}</VChip
>
<VChip
v-if="meta?.resource_pix"
variant="elevated"
size="small"
color="error"
class="me-1 mb-1"
>
{{ meta?.resource_pix }}
</VChip>
<VChip
v-if="meta?.video_encode"
variant="elevated"
size="small"
color="warning"
class="me-1 mb-1"
>
{{ meta?.video_encode }}
</VChip>
<VChip
v-if="meta?.resource_team"
variant="elevated"
size="small"
color="info"
class="me-1 mb-1"
>
{{ meta?.resource_team }}
</VChip>
<VChip
v-if="torrent?.volume_factor"
variant="elevated"
size="small"
color="success"
class="me-1 mb-1"
>
{{ torrent?.volume_factor }}
</VChip>
</VCardItem> </VCardItem>
</VCard> </VCard>
</template> </template>