From 793637f9e115a0e8267ee111d5c50d57e664b929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Sat, 27 Dec 2025 10:21:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BE=A7=E8=BE=B9=E6=A0=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E8=BE=B9=E7=95=8C=E6=A3=80=E6=B5=8B=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用百分比计算边界,兼容所有设备 - 按钮活动范围:屏幕顶部10%到底部75% - 移除复杂的safeArea判断,提高健壮性 --- pages/index/index.js | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index 2baa48b..f9638e8 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -149,29 +149,16 @@ Page({ let newTop = this.data.sidebarBtnTop + diffY * 2; const systemInfo = wx.getSystemInfoSync(); - const screenHeight = systemInfo.screenHeight; - const safeArea = systemInfo.safeArea; + const screenHeight = systemInfo.screenHeight * 2; const btnHeight = 90; - const margin = 20; - const tabBarHeight = 70; - let minTop, maxTop; + const minTop = screenHeight * 0.1; + const maxTop = screenHeight * 0.75; - if (safeArea) { - minTop = safeArea.top + margin; - maxTop = safeArea.bottom - btnHeight - margin - tabBarHeight; - } else { - minTop = margin; - maxTop = screenHeight - btnHeight - margin - tabBarHeight; - } - - const minTopRpx = minTop * 2; - const maxTopRpx = maxTop * 2; - - if (newTop < minTopRpx) { - newTop = minTopRpx; - } else if (newTop > maxTopRpx) { - newTop = maxTopRpx; + if (newTop < minTop) { + newTop = minTop; + } else if (newTop > maxTop) { + newTop = maxTop; } this.setData({