no data found pages

This commit is contained in:
jxxghp
2023-07-02 22:17:54 +08:00
parent b2f66c513c
commit 4aabcccd49
8 changed files with 178 additions and 95 deletions

View File

@@ -9,6 +9,9 @@ const props = defineProps({
type: String,
});
// 是否刷新过
const isRefreshed = ref(false)
// 数据列表
const dataList = ref<Subscribe[]>([]);
@@ -16,13 +19,14 @@ const dataList = ref<Subscribe[]>([]);
const fetchData = async () => {
try {
dataList.value = await api.get("subscribe");
isRefreshed.value = true
} catch (error) {
console.error(error);
}
};
// 加载时获取数据
onMounted(fetchData);
onBeforeMount(fetchData);
// 刷新状态
const loading = ref(false);
@@ -42,9 +46,17 @@ const filteredDataList = computed(() => {
<template>
<PullRefresh v-model="loading" @refresh="onRefresh">
<div class="grid gap-3 grid-subscribe-card">
<div class="grid gap-3 grid-subscribe-card"
v-if="filteredDataList.length > 0">
<SubscribeCard v-for="data in filteredDataList" :key="data.id" :media="data" />
</div>
<NoDataFound
v-if="filteredDataList.length === 0 && isRefreshed"
error-code="404"
error-title="没有订阅"
error-description="请通过搜索添加电影电视剧订阅"
>
</NoDataFound>
</PullRefresh>
</template>