Skip to content

Commit

Permalink
fix: route错误
Browse files Browse the repository at this point in the history
  • Loading branch information
MarleneJiang committed Feb 6, 2023
1 parent 1a3a3f1 commit cf078ab
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions frontend/components/ArticlesList/index.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<script setup lang="ts">
const route = useRoute()
const articleList = ref(await useFetchPostData(route?.params?.all))
const articleList = ref(await useFetchPostData(route?.params))
const { data: articleAds } = (await useFetch('/api/global/ad'))
const isLoading = useState('isLoading', () => true)
let pagenum = 1
const addArtListItem = useThrottle(async () => {
useScrollBottom() && articleList.value.push(...(await useFetchPostData(route?.params?.all, route.query?.sort, ++pagenum)))
useScrollBottom() && articleList.value.push(...(await useFetchPostData(route?.params, route.query?.sort, ++pagenum)))
})
watch(() => route, async () => {
// 目前仅在query改变生效
articleList.value = []
articleList.value = await useFetchPostData(route?.params?.all, route.query?.sort, pagenum = 1)
articleList.value = await useFetchPostData(route?.params, route.query?.sort, pagenum = 1)
}, { deep: true })
onMounted(() => {
(window as any).addEventListener('scroll', addArtListItem)
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/Types/TagNav.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
const route = useRoute()
const { data: tagList } = await useFetch(`/api/global/tags?type=${route?.params?.all?.type}`)
const { data: tagList } = await useFetch(`/api/global/tags?type=${route?.params?.type}`)
const isFold = useFold(false)
const maxLength = 9
</script>
Expand All @@ -10,12 +10,12 @@ const maxLength = 9
<nav v-if="tagList.length > 0" class="tag-nav tag-navigator">
<ul class="nav-list tag-list">
<li class="nav-items tag active">
<NuxtLink :to="`/${route?.params?.all?.type}`" class="nav-item">
<NuxtLink :to="`/${route?.params?.type}`" class="nav-item">
综合
</NuxtLink>
</li>
<li v-for="(item, index) in tagList" :key="item.id" class="nav-items tag " :class="{ '!hidden': (index >= maxLength && !isFold) }">
<NuxtLink :to="`/${route?.params?.all?.type}/${item.tag}`" class="nav-item">
<NuxtLink :to="`/${route?.params?.type}/${item.tag}`" class="nav-item">
{{ item.alias }}
</NuxtLink>
</li>
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Types/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isNavShown = inject('isNavShown')
综合
</NuxtLink>
<div v-for="item in typeList" :key="item.type" class="list-item-wrapper">
<NuxtLink class="type-list-item" :to="`/${item.type}`" :class="{ 'router-link-exact-active': route?.params?.all?.type === item.type }">
<NuxtLink class="type-list-item" :to="`/${item.type}`" :class="{ 'router-link-exact-active': route?.params?.type === item.type }">
{{ item.alias }}
</NuxtLink>
<div v-if="item.tags.data.length > 0" class="category-popover">
Expand Down
2 changes: 1 addition & 1 deletion frontend/composables/Articlelist/useArtlistFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const useFetchPostData = async (
sort: any = 'recommended',
pagenum = 1,
): Promise<IArticleItem[]> => {
const url = `/api/articles/list?sort=${sort}&type=${params?.type}&pageNum=${pagenum}&tag=${params?.tag || ''}`
const url = `/api/articles/list?sort=${sort}&type=${params?.type || ''}&pageNum=${pagenum}&tag=${params?.tag || ''}`
const { data } = await useFetch(url)
// 数据内容
return data.value
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<template>
<div class="root">
<Main pb-8rem />
<Main />
</div>
</template>

Expand Down

0 comments on commit cf078ab

Please sign in to comment.