增加发布协议确认配置

This commit is contained in:
yml2213
2026-06-07 21:14:49 +08:00
parent 954c3d6be3
commit eebd2d3b04
19 changed files with 760 additions and 13 deletions
@@ -87,6 +87,16 @@ export interface PublishSalePriceConfig {
ratio_adjustment_rules: PublishSaleRatioAdjustmentRule[]
}
export interface AgreementContent {
title: string
content: string
}
export interface ListingPublishAgreements {
virtual_asset_sale: AgreementContent
seller_agreement: AgreementContent
}
export interface ListingPublishOptions {
server_options: string[]
face_options: string[]
@@ -158,11 +168,27 @@ export const emptyListingSalePriceConfig: PublishSalePriceConfig = {
],
}
export const emptyListingPublishAgreements: ListingPublishAgreements = {
virtual_asset_sale: {
title: '虚拟资产出售协议',
content: '',
},
seller_agreement: {
title: '号主协议',
content: '',
},
}
export async function fetchListingPublishOptions() {
const { data } = await apiClient.get<ApiResponse<ListingPublishOptions>>('/listing-publish-options')
return mergeListingPublishOptions(data.data)
}
export async function fetchListingPublishAgreements() {
const { data } = await apiClient.get<ApiResponse<ListingPublishAgreements>>('/listing-publish-agreements')
return mergeListingPublishAgreements(data.data)
}
export async function fetchListingSalePriceConfig() {
const { data } = await apiClient.get<ApiResponse<PublishSalePriceConfig>>('/listing-sale-price-config')
return mergeListingSalePriceConfig(data.data)
@@ -193,6 +219,20 @@ export function mergeListingSalePriceConfig(options?: Partial<PublishSalePriceCo
return normalizeSalePriceConfig(options)
}
export function mergeListingPublishAgreements(options?: Partial<ListingPublishAgreements>): ListingPublishAgreements {
return {
virtual_asset_sale: normalizeAgreementContent(options?.virtual_asset_sale, emptyListingPublishAgreements.virtual_asset_sale),
seller_agreement: normalizeAgreementContent(options?.seller_agreement, emptyListingPublishAgreements.seller_agreement),
}
}
function normalizeAgreementContent(value: unknown, fallback: AgreementContent): AgreementContent {
const row = isRecord(value) ? value : {}
const title = typeof row.title === 'string' && row.title.trim() ? row.title.trim() : fallback.title
const content = typeof row.content === 'string' && row.content.trim() ? row.content.trim() : fallback.content
return { title, content }
}
function normalizeStringList(values?: unknown[]) {
return Array.isArray(values)
? values.map((item) => (typeof item === 'string' ? item.trim() : '')).filter(Boolean)
@@ -41,6 +41,8 @@ export interface ListingPayload {
screenshot_urls: string[]
price: number
deposit_amount: number
agreed_virtual_asset_sale: boolean
agreed_seller_agreement: boolean
}
export interface PublicListingQuery {