From 233a467167e2b363098cc7fa63e7f26d1d15507b Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期日, 27 四月 2025 16:23:28 +0800
Subject: [PATCH] 线索任务

---
 miniprogram_npm/tdesign-miniprogram/navbar/navbar.js |   46 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/miniprogram_npm/tdesign-miniprogram/navbar/navbar.js b/miniprogram_npm/tdesign-miniprogram/navbar/navbar.js
index d5b4e61..0355032 100644
--- a/miniprogram_npm/tdesign-miniprogram/navbar/navbar.js
+++ b/miniprogram_npm/tdesign-miniprogram/navbar/navbar.js
@@ -5,6 +5,7 @@
     return c > 3 && r && Object.defineProperty(target, key, r), r;
 };
 import { SuperComponent, wxComponent } from '../common/src/index';
+import { getRect } from '../common/utils';
 import config from '../common/config';
 import props from './props';
 const { prefix } = config;
@@ -14,6 +15,8 @@
         super(...arguments);
         this.externalClasses = [
             `${prefix}-class`,
+            `${prefix}-class-placeholder`,
+            `${prefix}-class-content`,
             `${prefix}-class-title`,
             `${prefix}-class-left`,
             `${prefix}-class-center`,
@@ -24,7 +27,6 @@
         ];
         this.timer = null;
         this.options = {
-            addGlobalClass: true,
             multipleSlots: true,
         };
         this.properties = props;
@@ -62,8 +64,35 @@
             classPrefix: name,
             boxStyle: '',
             showTitle: '',
+            hideLeft: false,
+            hideCenter: false,
         };
         this.methods = {
+            queryElements(capsuleRect) {
+                Promise.all([
+                    getRect(this, `.${this.data.classPrefix}__left`),
+                    getRect(this, `.${this.data.classPrefix}__center`),
+                ]).then(([leftRect, centerRect]) => {
+                    if (leftRect.right > capsuleRect.left) {
+                        this.setData({
+                            hideLeft: true,
+                            hideCenter: true,
+                        });
+                    }
+                    else if (centerRect.right > capsuleRect.left) {
+                        this.setData({
+                            hideLeft: false,
+                            hideCenter: true,
+                        });
+                    }
+                    else {
+                        this.setData({
+                            hideLeft: false,
+                            hideCenter: false,
+                        });
+                    }
+                });
+            },
             goBack() {
                 const { delta } = this.data;
                 const that = this;
@@ -95,23 +124,30 @@
         wx.getSystemInfo({
             success: (res) => {
                 const boxStyleList = [];
-                const { statusBarHeight } = wx.getSystemInfoSync();
-                boxStyleList.push(`--td-navbar-padding-top:${statusBarHeight}px`);
+                boxStyleList.push(`--td-navbar-padding-top: ${res.statusBarHeight}px`);
                 if (rect && (res === null || res === void 0 ? void 0 : res.windowWidth)) {
-                    boxStyleList.push(`--td-navbar-right:${res.windowWidth - rect.left}px`);
+                    boxStyleList.push(`--td-navbar-right: ${res.windowWidth - rect.left}px`);
                 }
                 boxStyleList.push(`--td-navbar-capsule-height: ${rect.height}px`);
                 boxStyleList.push(`--td-navbar-capsule-width: ${rect.width}px`);
-                boxStyleList.push(`--td-navbar-height: ${(rect.top - statusBarHeight) * 2 + rect.height}px`);
+                boxStyleList.push(`--td-navbar-height: ${(rect.top - res.statusBarHeight) * 2 + rect.height}px`);
                 this.setData({
                     boxStyle: `${boxStyleList.join('; ')}`,
                 });
+                if (wx.onMenuButtonBoundingClientRectWeightChange) {
+                    wx.onMenuButtonBoundingClientRectWeightChange((res) => this.queryElements(res));
+                }
             },
             fail: (err) => {
                 console.error('navbar 鑾峰彇绯荤粺淇℃伅澶辫触', err);
             },
         });
     }
+    detached() {
+        if (wx.offMenuButtonBoundingClientRectWeightChange) {
+            wx.offMenuButtonBoundingClientRectWeightChange((res) => this.queryElements(res));
+        }
+    }
 };
 Navbar = __decorate([
     wxComponent()

--
Gitblit v1.9.3