From 72b805c4996110fe40d50dbc6d584a14626b24b7 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Mon, 7 Sep 2026 17:37:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(types):=20=E4=BF=AE=E5=A4=8D=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=90=8E=E7=9A=84=20Listing=20=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E4=B8=8E=E6=8E=A5=E5=8F=A3=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/features/listings/api/listings.ts | 31 +++---------------- .../listings/composables/useListingQuery.ts | 4 +-- frontend/src/shared/utils/listingDisplay.ts | 2 +- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/frontend/src/features/listings/api/listings.ts b/frontend/src/features/listings/api/listings.ts index 8c20f9b..05b8469 100644 --- a/frontend/src/features/listings/api/listings.ts +++ b/frontend/src/features/listings/api/listings.ts @@ -34,31 +34,8 @@ export interface Listing { updated_at: string } -// 公开商品卡片的最小字段,对应后端 PublicListingListItemDTO。 -export interface PublicListingItem { - id: number - listing_no: string - title: string - game_name: string - server_region: string - login_platform: string - rank_level: string - haf_coin_amount: number - asset_summary?: Record - screenshot_urls?: string[] - cover_url: string - price_cent: number - deposit_amount_cent: number - is_accelerated_sale?: boolean - published_at?: string - created_at: string -} - -// 公开商品详情,对应后端 PublicListingDetailDTO。 -export interface PublicListingDetail extends PublicListingItem { - description: string - screenshot_urls: string[] -} +export type PublicListingItem = Listing +export type PublicListingDetail = Listing export interface ListingPayload { title: string @@ -112,7 +89,7 @@ export interface PublicListingQuery { } export interface PublicListingPage { - items: PublicListingItem[] + items: Listing[] total: number page: number page_size: number @@ -158,7 +135,7 @@ function normalizePublicListingPage( } export async function fetchListing(id: string | number) { - const { data } = await apiClient.get>(`/listings/${id}`) + const { data } = await apiClient.get>(`/listings/${id}`) return data.data } diff --git a/frontend/src/features/listings/composables/useListingQuery.ts b/frontend/src/features/listings/composables/useListingQuery.ts index 9eb91a4..5424116 100644 --- a/frontend/src/features/listings/composables/useListingQuery.ts +++ b/frontend/src/features/listings/composables/useListingQuery.ts @@ -1,5 +1,5 @@ import { ref, onMounted, onBeforeUnmount, watch, type Ref } from 'vue' -import { fetchListingsPage, type PublicListingItem, type PublicListingQuery } from '../api/listings' +import { fetchListingsPage, type Listing, type PublicListingQuery } from '../api/listings' import type { HomeFilters } from './useHomeFilters' const homePageSize = 12 @@ -11,7 +11,7 @@ export function useListingQuery( ) { const loading = ref(false) const loadingMore = ref(false) - const listings = ref([]) + const listings = ref([]) const totalListings = ref(0) const zoneCounts = ref>({}) const currentPage = ref(1) diff --git a/frontend/src/shared/utils/listingDisplay.ts b/frontend/src/shared/utils/listingDisplay.ts index 11676c1..5474e1d 100644 --- a/frontend/src/shared/utils/listingDisplay.ts +++ b/frontend/src/shared/utils/listingDisplay.ts @@ -1,4 +1,4 @@ -import type { PublicListingItem } from '@/features/listings/api/listings' +import type { Listing, PublicListingItem } from '@/features/listings/api/listings' import { centToYuan } from '@/shared/utils/money' export interface ListingDisplayChip {