From ec97f92cdf9321aeede81910310d95e18e985e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=9E=E6=BC=AA?= Date: Sat, 17 May 2025 17:32:23 +0800 Subject: [PATCH] =?UTF-8?q?gl=E5=8D=95=E5=B1=8F=E5=8F=98=E4=B8=89=E5=B1=8F?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E5=8C=BA=E5=B0=BA=E5=AF=B8=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 连漪 --- customappbar/interfaces/custom_app_bar.js | 19 ++++--------------- customappbar/source/custom_app_bar.ets | 13 ++++--------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/customappbar/interfaces/custom_app_bar.js b/customappbar/interfaces/custom_app_bar.js index b509c68..9cc6eb3 100644 --- a/customappbar/interfaces/custom_app_bar.js +++ b/customappbar/interfaces/custom_app_bar.js @@ -148,8 +148,6 @@ export class CustomAppBar extends ViewPU { this.bundleName = ''; this.icon = { 'id': -1, 'type': 20000, params: ['sys.media.ohos_app_icon'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; this.fullContentMarginTop = 0; - this.windowWidth = 0; - this.windowHeight = 0; this.deviceBorderRadius = '0'; this.smListener = mediaquery.matchMediaSync('(0vp this.windowHeight ? this.windowHeight * LG_WIDTH_LIMIT : this.windowWidth * LG_WIDTH_LIMIT; + let displayData = display.getDefaultDisplaySync(); + let windowWidth = px2vp(displayData.width); + let windowHeight = px2vp(displayData.height); + this.containerWidth = windowWidth > windowHeight ? windowHeight * LG_WIDTH_LIMIT : windowWidth * LG_WIDTH_LIMIT; } } } diff --git a/customappbar/source/custom_app_bar.ets b/customappbar/source/custom_app_bar.ets index d094653..85966f9 100644 --- a/customappbar/source/custom_app_bar.ets +++ b/customappbar/source/custom_app_bar.ets @@ -160,8 +160,6 @@ export struct CustomAppBar { @State labelName: string = ''; private icon: Resource | string | PixelMap = $r('sys.media.ohos_app_icon'); private fullContentMarginTop: number = 0; - private windowWidth: number = 0; - private windowHeight: number = 0; private deviceBorderRadius: string = '0'; private smListener: mediaquery.MediaQueryListener = mediaquery.matchMediaSync('(0vp this.windowHeight ? this.windowHeight * LG_WIDTH_LIMIT : this.windowWidth * LG_WIDTH_LIMIT; + let displayData = display.getDefaultDisplaySync(); + let windowWidth = px2vp(displayData.width); + let windowHeight = px2vp(displayData.height); + this.containerWidth = windowWidth > windowHeight ? windowHeight * LG_WIDTH_LIMIT : windowWidth * LG_WIDTH_LIMIT; } } } -- Gitee