diff --git a/entry/src/main/ets/application/MailBox.ets b/entry/src/main/ets/application/MailBox.ets index 8d1806adcb80387732f59384924c180efe4f68e8..2cb422547437c3ed7519cf540bada91016eeeb90 100644 --- a/entry/src/main/ets/application/MailBox.ets +++ b/entry/src/main/ets/application/MailBox.ets @@ -16,7 +16,8 @@ import { MailNavigation } from '../common/MailNavigation'; import { MailSideBar } from '../common/MailSideBar'; -let storage = LocalStorage.getShared(); +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); +let storage = uiContext?.getSharedLocalStorage(); @Entry(storage) @Component diff --git a/entry/src/main/ets/application/PhotoAlbum.ets b/entry/src/main/ets/application/PhotoAlbum.ets index 25c8c58591724d18e744e00a85d207b012ae741a..6d93c29657be0e83f80a0122577430a4a7a79805 100644 --- a/entry/src/main/ets/application/PhotoAlbum.ets +++ b/entry/src/main/ets/application/PhotoAlbum.ets @@ -16,7 +16,8 @@ import { PhotoContent } from '../common/PhotoContent'; import { PhotoSideBar } from '../common/PhotoSideBar'; -let storage = LocalStorage.getShared(); +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); +let storage = uiContext?.getSharedLocalStorage(); @Entry(storage) @Component diff --git a/entry/src/main/ets/application/Settings.ets b/entry/src/main/ets/application/Settings.ets index d0304198c219812c37649b82d5dcfedf2715102f..83ef452002b58396c7d572a1784a4437469c1dcb 100644 --- a/entry/src/main/ets/application/Settings.ets +++ b/entry/src/main/ets/application/Settings.ets @@ -16,7 +16,8 @@ import { MainItem } from '../common/SettingItem'; import { WlanItem } from '../common/WlanItem'; -let storage = LocalStorage.getShared(); +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); +let storage = uiContext?.getSharedLocalStorage(); @Entry(storage) @Component diff --git a/entry/src/main/ets/common/PhotoContent.ets b/entry/src/main/ets/common/PhotoContent.ets index 0dd9e78d558ba96351727f69ffef254185476ba7..07925536b9ed8ca48538ef71c8379711457c05d0 100644 --- a/entry/src/main/ets/common/PhotoContent.ets +++ b/entry/src/main/ets/common/PhotoContent.ets @@ -36,7 +36,7 @@ export struct PhotoContent { } onStateChange() { - animateTo({ duration: 300 }, () => { + this.getUIContext().animateTo({ duration: 300 }, () => { if (this.sideBarStatus === true && this.currentBreakPoint !== 'sm') { this.columnsTemplate = '1fr 1fr 1fr'; } else { diff --git a/entry/src/main/ets/common/WlanItem.ets b/entry/src/main/ets/common/WlanItem.ets index 0915894be724a8feb1c138e9c5c93799ac731fba..f062288aa8ae262ca94937b7c0f7f94df75ef287 100644 --- a/entry/src/main/ets/common/WlanItem.ets +++ b/entry/src/main/ets/common/WlanItem.ets @@ -35,7 +35,7 @@ export struct WlanItem { if (this.currentBreakPoint === 'sm') { Image($r('app.media.ic_public_back')).width(24).height(24).margin({ right: 16 }) .onClick(()=>{ - router.back(); + this.getUIContext().getRouter().back(); }) } Text($r('app.string.WLAN')).fontSize(20).fontWeight(FontWeight.Medium) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 45917dc0d77ee7642343f7c7f871849ffa78111a..a8504cba4c3b188d9d03351215647b76b9e7484e 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -36,6 +36,9 @@ export default class EntryAbility extends UIAbility { return; } hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + + let uiContext: UIContext | undefined = windowStage.getMainWindowSync().getUIContext() + AppStorage.setOrCreate('uiContext', uiContext); }); } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 6d80b9468309476c41cf54d0e0e07662c9aaa7d7..cb2552b0569b62fbde3bde2e775d184ac502624e 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -22,15 +22,15 @@ struct Index { Column() { Column() { Button('A+B+C').onClick(() => { - router.pushUrl({ url: "application/MailBox" }) + this.getUIContext().getRouter().pushUrl({ url: "application/MailBox" }) }).type(ButtonType.Normal).borderRadius(5).width(100).id('caseOne') Button('A+C').onClick(() => { - router.pushUrl({ url: "application/PhotoAlbum" }) + this.getUIContext().getRouter().pushUrl({ url: "application/PhotoAlbum" }) }).type(ButtonType.Normal).borderRadius(5).width(100).id('caseTwo') Button('B+C').onClick(() => { - router.pushUrl({ url: "application/Settings" }) + this.getUIContext().getRouter().pushUrl({ url: "application/Settings" }) }).type(ButtonType.Normal).borderRadius(5).width(100).id('caseThree') }.width('100%').height('50%').justifyContent(FlexAlign.SpaceAround) }.width('100%').height('100%')