feat: switch explain flow to API data
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-06 23:18:51 +08:00
parent e2b6a331ba
commit 50902eca82
21 changed files with 1417 additions and 632 deletions

View File

@@ -61,6 +61,9 @@ export interface ExplainDetailPageViewModel {
statusText?: string
}
imageStatus?: string
linkedExhibitCount?: number
isSharedStop?: boolean
linkedExhibitStatusText?: string
linkedExhibits?: Array<{
id: string
name: string
@@ -128,9 +131,9 @@ const languageLabelFor = (language?: string) => {
}
const isAudioReady = (exhibit: MuseumExhibit) => (
exhibit.audioStatus === 'READY'
|| exhibit.audioAvailable === true
|| Boolean(exhibit.audioUrl?.trim())
exhibit.audioStatus
? exhibit.audioStatus === 'READY'
: exhibit.audioAvailable === true || Boolean(exhibit.audioUrl?.trim())
)
export const toExplainCardViewModel = (exhibit: MuseumExhibit): ExplainCardViewModel => {
@@ -153,7 +156,7 @@ export const toExplainCardViewModel = (exhibit: MuseumExhibit): ExplainCardViewM
audioDuration: exhibit.audioDuration,
languageLabel: languageLabelFor(exhibit.audioLanguage),
audioStatus,
audioStatusText: hasPlayableAudio ? '可播放' : '图文讲解',
audioStatusText: hasPlayableAudio ? '可播放' : exhibit.audioUnavailableReason || '当前语言暂无语音讲解',
playTargetType: exhibit.playTargetType,
playTargetId: exhibit.playTargetId,
badges: buildBadges(exhibit),
@@ -168,6 +171,14 @@ export const toExplainExhibitViewModel = (exhibit: MuseumExhibit): ExplainExhibi
export const toExplainDetailPageViewModel = (exhibit: MuseumExhibit): ExplainDetailPageViewModel => {
const hasPlayableAudio = isAudioReady(exhibit)
const linkedExhibitCount = typeof exhibit.linkedExhibitCount === 'number'
? exhibit.linkedExhibitCount
: exhibit.linkedExhibits?.length
const linkedExhibitStatusText = linkedExhibitCount
? exhibit.isSharedStop
? `${linkedExhibitCount} 件展品共用此讲解点`
: `关联 ${linkedExhibitCount} 件展品`
: undefined
const metadataLines = [
exhibit.size ? `展品编号:${exhibit.size}` : '',
exhibit.year ? `年代:${exhibit.year}` : '',
@@ -204,9 +215,12 @@ export const toExplainDetailPageViewModel = (exhibit: MuseumExhibit): ExplainDet
playTargetType: exhibit.playTargetType,
playTargetId: exhibit.playTargetId,
hasText: exhibit.audioHasText,
statusText: hasPlayableAudio ? '可播放' : '图文讲解'
statusText: hasPlayableAudio ? '可播放' : '当前语言暂无语音讲解'
},
imageStatus: exhibit.imageStatus,
linkedExhibitCount,
isSharedStop: exhibit.isSharedStop,
linkedExhibitStatusText,
linkedExhibits: exhibit.linkedExhibits,
chapters: metadataLines.length
? metadataLines.map((line, index) => ({