用 window.innerWidth 代替 window.screen.width,因为 screen 包括了开发工具窗

This commit is contained in:
陆柯 2022-05-28 13:33:35 +08:00
parent 37471f5d3d
commit 4a96e6a66f

View File

@ -97,7 +97,7 @@ export default {
if (pagesJson?.topWindow || envar?.Hide_Bars_On_PC) {
// 如果页头不是通过 pagesJson.topWindow 而是作为组件来引入个别页面,那么定义配置参数 Hide_Bars_On_PC 来控制。
if (uni.getSystemInfoSync().model === 'PC') {
if (window.screen.width > (pagesJson?.topWindow?.matchMedia?.minWidth || 0)) {
if (window.innerWidth > (pagesJson?.topWindow?.matchMedia?.minWidth || 0)) {
uni.hideTabBar()
// 不知为何,同一个二级页面,如果第二次进入,就仍然会显示 navibar, 必须通过 setTimeout 执行才能彻底隐藏。
setTimeout(() => {
@ -549,10 +549,10 @@ export default {
}, 1000)
},
// 注意,即使在 PC 上 topWindow 代替了 tabBar 时,从标签页转化而来的菜单页,也是用 switchTab 跳转。
goto_page (pageName, { forget = false, pagesJson = this.pagesJson || wo?.pagesJson } = {}) {
if (pageName) {
if (pagesJson?.tabBar?.list?.find((item) => item?.pagePath?.substr(6) === pageName)) {
// 注意,即使在 PC 上 topWindow 代替了 tabBar 时,从标签页转化而来的菜单页,也是用 switchTab 跳转。
uni.switchTab({ url: pageName })
} else if (forget) {
uni.navigateTo({ url: pageName })
@ -564,4 +564,15 @@ export default {
}
},
next_focus(currentFocus, focusList=this.thisPage().focusList){
if (focusList) {
for (let n in focusList) {
focusList[n]=false
}
setTimeout(()=>{
focusList[(parseInt(currentFocus)+1) % Object.keys(focusList).length]=true
},200) // 如果没有 setTimeout 至少 200ms, 焦点短暂跳到下一个后,又会消失
}
}
}