From 2e104b4be564c8e6ceb4ccbdefba0e2c323487f3 Mon Sep 17 00:00:00 2001 From: EasyGuohf <163991322+EasyGuohf@users.noreply.github.com> Date: Tue, 17 Jun 2025 12:22:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E6=8A=98=E5=88=87=E6=8D=A2=E4=BA=8C?= =?UTF-8?q?=E6=8A=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/application/MailBox.ets | 12 +++++++++--- entry/src/main/ets/application/PhotoAlbum.ets | 2 +- entry/src/main/ets/entryability/EntryAbility.ets | 6 ++---- entry/src/main/ets/pages/Index.ets | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/entry/src/main/ets/application/MailBox.ets b/entry/src/main/ets/application/MailBox.ets index fb8ba8b..23032f1 100644 --- a/entry/src/main/ets/application/MailBox.ets +++ b/entry/src/main/ets/application/MailBox.ets @@ -24,10 +24,15 @@ let storage = LocalStorage.getShared(); @Entry(storage) @Component struct MailBox { - @LocalStorageLink('currentBreakPoint') currentBreakPoint: string = 'md'; + @StorageProp('currentBreakPoint') currentBreakPoint: string = 'md'; @State isFold: boolean = false; @State sideBarWidth: number = 304; - @StorageProp('topRectHeight') topRectHeight: number = 0; + @StorageProp('topRectHeight') topRectHeight: number = 0; //showSideBar + @StorageProp('isShowMailSideBar') isShowMailSideBar: boolean = this.currentBreakPoint === 'lg' ? true : false; + + aboutToAppear(): void { + this.isShowMailSideBar = this.currentBreakPoint === 'lg' ? true : false; + } build() { GridRow() { @@ -65,8 +70,9 @@ struct MailBox { width: 24, height: 24 }) - .showSideBar(this.currentBreakPoint === 'lg') + .showSideBar(this.isShowMailSideBar) .onChange((value: boolean) => { + this.isShowMailSideBar = value; this.isFold = value; }) diff --git a/entry/src/main/ets/application/PhotoAlbum.ets b/entry/src/main/ets/application/PhotoAlbum.ets index d854043..1037234 100644 --- a/entry/src/main/ets/application/PhotoAlbum.ets +++ b/entry/src/main/ets/application/PhotoAlbum.ets @@ -25,7 +25,7 @@ let storage = LocalStorage.getShared(); @Component struct PhotoAlbum { @State sideBarStatus: boolean = true; - @LocalStorageLink('currentBreakPoint') currentBreakPoint: string = 'sm'; + @StorageProp ('currentBreakPoint') currentBreakPoint: string = 'sm'; @StorageProp('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; @StorageProp('topRectHeight') topRectHeight: number = 0; diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index dd70028..51d07b3 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -32,10 +32,8 @@ export default class EntryAbility extends UIAbility { } else { newBp = 'lg'; } - if (this.curBp !== newBp) { - this.curBp = newBp; - AppStorage.setOrCreate('currentBreakpoint', this.curBp); - } + this.curBp = newBp; + AppStorage.setOrCreate('currentBreakPoint', this.curBp); } catch (error) { hilog.error(0x0000, 'testTag', `Update breakpoint fail. Cause: ${(error as BusinessError).message}`); } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index c21e231..6e5d751 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -21,7 +21,7 @@ import { BusinessError } from '@kit.BasicServicesKit'; @Entry @Component struct Index { - @StorageProp('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageProp('currentBreakPoint') curBp: string = CommonConstants.BREAK_POINT_SM; @StorageProp('bottomRectHeight') bottomRectHeight: number = 0; @StorageProp('topRectHeight') topRectHeight: number = 0; private routes: Route[] = CommonConstants.ROUTES; -- Gitee