优化讲解数据请求与缓存管理
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-16 14:43:57 +08:00
parent 72885b7f54
commit d86845afeb
11 changed files with 259 additions and 137 deletions

View File

@@ -77,8 +77,8 @@
<view class="detail-audio-dock-main">
<button
class="detail-audio-play"
:class="{ disabled: audioDockState === 'unavailable' }"
:disabled="audioDockState === 'unavailable'"
:class="{ disabled: audioDockState === 'unavailable' || audioDockState === 'loading' }"
:disabled="audioDockState === 'unavailable' || audioDockState === 'loading'"
:aria-label="detailAudioActionLabel"
@tap="handlePlayAudio"
>
@@ -193,6 +193,11 @@ const detailEntryRequest = ref<{
exhibitId: string
targetType?: AudioPlayTargetType
targetId?: string
hallId?: string
hallName?: string
floorId?: string
floorLabel?: string
poiId?: string
} | null>(null)
const detailTextByLanguage = ref<Record<AudioLanguage, string>>({
'zh-CN': defaultDetail.body,
@@ -478,7 +483,11 @@ onLoad(async (options: any = {}) => {
detailEntryRequest.value = {
exhibitId,
targetType,
targetId
targetId,
hallId: Array.isArray(options.hallId) ? options.hallId[0] : options.hallId,
hallName: Array.isArray(options.hallName) ? options.hallName[0] : options.hallName,
floorId: Array.isArray(options.floorId) ? options.floorId[0] : options.floorId,
poiId: Array.isArray(options.poiId) ? options.poiId[0] : options.poiId
}
await loadExplainDetail(detailEntryRequest.value, lang)
} catch (error) {
@@ -737,7 +746,7 @@ const playDetailAudio = async (audio: AudioItem) => {
}
const handlePlayAudio = async (options: { forceRefresh?: boolean } = {}) => {
if (audioDockState.value === 'unavailable') return
if (audioDockState.value === 'unavailable' || audioDockState.value === 'loading') return
if (isCurrentDetailAudio.value && !options.forceRefresh) {
if (globalAudioPlayer.playing.value) {

View File

@@ -31,7 +31,7 @@ import {
explainUseCase
} from '@/usecases/explainUseCase'
import type {
ExplainBusinessUnit
ExplainGuideStop
} from '@/domain/museum'
import {
normalizeExplainDetailTargetFromGuideStop
@@ -49,8 +49,8 @@ const explainGuideStopItems = ref<ExplainGuideStopSelectItem[]>([])
const explainLoading = ref(false)
const explainError = ref('')
const toGuideStopItems = (unit: ExplainBusinessUnit): ExplainGuideStopSelectItem[] => (
unit.stops.map((stop) => ({
const toGuideStopItems = (stops: ExplainGuideStop[]): ExplainGuideStopSelectItem[] => (
stops.map((stop) => ({
id: stop.id,
name: stop.name,
hallId: stop.hallId,
@@ -99,7 +99,11 @@ onLoad(async (options: any = {}) => {
}
selectedExplainBusinessUnitName.value = unit.name || selectedExplainBusinessUnitName.value
syncPageTitle(selectedExplainBusinessUnitName.value)
explainGuideStopItems.value = toGuideStopItems(unit)
const stops = await explainUseCase.listGuideStopsByBusinessUnit(
selectedExplainHallId.value,
selectedExplainBusinessUnitId.value
)
explainGuideStopItems.value = toGuideStopItems(stops)
} catch (error) {
explainError.value = '讲解点加载失败,请稍后重试'
} finally {
@@ -118,6 +122,10 @@ const handleExplainGuideStopClick = (stop: ExplainGuideStopSelectItem) => {
targetType: target.targetType,
targetId: target.targetId
})
if (stop.hallId) params.set('hallId', stop.hallId)
if (stop.hallName) params.set('hallName', stop.hallName)
if (stop.floorId) params.set('floorId', stop.floorId)
if (stop.poiId) params.set('poiId', stop.poiId)
uni.navigateTo({
url: `/pages/exhibit/detail?${params.toString()}`