Update guide presentation and route preview gating

This commit is contained in:
lyf
2026-06-24 23:12:44 +08:00
parent 67c6609ae6
commit 1d277eabf0
12 changed files with 560 additions and 142 deletions

View File

@@ -4,6 +4,8 @@ import type {
GuideRouteTarget
} from '@/domain/museum'
import {
applyRouteReadinessGate,
NAV_ROUTE_UNAVAILABLE_MESSAGE,
NAV_ROUTE_READINESS
} from '@/domain/guideReadiness'
import {
@@ -139,20 +141,24 @@ export class StaticGuideRouteRepository implements GuideRouteRepository {
constructor(private readonly provider: StaticNavAssetsProvider = defaultStaticNavAssetsProvider) {}
async getRouteReadiness() {
const manifestReadiness = await this.provider.loadRouteReadiness()
const hardGateReadiness = applyRouteReadinessGate(NAV_ROUTE_READINESS)
if (!hardGateReadiness.ready) return hardGateReadiness
const manifestReadiness = applyRouteReadinessGate(await this.provider.loadRouteReadiness()
.catch(() => NAV_ROUTE_READINESS)
)
if (!manifestReadiness.ready) return manifestReadiness
try {
const dataset = await this.loadDataset()
if (!dataset.nodes.size || !dataset.edges.length || !dataset.anchorsByPoiId.size) {
return createUnavailableReadiness('路线数据不完整,暂不可查看路径')
return createUnavailableReadiness('路线示意数据不完整,当前暂不支持正式导航')
}
return manifestReadiness
return applyRouteReadinessGate(manifestReadiness)
} catch (error) {
return createUnavailableReadiness(error instanceof Error ? error.message : '路线数据加载失败')
return createUnavailableReadiness(error instanceof Error ? error.message : '路线示意数据加载失败')
}
}
@@ -162,6 +168,14 @@ export class StaticGuideRouteRepository implements GuideRouteRepository {
}
async findRoute(startPoiId: string, endPoiId: string) {
const readiness = await this.getRouteReadiness()
if (!readiness.ready) {
throw new GuideRouteError(
'ROUTE_DATA_UNAVAILABLE',
readiness.message || NAV_ROUTE_UNAVAILABLE_MESSAGE
)
}
if (!startPoiId || !endPoiId) {
throw new GuideRouteError('ROUTE_TARGET_MISSING', '请选择起点和终点')
}
@@ -175,11 +189,11 @@ export class StaticGuideRouteRepository implements GuideRouteRepository {
const endAnchor = dataset.anchorsByPoiId.get(endPoiId)
if (!startAnchor) {
throw new GuideRouteError('ROUTE_TARGET_UNANCHORED', '起点暂无可用路锚点')
throw new GuideRouteError('ROUTE_TARGET_UNANCHORED', '起点暂无可用路线示意锚点')
}
if (!endAnchor) {
throw new GuideRouteError('ROUTE_TARGET_UNANCHORED', '终点暂无可用路锚点')
throw new GuideRouteError('ROUTE_TARGET_UNANCHORED', '终点暂无可用路线示意锚点')
}
const searchResult = this.findShortestPath(startAnchor.routeNodeId, endAnchor.routeNodeId)