@@ -25,7 +25,7 @@
|
||||
{
|
||||
"path": "pages/explain/list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "全部讲解",
|
||||
"navigationBarTitleText": "免费讲解",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<ExplainHallSelect
|
||||
:halls="explainHallItems"
|
||||
stage="hall"
|
||||
force-internal-header
|
||||
:loading="explainLoading"
|
||||
:error="explainError"
|
||||
@hall-click="handleExplainHallClick"
|
||||
@@ -40,6 +39,7 @@ import {
|
||||
type GuideTopTab
|
||||
} from '@/utils/guideTopTabs'
|
||||
import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment'
|
||||
import { syncHostNavigationTitle } from '@/utils/hostNavigationTitle'
|
||||
import { explainGuideStopListUrl } from '@/utils/explainNavigation'
|
||||
|
||||
const explainHallItems = ref<ExplainHallSelectItem[]>([])
|
||||
@@ -218,6 +218,7 @@ const loadExplainHalls = async () => {
|
||||
}
|
||||
|
||||
onLoad(() => {
|
||||
syncHostNavigationTitle('免费讲解')
|
||||
pushExplainListHistory()
|
||||
void loadExplainHalls()
|
||||
})
|
||||
|
||||
@@ -276,6 +276,7 @@ import {
|
||||
type GuideTopTab
|
||||
} from '@/utils/guideTopTabs'
|
||||
import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment'
|
||||
import { syncHostNavigationTitle } from '@/utils/hostNavigationTitle'
|
||||
import {
|
||||
guideUseCase
|
||||
} from '@/usecases/guideUseCase'
|
||||
@@ -419,6 +420,14 @@ let pendingPoiDetailUiContext: Readonly<{
|
||||
|
||||
// 状态
|
||||
const currentTab = ref<GuideTopTab>(initialTopTab())
|
||||
const topTabNavigationTitle = (tab: GuideTopTab) => (
|
||||
tab === 'explain' ? '免费讲解' : '地图导览'
|
||||
)
|
||||
|
||||
watch(currentTab, (tab) => {
|
||||
syncHostNavigationTitle(topTabNavigationTitle(tab))
|
||||
}, { immediate: true })
|
||||
|
||||
const launchOverlayVisible = ref(shouldShowLaunchOverlay())
|
||||
const launchOverlayLeaving = ref(false)
|
||||
const launchProgress = ref(8)
|
||||
|
||||
39
src/utils/hostNavigationTitle.ts
Normal file
39
src/utils/hostNavigationTitle.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment'
|
||||
|
||||
export const MINI_PROGRAM_NAVIGATION_TITLE_MESSAGE = 'museum-guide:navigation-title'
|
||||
|
||||
type MiniProgramBridge = {
|
||||
postMessage?: (options: {
|
||||
data: {
|
||||
type: typeof MINI_PROGRAM_NAVIGATION_TITLE_MESSAGE
|
||||
title: string
|
||||
}
|
||||
}) => void
|
||||
}
|
||||
|
||||
const getMiniProgramBridge = () => {
|
||||
if (typeof window === 'undefined') return undefined
|
||||
|
||||
return (window as Window & {
|
||||
wx?: {
|
||||
miniProgram?: MiniProgramBridge
|
||||
}
|
||||
}).wx?.miniProgram
|
||||
}
|
||||
|
||||
export const syncHostNavigationTitle = (title: string) => {
|
||||
if (typeof document !== 'undefined') document.title = title
|
||||
|
||||
if (typeof uni !== 'undefined' && typeof uni.setNavigationBarTitle === 'function') {
|
||||
uni.setNavigationBarTitle({ title })
|
||||
}
|
||||
|
||||
if (!isEmbeddedInWechatMiniProgram()) return
|
||||
|
||||
getMiniProgramBridge()?.postMessage?.({
|
||||
data: {
|
||||
type: MINI_PROGRAM_NAVIGATION_TITLE_MESSAGE,
|
||||
title
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user