Update API request formatting and error handling
This commit is contained in:
@ -146,7 +146,7 @@
|
||||
// })
|
||||
// }
|
||||
|
||||
const { data: projectTypeList, refresh: getParent } = useAsyncData('projectTypeListChildren-PopularDrawings-popularDrawings', async () => {
|
||||
const { data: projectTypeList, refresh: getParent } = await useAsyncData('projectTypeListChildren-PopularDrawings-popularDrawings', async () => {
|
||||
const res = await hotTag({
|
||||
type: query.type,
|
||||
limit: 6,
|
||||
@ -154,7 +154,7 @@
|
||||
})
|
||||
const all = [{ id: '0', name: '全部分类', children: [] }]
|
||||
if (Array.isArray(res.data) && res.data?.length > 0) {
|
||||
const total = [...res.data,...all]
|
||||
const total = [...res.data, ...all]
|
||||
// query.projectTypeDay = total[0]?.id || ''
|
||||
// query.projectType = total[0]!.children?.[0]?.id || ''
|
||||
return total
|
||||
@ -162,13 +162,21 @@
|
||||
return []
|
||||
})
|
||||
|
||||
const {data: hotTopList, refresh: getHotTop} = useAsyncData('hotTop-PopularDrawings-popularDrawings', async () => {
|
||||
if (!projectTypeList.value?.length) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: 'Page Not Found',
|
||||
fatal: true,
|
||||
})
|
||||
}
|
||||
|
||||
const { data: hotTopList, refresh: getHotTop } = useAsyncData('hotTop-PopularDrawings-popularDrawings', async () => {
|
||||
const res = await hotTop({
|
||||
type: query.type,
|
||||
// @ts-ignore
|
||||
projectType: query.projectTypeDay,
|
||||
projectType: query.projectTypeDay || projectTypeList.value[0].id,
|
||||
isDomestic: query.isDomestic || 1,
|
||||
projectTypeTop: query.projectTypeDay,
|
||||
projectTypeTop: query.projectTypeDay || projectTypeList.value?.[0].id,
|
||||
})
|
||||
return res.data || []
|
||||
})
|
||||
@ -197,8 +205,6 @@
|
||||
// })
|
||||
// }
|
||||
|
||||
|
||||
|
||||
const handleHover = (item: ProjectDictNodeVO) => {
|
||||
query.projectTypeDay = item.id || ''
|
||||
if (item.name === '全部分类') return
|
||||
@ -217,8 +223,8 @@
|
||||
watch(
|
||||
() => query.type,
|
||||
async () => {
|
||||
await getParent();
|
||||
await getHotTop();
|
||||
await getParent()
|
||||
await getHotTop()
|
||||
},
|
||||
{
|
||||
// immediate: true,
|
||||
|
||||
Reference in New Issue
Block a user