diff --git a/entry/src/main/ets/application/MailBox.ets b/entry/src/main/ets/application/MailBox.ets index fb8ba8b28544b26e663396d4de2628d2e73851fe..23032f1030f84f2a6e782c788f685562cc295928 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 d854043abf6da13cc5755f7b4ab0eef10145dc9d..103723487f078f817a996339bc7a648d7c76bb3c 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 dd700286229443f1fd1cf28ad9f0c6de9ba0fcc3..51d07b353a509e3d33eb7c8989a7408ef6afb0ea 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 c21e2316e455c5e15de4e093d98cd3a49ad7b781..6e5d7516534af265906667660d0b1689bae3c101 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;