Skip to content

Commit

Permalink
fix(web): page dead when no data
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilfish committed Mar 3, 2024
1 parent 089be04 commit 5d9f71e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/core/src/stores/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export const usePostStore = defineStore('post', () => {
}

async function get(page?: number) {
if (ids.value.length === 0)
return []

let p = page
if (!p)
p = curPage.value
Expand All @@ -63,7 +66,7 @@ export const usePostStore = defineStore('post', () => {
const query = route.query.q as string

if (posts.value.length === 0)
posts.value = await getMany<Post>(ids.value)
posts.value = (await getMany<Post>(ids.value)) || []

if (path === '/post') {
total.value = ids.value.length
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const route = useRoute()
const loaded = ref(false)
onMounted(async () => {
const ids = await indexDB.getItem<string[]>('ids')
postStore.ids = ids ?? []
postStore.ids = ids || []
postStore.total = ids?.length ?? 0
loaded.value = true
})
Expand Down

0 comments on commit 5d9f71e

Please sign in to comment.