Update API request formatting and error handling

This commit is contained in:
wangqiao
2025-08-27 16:24:22 +08:00
parent 600c3e9f18
commit dc628e3494
2 changed files with 20 additions and 14 deletions

View File

@ -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 })
}
/**

View File

@ -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,