This commit is contained in:
jxxghp
2023-07-04 12:33:35 +08:00
parent f87d87e69b
commit d543f8d97f
4 changed files with 58 additions and 34 deletions

View File

@@ -109,5 +109,6 @@
"borderStyle": "solid" "borderStyle": "solid"
} }
] ]
} },
"vue3snippets.enable-compile-vue-file-on-did-save-code": true
} }

View File

@@ -39,6 +39,8 @@ export interface Subscribe {
state: string; state: string;
// 最后更新时间 // 最后更新时间
last_update: string; last_update: string;
// 订阅用户
username: string;
} }
// 历史记录 // 历史记录

View File

@@ -151,10 +151,26 @@ const dropdownItems = ref([
class="me-1" class="me-1"
v-if="props.media?.total_episode" v-if="props.media?.total_episode"
/> />
<span class="text-subtitle-2" :class="getTextClass()" v-if="props.media?.season" <span
class="text-subtitle-2 me-4"
:class="getTextClass()"
v-if="props.media?.season"
>{{ (props.media?.total_episode || 0) - (props.media?.lack_episode || 0) }} / >{{ (props.media?.total_episode || 0) - (props.media?.lack_episode || 0) }} /
{{ props.media?.total_episode }}</span {{ props.media?.total_episode }}</span
> >
<IconBtn
icon="mdi-account"
:color="getTextColor()"
class="me-1"
v-if="props.media?.username"
/>
<span
class="text-subtitle-2"
:class="getTextClass()"
v-if="props.media?.username"
>
{{ props.media?.username }}
</span>
</div> </div>
</VCardText> </VCardText>

View File

@@ -1,58 +1,63 @@
<script lang="ts" setup> <script lang="ts" setup>
import api from '@/api' import api from "@/api";
import type { DownloadingInfo } from '@/api/types' import type { DownloadingInfo } from "@/api/types";
import NoDataFound from '@/components/NoDataFound.vue' import NoDataFound from "@/components/NoDataFound.vue";
import DownloadingCard from '@/components/cards/DownloadingCard.vue' import DownloadingCard from "@/components/cards/DownloadingCard.vue";
import PullRefresh from 'pull-refresh-vue3' import PullRefresh from "pull-refresh-vue3";
// 定时器
let refreshTimer: NodeJS.Timer | null = null;
// 数据列表 // 数据列表
const dataList = ref<DownloadingInfo[]>([]) const dataList = ref<DownloadingInfo[]>([]);
// 获取订阅列表数据 // 获取订阅列表数据
const fetchData = async () => { const fetchData = async () => {
try { try {
dataList.value = await api.get('download') dataList.value = await api.get("download");
isRefreshed.value = true isRefreshed.value = true;
} catch (error) { } catch (error) {
console.error(error) console.error(error);
} }
} };
// 刷新状态 // 刷新状态
const loading = ref(false) const loading = ref(false);
// 是否刷新过 // 是否刷新过
const isRefreshed = ref(false) const isRefreshed = ref(false);
// 下拉刷新 // 下拉刷新
const onRefresh = () => { const onRefresh = () => {
loading.value = true loading.value = true;
fetchData() fetchData();
loading.value = false loading.value = false;
} };
// 加载时获取数据 // 加载时获取数据
onBeforeMount(() => { onBeforeMount(() => {
fetchData() fetchData();
}) // 启动定时器
refreshTimer = setInterval(() => {
fetchData();
}, 3000);
});
// 组件卸载时停止定时器
onUnmounted(() => {
if (refreshTimer) {
clearInterval(refreshTimer);
refreshTimer = null;
}
});
</script> </script>
<template> <template>
<PullRefresh <PullRefresh v-model="loading" @refresh="onRefresh">
v-model="loading" <div class="grid gap-3 grid-downloading-card" v-if="dataList.length > 0">
@refresh="onRefresh" <DownloadingCard v-for="data in dataList" :key="data.hash" :info="data" />
>
<div
class="grid gap-3 grid-downloading-card"
v-if="dataList.length > 0"
>
<DownloadingCard
v-for="data in dataList"
:key="data.hash"
:info="data"
/>
</div> </div>
<NoDataFound <NoDataFound
v-if="dataList.length === 0 && isRefreshed" v-if="dataList.length === 0 && isRefreshed"
error-code="404" error-code="404"
error-title="没有任务" error-title="没有任务"