fix torrent card

This commit is contained in:
jxxghp
2023-07-08 23:31:06 +08:00
parent 7844577b5b
commit 3e90c0b0fc
5 changed files with 76 additions and 19 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ export const formatFileSize = (bytes: number) => {
throw new Error("字节数不能为负数。"); throw new Error("字节数不能为负数。");
} }
const units = ["B", "KB", "MB", "GB", "TB"]; const units = ["B", "K", "M", "G", "T"];
let size = bytes; let size = bytes;
let unitIndex = 0; let unitIndex = 0;
+2 -2
View File
@@ -393,14 +393,14 @@ export interface MetaInfo {
season_episode: string season_episode: string
// 资源类型字符串,含分辨率 // 资源类型字符串,含分辨率
resource_term: string resource_term: string
// 资源类型字符串,不含分辨率
edtion: string
// 发布组/字幕组字符串 // 发布组/字幕组字符串
release_group: string release_group: string
// 视频编码 // 视频编码
video_term: string video_term: string
// 音频编码 // 音频编码
audio_term: string audio_term: string
// 资源类型+特效
edition: string
} }
+3 -3
View File
@@ -258,7 +258,7 @@ onMounted(() => {
<VCardActions> <VCardActions>
<VBtn <VBtn
@click="handleSiteUpdate" @click.stop="handleSiteUpdate"
:disabled="updateButtonDisable" :disabled="updateButtonDisable"
v-if="!props.site?.public" v-if="!props.site?.public"
> >
@@ -267,13 +267,13 @@ onMounted(() => {
</template> </template>
{{ updateButtonText }} {{ updateButtonText }}
</VBtn> </VBtn>
<VBtn @click="handleSiteInfo"> <VBtn @click.stop="handleSiteInfo">
<template #prepend> <template #prepend>
<VIcon icon="mdi-square-edit-outline"></VIcon> <VIcon icon="mdi-square-edit-outline"></VIcon>
</template> </template>
编辑 编辑
</VBtn> </VBtn>
<VBtn @click="testSite" :disabled="testButtonDisable"> <VBtn @click.stop="testSite" :disabled="testButtonDisable">
<template #prepend> <template #prepend>
<VIcon icon="mdi-network-outline"></VIcon> <VIcon icon="mdi-network-outline"></VIcon>
</template> </template>
+1 -1
View File
@@ -194,7 +194,7 @@ const subscribeForm = reactive({
variant="plain" variant="plain"
:base-color="item.props.color" :base-color="item.props.color"
:key="i" :key="i"
@click="item.props.click" @click.stop="item.props.click"
> >
<template #prepend> <template #prepend>
<VIcon :icon="item.props.prependIcon"></VIcon> <VIcon :icon="item.props.prependIcon"></VIcon>
+69 -12
View File
@@ -1,4 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { formatFileSize } from "@/@core/utils/formatters";
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";
@@ -73,6 +74,27 @@ const addDownload = async () => {
} }
}; };
// 打开种子详情页面
const openTorrentDetail = () => {
window.open(torrent.value?.page_url, "_blank");
};
// 下载种子文件
const downloadTorrentFile = async () => {
window.open(torrent.value?.enclosure, "_blank");
};
// 促销Chip颜色
const getVolumeFactorColor = (downloadVolume: number, uploadVolume: number) => {
if (downloadVolume === 0) {
return "text-white bg-green-700";
} else if (uploadVolume >= 2) {
return "text-white bg-blue-700";
} else {
return "";
}
};
// 装载时查询站点图标 // 装载时查询站点图标
onMounted(() => { onMounted(() => {
getSiteIcon(); getSiteIcon();
@@ -85,16 +107,41 @@ onMounted(() => {
<VImg :src="siteIcon" /> <VImg :src="siteIcon" />
</VAvatar> </VAvatar>
</template> </template>
<VCardTitle> <VCardItem>
{{ media?.title }} {{ meta?.season_episode }} <VCardTitle>
<span class="text-green-700 ms-2 text-sm">{{ torrent?.seeders }}</span> {{ media?.title }} {{ meta?.season_episode }}
<span class="text-orange-700 ms-2 text-sm">{{ torrent?.peers }}</span> <span class="text-green-700 ms-2 text-sm">{{ torrent?.seeders }}</span>
</VCardTitle> <span class="text-orange-700 ms-2 text-sm">{{ torrent?.peers }}</span>
<VCardText> </VCardTitle>
<template #append>
<div class="me-n3">
<IconBtn>
<VIcon icon="mdi-dots-vertical" color="white" />
<VMenu activator="parent">
<VList>
<VListItem variant="plain" @click.stop="openTorrentDetail">
<template #prepend>
<VIcon icon="mdi-information"></VIcon>
</template>
<VListItemTitle>查看详情</VListItemTitle>
</VListItem>
<VListItem variant="plain" @click.stop="downloadTorrentFile">
<template #prepend>
<VIcon icon="mdi-download"></VIcon>
</template>
<VListItemTitle>下载种子</VListItemTitle>
</VListItem>
</VList>
</VMenu>
</IconBtn>
</div>
</template>
</VCardItem>
<VCardText class="text-subtitle-2">
{{ torrent?.title }} {{ torrent?.title }}
</VCardText> </VCardText>
<VCardText>{{ torrent?.description }}</VCardText> <VCardText>{{ torrent?.description }}</VCardText>
<VCardItem class="pb-3 pt-0" v-if="torrent?.labels"> <VCardItem class="pb-3 pt-0 pe-12" v-if="torrent?.labels">
<VChip <VChip
variant="elevated" variant="elevated"
size="small" size="small"
@@ -104,13 +151,13 @@ onMounted(() => {
>{{ label }}</VChip >{{ label }}</VChip
> >
<VChip <VChip
v-if="meta?.resource_type" v-if="meta?.edition"
variant="elevated" variant="elevated"
size="small" size="small"
color="error" color="error"
class="me-1 mb-1" class="me-1 mb-1"
> >
{{ meta?.resource_type }}</VChip {{ meta?.edition }}</VChip
> >
<VChip <VChip
v-if="meta?.resource_pix" v-if="meta?.resource_pix"
@@ -125,10 +172,18 @@ onMounted(() => {
v-if="meta?.video_encode" v-if="meta?.video_encode"
variant="elevated" variant="elevated"
size="small" size="small"
class="me-1 mb-1 text-white bg-indigo-500"
>
{{ meta?.video_encode }}
</VChip>
<VChip
v-if="torrent?.size"
variant="elevated"
size="small"
color="warning" color="warning"
class="me-1 mb-1" class="me-1 mb-1"
> >
{{ meta?.video_encode }} {{ formatFileSize(torrent?.size) }}
</VChip> </VChip>
<VChip <VChip
v-if="meta?.resource_team" v-if="meta?.resource_team"
@@ -140,10 +195,12 @@ onMounted(() => {
{{ meta?.resource_team }} {{ meta?.resource_team }}
</VChip> </VChip>
<VChip <VChip
v-if="torrent?.volume_factor" v-if="torrent?.downloadvolumefactor !== 1 || torrent?.uploadvolumefactor !== 1"
:color="
getVolumeFactorColor(torrent?.downloadvolumefactor, torrent?.uploadvolumefactor)
"
variant="elevated" variant="elevated"
size="small" size="small"
color="success"
class="me-1 mb-1" class="me-1 mb-1"
> >
{{ torrent?.volume_factor }} {{ torrent?.volume_factor }}