feat(mobile): 新增解忧商行移动端首页、详情与个人中心

This commit is contained in:
yml2213
2026-10-30 12:26:31 +08:00
parent 97167fa482
commit ef01486e53
14 changed files with 1499 additions and 10 deletions
+13 -1
View File
@@ -1,7 +1,7 @@
import { useQuery } from '@tanstack/react-query'
import { apiClient, unwrapData } from '@/shared/api/client'
import type { ApiResponse, PublicListingPage } from '@/shared/api/types'
import type { ApiResponse, Listing, PublicListingPage } from '@/shared/api/types'
export interface ListingQuery {
page?: number
@@ -30,3 +30,15 @@ export function useListings(query: ListingQuery) {
queryFn: () => fetchListings(query),
})
}
export function fetchListingDetail(id: number | string) {
return unwrapData<Listing>(apiClient.get<ApiResponse<Listing>>(`/listings/${id}`))
}
export function useListingDetail(id?: string) {
return useQuery({
queryKey: ['listing-detail', id],
queryFn: () => fetchListingDetail(id as string),
enabled: Boolean(id),
})
}