feat: 临时改造讲解页方案 B 链路

接入展厅列表、展厅讲解点分组生成临时业务单元,并迁移讲解详情播放正文到新接口链路。
This commit is contained in:
lyf
2026-07-02 00:51:27 +08:00
parent e0aeafe062
commit 9efcef5190
14 changed files with 1429 additions and 288 deletions

View File

@@ -1,4 +1,5 @@
import type {
AudioPlayTargetType,
GuideLocationResolution,
MuseumExhibit,
MuseumHall,
@@ -28,6 +29,8 @@ export interface ExplainCardViewModel {
languageLabel?: string
audioStatus: ExplainAudioStatus
audioStatusText: string
playTargetType?: AudioPlayTargetType
playTargetId?: string
badges: string[]
progress?: number
poiId?: string
@@ -52,7 +55,19 @@ export interface ExplainDetailPageViewModel {
durationLabel?: string
language?: string
unavailableReason?: string
playTargetType?: AudioPlayTargetType
playTargetId?: string
hasText?: boolean
statusText?: string
}
imageStatus?: string
linkedExhibits?: Array<{
id: string
name: string
nameEn?: string
exhibitCode?: string
coverImageUrl?: string
}>
chapters: Array<{
id: string
title: string
@@ -112,10 +127,14 @@ const languageLabelFor = (language?: string) => {
return language || undefined
}
const hasPlayableAudioUrl = (exhibit: MuseumExhibit) => Boolean(exhibit.audioUrl?.trim())
const isAudioReady = (exhibit: MuseumExhibit) => (
exhibit.audioStatus === 'READY'
|| exhibit.audioAvailable === true
|| Boolean(exhibit.audioUrl?.trim())
)
export const toExplainCardViewModel = (exhibit: MuseumExhibit): ExplainCardViewModel => {
const hasPlayableAudio = hasPlayableAudioUrl(exhibit)
const hasPlayableAudio = isAudioReady(exhibit)
const audioStatus: ExplainAudioStatus = hasPlayableAudio ? 'playable' : 'unavailable'
const location = exhibit.location
@@ -135,6 +154,8 @@ export const toExplainCardViewModel = (exhibit: MuseumExhibit): ExplainCardViewM
languageLabel: languageLabelFor(exhibit.audioLanguage),
audioStatus,
audioStatusText: hasPlayableAudio ? '可播放' : '图文讲解',
playTargetType: exhibit.playTargetType,
playTargetId: exhibit.playTargetId,
badges: buildBadges(exhibit),
progress: undefined,
poiId: location?.poiId || exhibit.poiId,
@@ -146,7 +167,7 @@ export const toExplainCardViewModel = (exhibit: MuseumExhibit): ExplainCardViewM
export const toExplainExhibitViewModel = (exhibit: MuseumExhibit): ExplainExhibitViewModel => toExplainCardViewModel(exhibit)
export const toExplainDetailPageViewModel = (exhibit: MuseumExhibit): ExplainDetailPageViewModel => {
const hasPlayableAudio = hasPlayableAudioUrl(exhibit)
const hasPlayableAudio = isAudioReady(exhibit)
const metadataLines = [
exhibit.size ? `展品编号:${exhibit.size}` : '',
exhibit.year ? `年代:${exhibit.year}` : '',
@@ -163,7 +184,10 @@ export const toExplainDetailPageViewModel = (exhibit: MuseumExhibit): ExplainDet
title: exhibit.name,
subtitle: buildSubtitle(exhibit),
contentType: contentTypeFor(exhibit),
coverImages: [exhibit.image || EXHIBIT_PLACEHOLDER_IMAGE].filter(Boolean),
coverImages: [
exhibit.image || EXHIBIT_PLACEHOLDER_IMAGE,
...(exhibit.galleryUrls || [])
].filter(Boolean),
hallId: exhibit.hallId,
hallName: exhibit.hallName,
floorLabel: exhibit.floorLabel,
@@ -176,8 +200,14 @@ export const toExplainDetailPageViewModel = (exhibit: MuseumExhibit): ExplainDet
language: exhibit.audioLanguage,
unavailableReason: hasPlayableAudio
? undefined
: exhibit.audioUnavailableReason || '该展项暂无已发布音频,当前提供图文讲解。'
: exhibit.audioUnavailableReason || '当前语言暂无语音讲解。',
playTargetType: exhibit.playTargetType,
playTargetId: exhibit.playTargetId,
hasText: exhibit.audioHasText,
statusText: hasPlayableAudio ? '可播放' : '图文讲解'
},
imageStatus: exhibit.imageStatus,
linkedExhibits: exhibit.linkedExhibits,
chapters: metadataLines.length
? metadataLines.map((line, index) => ({
id: `${exhibit.id}-metadata-${index}`,