Update API request formatting and error handling
This commit is contained in:
@ -15,7 +15,7 @@ import type {
|
||||
* @returns
|
||||
*/
|
||||
export const hotTop = (params: ThotTopReq) => {
|
||||
return useFetchRequest.get<IResponse<ProjectDrawPageRespVO[]>>('/prod-api/app-api/business/app/project-draw/hot-top', { query:params })
|
||||
return useDollarFetchRequest.get<IResponse<ProjectDrawPageRespVO[]>>('/prod-api/app-api/business/app/project-draw/hot-top', { query: params })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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,
|
||||
@ -162,13 +162,21 @@
|
||||
return []
|
||||
})
|
||||
|
||||
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