fix(listings): 首页无论是否可修改游戏名都展示该字段

号主选择「否」时买家也能在商品卡片上看到,避免只展示「是」造成信息缺失。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-10-01 16:06:15 +08:00
co-authored by Cursor
parent 2a76d59a30
commit a1008f7e6a
2 changed files with 25 additions and 4 deletions
@@ -1,6 +1,10 @@
import { describe, expect, it } from 'vitest'
import { getListingSellerCoinPrice, getListingSellerPrice } from '../listingDisplay'
import {
getListingChips,
getListingSellerCoinPrice,
getListingSellerPrice,
} from '../listingDisplay'
import type { PublicListingItem } from '@/features/listings/api/listings'
function buildListing(assetSummary?: Record<string, unknown>): PublicListingItem {
@@ -62,3 +66,19 @@ describe('号主纯币价格读取', () => {
)
})
})
describe('首页规格芯片', () => {
it('无论是否可以修改游戏名都展示', () => {
const yesChip = getListingChips(buildListing({ can_change_game_name: '是' })).find(
chip => chip.label === '可修改游戏名'
)
const noChip = getListingChips(buildListing({ can_change_game_name: '否' })).find(
chip => chip.label === '可修改游戏名'
)
const missing = getListingChips(buildListing()).find(chip => chip.label === '可修改游戏名')
expect(yesChip).toEqual({ label: '可修改游戏名', value: '是' })
expect(noChip).toEqual({ label: '可修改游戏名', value: '否' })
expect(missing).toBeUndefined()
})
})
+4 -3
View File
@@ -155,9 +155,10 @@ export function getListingChips(item: PublicListingItem): ListingDisplayChip[] {
if (online) {
chips.push({ label: '方便上号', value: online })
}
// 仅在号主确认可修改游戏名时展示。
if (readAssetString(item, 'can_change_game_name') === '是') {
chips.push({ label: '可修改游戏名', value: '是' })
// 号主已填写时,首页同时展示「是」和「否」。
const canChangeGameName = readAssetString(item, 'can_change_game_name')
if (canChangeGameName === '是' || canChangeGameName === '否') {
chips.push({ label: '可修改游戏名', value: canChangeGameName })
}
// 全英雄为必选项,仅在号主勾选「是」时展示
if (readAssetString(item, 'all_hero') === '是') {