补齐讲解字段映射并优先展示接口展厅图
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-07 01:31:06 +08:00
parent 0ce38b390e
commit 4b03cc281c
9 changed files with 199 additions and 17 deletions

View File

@@ -83,6 +83,8 @@ export interface BackendGuideStop {
id?: string | number | null
name?: string | null
floorId?: string | number | null
mapX?: number | string | null
mapY?: number | string | null
targetType?: string | null
targetId?: string | number | null
coverImageUrl?: string | null
@@ -128,6 +130,7 @@ export interface BackendCatalogLinkedExhibitItem {
code?: string | null
exhibitCode?: string | null
coverImageUrl?: string | null
galleryUrls?: string | string[] | null
sortOrder?: number | null
}
@@ -135,6 +138,10 @@ export interface BackendCatalogStopItem {
stopId?: string | number | null
id?: string | number | null
outlineId?: string | number | null
poiId?: string | number | null
floorId?: string | number | null
mapX?: number | string | null
mapY?: number | string | null
name?: string | null
guideLevel?: string | null
description?: string | null
@@ -168,7 +175,7 @@ const firstText = (...values: Array<string | number | null | undefined>) => (
.find(Boolean) || ''
)
const parseGalleryUrls = (value: BackendExhibit['galleryUrls']) => {
const parseGalleryUrls = (value: BackendExhibit['galleryUrls'] | string[]) => {
if (!value) return []
if (Array.isArray(value)) return value.map(String).filter(Boolean)
@@ -308,8 +315,11 @@ const toCatalogLinkedExhibitSummary = (source: BackendCatalogLinkedExhibitItem)
id,
name: firstText(source.name, source.exhibitCode, source.code, `展品 ${id}`),
nameEn: firstText(source.nameEn) || undefined,
code: firstText(source.code, source.exhibitCode) || undefined,
exhibitCode: firstText(source.exhibitCode, source.code) || undefined,
coverImageUrl: normalizeSameOriginPublicUrl(firstText(source.coverImageUrl)) || undefined
coverImageUrl: normalizeSameOriginPublicUrl(firstText(source.coverImageUrl)) || undefined,
galleryUrls: parseGalleryUrls(source.galleryUrls),
sortOrder: normalizeNumber(source.sortOrder)
}
}
@@ -331,7 +341,7 @@ export const toCatalogGuideStop = (
name: firstText(source.name, `讲解点${id}`),
hallId: hall?.id,
hallName: hall?.name,
floorId: hall?.floorId,
floorId: stringifyId(source.floorId) || hall?.floorId,
targetType: playTargetType,
targetId: playTargetId,
coverImageUrl: canUseStopImage
@@ -342,6 +352,9 @@ export const toCatalogGuideStop = (
audioStatus: normalizeCatalogAudioStatus(source.audioStatus),
supportedLanguages: normalizeSupportedLanguages(source.supportedLanguages),
hasTextRecord: source.hasTextRecord === true,
poiId: stringifyId(source.poiId) || undefined,
mapX: normalizeNumber(source.mapX),
mapY: normalizeNumber(source.mapY),
outlineId: stringifyId(source.outlineId) || outline?.id,
outlineName: outline?.name,
sort: typeof source.sort === 'number' ? source.sort : undefined,
@@ -374,6 +387,10 @@ export const toCatalogMuseumExhibitFromStop = (
image: stop.coverImageUrl || undefined,
description: stop.description || linkedPrimary?.name || '该讲解点暂无简介。',
tags: [stop.outlineName, linkedPrimary?.exhibitCode].filter(Boolean) as string[],
poiId: stop.poiId,
sourcePoiId: stop.poiId,
mapX: stop.mapX,
mapY: stop.mapY,
guideTitle: stop.name,
guideText: stop.description,
audioAvailable: audioReady,
@@ -611,6 +628,8 @@ export const toBackendGuideStop = (source: BackendGuideStop): ExplainGuideStop |
description: firstText(source.description) || undefined,
hasAudio: source.hasAudio === true,
poiId: stringifyId(source.poiId) || undefined,
mapX: normalizeNumber(source.mapX),
mapY: normalizeNumber(source.mapY),
outlineId: stringifyId(source.outlineId) || undefined,
outlineName: firstText(source.outlineName) || undefined,
sort: typeof source.sort === 'number' ? source.sort : undefined

View File

@@ -9,8 +9,11 @@ export interface BackendGuideStopLinkedExhibit {
id?: string | number | null
name?: string | null
nameEn?: string | null
code?: string | null
exhibitCode?: string | null
coverImageUrl?: string | null
galleryUrls?: string | string[] | null
sortOrder?: number | string | null
}
export interface BackendGuideStopInfo {
@@ -19,6 +22,10 @@ export interface BackendGuideStopInfo {
targetId?: string | number | null
resolvedStopId?: string | number | null
stopId?: string | number | null
poiId?: string | number | null
floorId?: string | number | null
mapX?: number | string | null
mapY?: number | string | null
lang?: string | null
title?: string | null
description?: string | null
@@ -74,8 +81,11 @@ export interface GuideStopLinkedExhibit {
id: string
name: string
nameEn?: string
code?: string
exhibitCode?: string
coverImageUrl?: string
galleryUrls?: string[]
sortOrder?: number
}
export interface GuideStopInfo {
@@ -83,6 +93,10 @@ export interface GuideStopInfo {
targetType: AudioPlayTargetType
targetId: string
resolvedStopId?: string
poiId?: string
floorId?: string
mapX?: number
mapY?: number
lang: 'zh-CN' | 'en-US'
title: string
description?: string
@@ -156,7 +170,7 @@ const normalizeLanguage = (value: string | null | undefined): 'zh-CN' | 'en-US'
value === 'en-US' ? 'en-US' : 'zh-CN'
)
const parseGalleryUrls = (value: BackendGuideStopInfo['galleryUrls']) => {
const parseGalleryUrls = (value: BackendGuideStopInfo['galleryUrls'] | BackendGuideStopLinkedExhibit['galleryUrls']) => {
if (!value) return []
if (Array.isArray(value)) {
return value.map((entry) => normalizeSameOriginPublicUrl(String(entry))).filter(Boolean)
@@ -192,10 +206,13 @@ const normalizeLinkedExhibits = (items: BackendGuideStopLinkedExhibit[] | null |
return {
id,
name: item.name?.trim() || item.exhibitCode?.trim() || `展品 ${id}`,
name: item.name?.trim() || item.exhibitCode?.trim() || item.code?.trim() || `展品 ${id}`,
nameEn: item.nameEn?.trim() || undefined,
exhibitCode: item.exhibitCode?.trim() || undefined,
coverImageUrl: normalizeSameOriginPublicUrl(item.coverImageUrl) || undefined
code: item.code?.trim() || item.exhibitCode?.trim() || undefined,
exhibitCode: item.exhibitCode?.trim() || item.code?.trim() || undefined,
coverImageUrl: normalizeSameOriginPublicUrl(item.coverImageUrl) || undefined,
galleryUrls: parseGalleryUrls(item.galleryUrls),
sortOrder: normalizeNumber(item.sortOrder)
}
})
.filter(Boolean) as GuideStopLinkedExhibit[]
@@ -225,6 +242,10 @@ export const toGuideStopInfo = (
targetType,
targetId,
resolvedStopId: stringifyId(source.resolvedStopId) || stringifyId(source.stopId) || undefined,
poiId: stringifyId(source.poiId) || undefined,
floorId: stringifyId(source.floorId) || undefined,
mapX: normalizeNumber(source.mapX),
mapY: normalizeNumber(source.mapY),
lang: normalizeLanguage(source.lang || fallback.lang),
title: source.title?.trim() || '讲解内容',
description: source.description?.trim() || undefined,