fix: 在PC端,需要 uni.hideTabBar()
This commit is contained in:
parent
c30c4cc66d
commit
076a42f86f
54
unitool.js
54
unitool.js
@ -75,41 +75,25 @@ export default {
|
|||||||
// document.title = ???
|
// document.title = ???
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// 必须要在有 tab 的页面里 setTabBarItem 才有效果
|
if (uni.getSystemInfoSync().deviceType === 'pc') {
|
||||||
//const midIndex = parseInt(pagesJson?.tabBar?.list?.length/2) // 如果存在midButton,实际上tabBar.list.length必须为偶数。不过为了心安,再parseInt一下。
|
uni.hideTabBar()
|
||||||
pagesJson?.tabBar?.list?.forEach((tab, tabIndex) => {
|
} else {
|
||||||
if (tab.i18nText && tab.i18nText[mylang]) {
|
// 必须要在有 tab 的页面里 setTabBarItem 才有效果
|
||||||
uni.setTabBarItem({
|
//const midIndex = parseInt(pagesJson?.tabBar?.list?.length/2) // 如果存在midButton,实际上tabBar.list.length必须为偶数。不过为了心安,再parseInt一下。
|
||||||
// #ifdef H5
|
pagesJson?.tabBar?.list?.forEach((tab, tabIndex) => {
|
||||||
index: tabIndex, // + ((pagesJson?.tabBar?.midButton?.iconPath && tabIndex >= midIndex)?1:0), // H5 里,如果使用了 midButton,tabBarItem的index出现错位,需hack调整。推测,在H5里 midButton 作为一个普通tab被插入到 tabBar 里,导致 tabBar 的 index 和 pagesJson.tabBar.list 的 index 错位了。[20211031] 注意到,从 HBuilderX 3.2.12.20211029 起,在 H5 里也没有错位了。
|
if (tab.i18nText && tab.i18nText[mylang]) {
|
||||||
// #endif
|
uni.setTabBarItem({
|
||||||
// #ifndef H5
|
// #ifdef H5
|
||||||
index: tabIndex,
|
index: tabIndex, // + ((pagesJson?.tabBar?.midButton?.iconPath && tabIndex >= midIndex)?1:0), // H5 里,如果使用了 midButton,tabBarItem的index出现错位,需hack调整。推测,在H5里 midButton 作为一个普通tab被插入到 tabBar 里,导致 tabBar 的 index 和 pagesJson.tabBar.list 的 index 错位了。[20211031] 注意到,从 HBuilderX 3.2.12.20211029 起,在 H5 里也没有错位了。
|
||||||
// #endif
|
// #endif
|
||||||
text: tab.i18nText[mylang],
|
// #ifndef H5
|
||||||
})
|
index: tabIndex,
|
||||||
}
|
// #endif
|
||||||
})
|
text: tab.i18nText[mylang],
|
||||||
// uni.showTabBar({})
|
})
|
||||||
|
}
|
||||||
// 不再使用 topWindow 方案
|
})
|
||||||
// // #ifdef H5
|
}
|
||||||
// // 响应式方案:仅仅根据当前设备类型,如果是 PC 大屏幕,则始终显示 topWindow 并且隐藏顶部 navibar 和底部 tabBar。
|
|
||||||
// if (pagesJson?.topWindow || !envar?.showBarsOnPC) {
|
|
||||||
// // 如果页头不是通过 pagesJson.topWindow 而是作为组件来引入个别页面,那么定义配置参数 showBarsOnPC 来控制。
|
|
||||||
// if (uni.getSystemInfoSync().deviceType === 'pc') {
|
|
||||||
// if (window.innerWidth > (pagesJson?.topWindow?.matchMedia?.minWidth || 0)) {
|
|
||||||
// uni.hideTabBar()
|
|
||||||
// // 不知为何,同一个二级页面,如果第二次进入,就仍然会显示 navibar, 必须通过 setTimeout 执行才能彻底隐藏。
|
|
||||||
// setTimeout(() => {
|
|
||||||
// document.getElementsByTagName('uni-page-head')?.[0]?.remove()
|
|
||||||
// }, 0)
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// document.getElementsByTagName('uni-top-window')?.[0]?.remove() // 强制隐藏 topWindow,否则在手机浏览器里,topWindow 会遮挡掉 navibar。
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // #endif
|
|
||||||
|
|
||||||
//#ifdef H5
|
//#ifdef H5
|
||||||
//// 微信浏览器里,本身就显示了标题栏,和自有的导航栏形成功能重叠和混淆。
|
//// 微信浏览器里,本身就显示了标题栏,和自有的导航栏形成功能重叠和混淆。
|
||||||
|
Loading…
Reference in New Issue
Block a user