修复 H5 嵌入小程序导航栏冲突
Some checks failed
CI / verify (push) Has been cancelled

- 识别微信小程序 web-view 宿主环境
- 宿主导航存在时隐藏 H5 自绘返回与页面标题
- 收回详情、搜索、讲解列表页面顶部预留空间

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
lyf
2026-07-10 10:57:06 +08:00
parent 8758fe66c6
commit 2a21108157
6 changed files with 93 additions and 18 deletions

View File

@@ -20,7 +20,7 @@
mode="aspectFill"
/>
<view class="hero-image-shade"></view>
<view class="hero-back" @tap.stop="handleBack">
<view v-if="!shouldUseHostNavigation" class="hero-back" @tap.stop="handleBack">
<text class="hero-back-icon"></text>
</view>
<view class="hero-copy">
@@ -128,6 +128,7 @@ import {
import {
EXPLAIN_DETAIL_PLACEHOLDER_IMAGE
} from '@/utils/placeholders'
import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment'
const defaultDetail: ExplainDetailPageViewModel = {
id: '',
@@ -170,6 +171,7 @@ const detailTextLoadedByLanguage = ref<Record<AudioLanguage, boolean>>({
})
// 讲解详情页位置入口暂未开放,避免误导用户进入位置预览流程。
const isLocationActionVisible = false
const shouldUseHostNavigation = computed(() => isEmbeddedInWechatMiniProgram())
const contentLanguageOptions: Array<{
value: AudioLanguage
@@ -208,7 +210,6 @@ const currentAudioTarget = computed(() => ({
lang: selectedAudioLanguage.value
}))
const isCurrentDetailAudio = computed(() => globalAudioPlayer.isCurrentSource(currentAudioTarget.value))
const isCurrentDetailAudioTarget = computed(() => {
const source = globalAudioPlayer.currentSource.value
const targetType = exhibit.value.audio.playTargetType || 'ITEM'
@@ -699,7 +700,7 @@ const handleBack = () => {
.content {
height: 100%;
padding: 84px 20px calc(104px + env(safe-area-inset-bottom));
padding: var(--guide-page-detail-top-padding, 84px) 20px calc(104px + env(safe-area-inset-bottom));
box-sizing: border-box;
}
@@ -967,7 +968,6 @@ const handleBack = () => {
background: rgba(249, 250, 251, 0.96);
}
.location-btn {
height: 52px;
display: flex;

View File

@@ -264,7 +264,7 @@ const handleBack = () => {
.content {
height: 100%;
padding: 84px 20px calc(28px + env(safe-area-inset-bottom));
padding: var(--guide-page-detail-top-padding, 84px) 20px calc(28px + env(safe-area-inset-bottom));
box-sizing: border-box;
}

View File

@@ -1,6 +1,6 @@
<template>
<view class="poi-search-page">
<view class="search-header">
<view class="poi-search-page" :class="{ 'host-navigation': shouldUseHostNavigation }">
<view v-if="!shouldUseHostNavigation" class="search-header">
<view class="search-header-copy">
<text class="page-title">点位搜索</text>
<text class="page-subtitle">Search Museum Locations</text>
@@ -21,11 +21,13 @@
</template>
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue'
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import PoiSearchPanel from '@/components/search/PoiSearchPanel.vue'
import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment'
const initialKeyword = ref('')
const shouldUseHostNavigation = computed(() => isEmbeddedInWechatMiniProgram())
onLoad((options: any) => {
const keyword = typeof options.keyword === 'string'
@@ -119,6 +121,14 @@ onUnmounted(() => {
}
/* #endif */
.poi-search-page.host-navigation {
padding-top: 0;
}
.poi-search-page.host-navigation::before {
display: none;
}
.search-header {
position: relative;
z-index: 1;