接入H5讲解后端数据闭环

This commit is contained in:
lyf
2026-06-30 17:22:20 +08:00
parent 1c2cc788d1
commit e3682ed3ec
13 changed files with 815 additions and 68 deletions

View File

@@ -46,7 +46,7 @@ export class DefaultExplainRepository implements ExplainRepository {
}
getExhibitById(id: string) {
return this.content.getExhibitById(id)
return this.explainContent.getExhibitById?.(id) || this.content.getExhibitById(id)
}
listHalls() {
@@ -81,11 +81,43 @@ export class DefaultExplainRepository implements ExplainRepository {
}
async getTrackByExhibitId(exhibitId: string) {
const detail = await this.getExhibitById(exhibitId).catch(() => null)
if (detail) {
return {
id: `track-${detail.guideContentId || detail.id}`,
exhibitId: detail.id,
hallId: detail.hallId,
title: detail.guideTitle || trackTitleFor(detail),
summary: detail.guideText || detail.description,
mediaId: detail.audioUrl ? `media-${detail.guideContentId || detail.id}` : undefined,
coverImage: detail.image,
poiId: detail.poiId,
floorId: detail.floorId,
available: Boolean(detail.audioUrl) || detail.audioAvailable === true,
playTargetType: detail.playTargetType,
playTargetId: detail.playTargetId
}
}
const tracks = await this.listTracks()
return tracks.find((track) => track.exhibitId === exhibitId) || null
}
async searchExplain(keyword = '') {
if (this.explainContent.searchExplainExhibits) {
const exhibits = await this.explainContent.searchExplainExhibits(keyword)
return exhibits.map<SearchIndexItem>((exhibit) => ({
id: exhibit.id,
name: exhibit.name,
desc: `${exhibit.hallName || '展品讲解'} · ${exhibit.floorLabel || ''}`.trim(),
type: 'exhibit',
exhibitId: exhibit.id,
hallId: exhibit.hallId,
poiId: exhibit.poiId,
floorId: exhibit.floorId
}))
}
const normalizedKeyword = keyword.trim().toLowerCase()
const [exhibits, halls] = await Promise.all([
this.explainContent.listExplainExhibits(),