From 80dc90be027ee26869c63860b7d6a0759a03546b Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期二, 20 五月 2025 17:33:53 +0800
Subject: [PATCH] fix: 修改首页ui

---
 apps/taro/src/stores/modules/system.ts |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/apps/taro/src/stores/modules/system.ts b/apps/taro/src/stores/modules/system.ts
index 8fdd047..65d531c 100644
--- a/apps/taro/src/stores/modules/system.ts
+++ b/apps/taro/src/stores/modules/system.ts
@@ -1,6 +1,7 @@
 import Taro from '@tarojs/taro';
 import { defineStore } from 'pinia';
 import { store } from '@/stores';
+import { isWeb } from '@/utils/env';
 
 export interface Options {
   path: string;
@@ -68,7 +69,7 @@
       this.screenWidth = info.screenWidth;
 
       this.IPhoneXPadding = info.screenHeight - info.safeArea.bottom;
-      this.navHeight = info.statusBarHeight + this.navigationBarHeight;
+      this.navHeight = (info.statusBarHeight || 0) + this.navigationBarHeight;
 
       this.safeAreaTop = info.safeArea.top;
 
@@ -79,25 +80,29 @@
        */
       this.bottomNavHeight = 118 * scale;
 
-      this.pageHeight = info.screenHeight - this.navHeight - this.IPhoneXPadding; // 鏃犲簳閮╰abber
+      this.pageHeight = info.screenHeight - this.navHeight - (isWeb ? 0 : this.IPhoneXPadding); // 鏃犲簳閮╰abber
       this.pageHeightWithTab = this.pageHeight - this.bottomNavHeight; // 鏈夊簳閮╰abber
     },
 
     setNavigationBarHeight(systemInfo: Taro.getSystemInfoSync.Result) {
-      const { right, height, width, top } = Taro.getMenuButtonBoundingClientRect();
+      try {
+        if (!isWeb) {
+          const { right, height, width, top } = Taro.getMenuButtonBoundingClientRect();
 
-      let navigationBarHeight = 0;
+          this.menuButtonHeight = height;
+          this.menuButtonWidth = width;
+          this.menuButtonTop = top;
+          this.menuButtonRightDistance = systemInfo.screenWidth - right;
+        }
+        let navigationBarHeight = 0;
 
-      if (systemInfo.platform === 'android') {
-        navigationBarHeight = 48;
-      } else {
-        navigationBarHeight = 44;
-      }
-      this.menuButtonHeight = height;
-      this.menuButtonWidth = width;
-      this.menuButtonTop = top;
-      this.menuButtonRightDistance = systemInfo.screenWidth - right;
-      this.navigationBarHeight = navigationBarHeight;
+        if (systemInfo.platform === 'android') {
+          navigationBarHeight = 48;
+        } else {
+          navigationBarHeight = 44;
+        }
+        this.navigationBarHeight = navigationBarHeight;
+      } catch (error) {}
     },
 
     setTabIndex(tabIndex: number) {

--
Gitblit v1.9.1