fix downloading card

This commit is contained in:
jxxghp
2023-07-12 22:27:02 +08:00
parent f2fe3c2f74
commit 27ff1bdab9
+39 -31
View File
@@ -23,6 +23,19 @@ const getSpeedText = () => {
// 下载状态 // 下载状态
const isDownloading = ref(props.info?.state === "downloading" ? true : false); const isDownloading = ref(props.info?.state === "downloading" ? true : false);
// 图片是否加载完成
const imageLoaded = ref(false);
// 图片加载完成响应
const imageLoadHandler = () => {
imageLoaded.value = true;
};
// 计算文本类
const getTextClass = () => {
return imageLoaded.value ? "text-white" : "";
};
// 下载状态控制 // 下载状态控制
const toggleDownload = async () => { const toggleDownload = async () => {
let operation = isDownloading.value ? "stop" : "start"; let operation = isDownloading.value ? "stop" : "start";
@@ -51,41 +64,36 @@ const deleteDownload = async () => {
<template> <template>
<VCard :key="props.info?.hash" v-if="cardState"> <VCard :key="props.info?.hash" v-if="cardState">
<div class="d-flex justify-space-between flex-nowrap flex-row"> <template #image>
<div class="ma-auto pa-3 pe-0" v-if="props.info?.media.image"> <VImg
<VImg :src="props.info?.media.image"
aspect-ratio="2/3" aspect-ratio="2/3"
width="100" cover
class="rounded" class="brightness-50"
:src="props.info?.media.image" @load="imageLoadHandler"
/> />
</div> </template>
<div class="w-full"> <VCardTitle class="break-words whitespace-normal" :class="getTextClass()">
<VCardTitle {{ props.info?.media.title || props.info?.name }}
>{{ props.info?.media.title || props.info?.name }} {{ props.info?.season_episode }}
{{ props.info?.season_episode }}</VCardTitle </VCardTitle>
>
<VCardSubtitle <VCardSubtitle class="break-words whitespace-normal" :class="getTextClass()">
class="break-all whitespace-normal line-clamp-2 overflow-hidden text-ellipsis ..." {{ props.info?.title }}
> </VCardSubtitle>
{{ props.info?.title }}
</VCardSubtitle>
<VCardText class="text-subtitle-1 pt-3 pb-1"> {{ getSpeedText() }} </VCardText> <VCardText class="text-subtitle-1 pt-3 pb-1" :class="getTextClass()"> {{ getSpeedText() }} </VCardText>
<VCardText v-if="getPercentage() > 0"> <VCardText v-if="getPercentage() > 0" :class="getTextClass()">
<VProgressLinear :model-value="getPercentage()" /> <VProgressLinear :model-value="getPercentage()" />
</VCardText> </VCardText>
<VCardActions class="justify-space-between"> <VCardActions class="justify-space-between">
<VBtn @click="toggleDownload"> <VBtn @click="toggleDownload">
<span class="ms-2">{{ isDownloading ? "暂停" : "开始" }}</span> <span class="ms-2">{{ isDownloading ? "暂停" : "开始" }}</span>
</VBtn> </VBtn>
<VBtn color="error" icon="mdi-trash-can-outline" @click="deleteDownload" /> <VBtn color="error" icon="mdi-trash-can-outline" @click="deleteDownload" />
</VCardActions> </VCardActions>
</div>
</div>
</VCard> </VCard>
</template> </template>