Skip to content

Commit

Permalink
feat: then to async await
Browse files Browse the repository at this point in the history
  • Loading branch information
Plumbiu committed Feb 5, 2023
1 parent 6850ae1 commit f64a0a8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions frontend/components/ArticlesList/index.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<script setup lang="ts">
const artlistData = useArtlist(await useFetchPostData())
const { data } = await useFetch('/api/global')
const route = useRoute()
let pagenum = 1
const isLoading = useState('isLoading', () => false)
const artlistData = useArtlist(await useFetchPostData())
const isEmpty = useState('isEmpty', () => true)
const isEmpty = useState('isEmpty', () => false)
const articleAds = data.value.articleAds
const addArtListItem = async () => {
if (useScrollBottom()) {
pagenum++
const artlistVal = await useFetchPostData(route.path, route.query?.sort, pagenum)
const artlistVal = await useFetchPostData(route.path, route.query?.sort, pagenum++)
artlistData.value.push(...artlistVal)
}
}
const { data } = await useFetch('/api/global')
const articleAds = data.value.articleAds
const bottomHandler = useThrottle(addArtListItem)
watch(route, async () => {
pagenum = 1
isLoading.value = true
Expand All @@ -25,7 +26,6 @@ watch(route, async () => {
isLoading.value = false
isEmpty.value = false
}, { deep: true })
const bottomHandler = useThrottle(addArtListItem)
onBeforeMount(() => {
const EmployeeWindow = window as any
EmployeeWindow.addEventListener('scroll', bottomHandler)
Expand Down

0 comments on commit f64a0a8

Please sign in to comment.