This commit is contained in:
@@ -383,7 +383,7 @@ const topTabFromHash = () => {
|
|||||||
const launchOverlayMinDisplayMs = 700
|
const launchOverlayMinDisplayMs = 700
|
||||||
const launchOverlayGuideTimeoutMs = 12000
|
const launchOverlayGuideTimeoutMs = 12000
|
||||||
const launchOverlayNonGuideTimeoutMs = 900
|
const launchOverlayNonGuideTimeoutMs = 900
|
||||||
const launchOverlayDefaultText = '正在进入自然导览'
|
const launchOverlayDefaultText = '正在进入智能导览'
|
||||||
|
|
||||||
const shouldShowLaunchOverlay = () => {
|
const shouldShowLaunchOverlay = () => {
|
||||||
if (typeof window === 'undefined') return false
|
if (typeof window === 'undefined') return false
|
||||||
|
|||||||
@@ -133,13 +133,9 @@ const dedupePoisById = (pois: MuseumPoi[]) => {
|
|||||||
|
|
||||||
const getPoiSpaceIdentity = (poi: MuseumPoi) => poi.sourceSpaceId || poi.spaceId || ''
|
const getPoiSpaceIdentity = (poi: MuseumPoi) => poi.sourceSpaceId || poi.spaceId || ''
|
||||||
|
|
||||||
const getPoiLookupIdentities = (id: string) => {
|
const getPoiSourceLookupIdentity = (id: string) => (
|
||||||
const normalizedId = id.trim()
|
id.trim().replace(/^(?:hall|space)-/, '')
|
||||||
return new Set([
|
)
|
||||||
normalizedId,
|
|
||||||
normalizedId.replace(/^(?:hall|space)-/, '')
|
|
||||||
].filter(Boolean))
|
|
||||||
}
|
|
||||||
|
|
||||||
const mergePoiCategories = (...categoryGroups: MuseumCategory[][]) => {
|
const mergePoiCategories = (...categoryGroups: MuseumCategory[][]) => {
|
||||||
const seenIds = new Set<string>()
|
const seenIds = new Set<string>()
|
||||||
@@ -553,12 +549,18 @@ export class SgsSdkGuideRepository implements GuideRepository {
|
|||||||
|
|
||||||
async getPoiById(id: string) {
|
async getPoiById(id: string) {
|
||||||
const pois = await this.searchPois()
|
const pois = await this.searchPois()
|
||||||
const lookupIdentities = getPoiLookupIdentities(id)
|
const normalizedId = id.trim()
|
||||||
return pois.find((poi) => (
|
const exactPoi = pois.find((poi) => poi.id === normalizedId)
|
||||||
lookupIdentities.has(poi.id)
|
if (exactPoi) return exactPoi
|
||||||
|| lookupIdentities.has(poi.spaceId || '')
|
|
||||||
|| lookupIdentities.has(poi.sourceSpaceId || '')
|
const sourceIdentity = getPoiSourceLookupIdentity(normalizedId)
|
||||||
|
const sourcePoi = sourceIdentity
|
||||||
|
? pois.find((poi) => (
|
||||||
|
poi.spaceId === sourceIdentity
|
||||||
|
|| poi.sourceSpaceId === sourceIdentity
|
||||||
))
|
))
|
||||||
|
: undefined
|
||||||
|
return sourcePoi
|
||||||
|| findPoiByNavIdNameFallback(pois, id)
|
|| findPoiByNavIdNameFallback(pois, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,6 +167,34 @@ describe('SgsSdkGuideRepository 点位搜索', () => {
|
|||||||
expect(renderPois.some((poi) => poi.id === fallbackTheater?.id)).toBe(true)
|
expect(renderPois.some((poi) => poi.id === fallbackTheater?.id)).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('精确空间 ID 与普通点位 ID 同号时不会定位到错误点位', async () => {
|
||||||
|
vi.spyOn(console, 'warn').mockImplementation(() => undefined)
|
||||||
|
const provider = createProvider({
|
||||||
|
getFloorPois: vi.fn().mockResolvedValue([{
|
||||||
|
...floorPoi,
|
||||||
|
id: '42',
|
||||||
|
name: '普通卫生间'
|
||||||
|
}]),
|
||||||
|
getFloorSpaces: vi.fn().mockResolvedValue([{
|
||||||
|
id: '42',
|
||||||
|
name: '公共空间',
|
||||||
|
type: 'public_area',
|
||||||
|
floorId: '101',
|
||||||
|
boundaryWkt: 'POLYGON((0 0, 8 0, 8 8, 0 8, 0 0))'
|
||||||
|
}])
|
||||||
|
})
|
||||||
|
const repository = new SgsSdkGuideRepository(provider)
|
||||||
|
|
||||||
|
await expect(repository.getPoiById('space-42')).resolves.toMatchObject({
|
||||||
|
id: 'space-42',
|
||||||
|
name: '公共空间'
|
||||||
|
})
|
||||||
|
await expect(repository.getPoiById('42')).resolves.toMatchObject({
|
||||||
|
id: '42',
|
||||||
|
name: '普通卫生间'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('相同模型对象名不会删除不同稳定 ID 和坐标的普通点位', async () => {
|
it('相同模型对象名不会删除不同稳定 ID 和坐标的普通点位', async () => {
|
||||||
const provider = createProvider({
|
const provider = createProvider({
|
||||||
getFloorSpaces: vi.fn().mockResolvedValue([]),
|
getFloorSpaces: vi.fn().mockResolvedValue([]),
|
||||||
|
|||||||
Reference in New Issue
Block a user