Skip to content

Commit

Permalink
feat: 文章列表新增无数据显示
Browse files Browse the repository at this point in the history
  • Loading branch information
Plumbiu committed Jan 30, 2023
1 parent c32ad0f commit 42b48fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions frontend/components/ArticlesList/Empty.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div class="fcc">
<div>对不起,没有数据喔</div>
</div>
</template>
2 changes: 2 additions & 0 deletions frontend/components/ArticlesList/Navigation/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
const isShow = useState<boolean>('isShow', () => false)
const iptValue = useState<string>('iptValue', () => '3天内')
const artlistPath = useArtlistPath()
const artlistData = useArtlist([])
const iptValueHandler = (time: string) => {
artlistData.value = []
isShow.value = false
iptValue.value = time
}
Expand Down
9 changes: 7 additions & 2 deletions frontend/components/ArticlesList/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const route = useRoute()
let pagenum = 1
const isLoading = useState('isLoading', () => false)
const isEmpty = useState('isEmpty', () => false)
const artlistData = useArtlist([])
const addArtListItem = () => {
if (useScrollBottom()) {
Expand All @@ -17,10 +18,13 @@ watchEffect(() => {
if (!artlistData.value.length) {
isLoading.value = true
useFetchPostData(route.path, route.query?.sort).then((data) => {
if (!data.length)
if (!data.length) {
isEmpty.value = true
return
}
artlistData.value = data
isLoading.value = false
isEmpty.value = false
})
}
}, { flush: 'post' })
Expand All @@ -37,9 +41,10 @@ onUnmounted(() => {
<template>
<div class="pb-5 box-border w-full">
<ArticlesListNavigation />
<ul v-if="!isLoading">
<ul v-if="!isLoading && !isEmpty">
<ArticlesListItem :artlist-item="artlistData" />
</ul>
<ArticlesListEmpty v-else-if="isEmpty" />
<ArticlesListSkeleton v-else />
</div>
</template>

0 comments on commit 42b48fb

Please sign in to comment.