diff --git a/build-profile.json5 b/build-profile.json5 index 9112e921430528e84202ab51adc032d815bf9ddc..8578ca75f1d246e792d213d7793bc2ef73c62ab6 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -4,18 +4,19 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", - "runtimeOS": "HarmonyOS", + "compatibleSdkVersion": "5.0.4(16)", + "runtimeOS": "HarmonyOS" } ], "buildModeSet": [ { - "name": "debug", + "name": "debug" }, { "name": "release" } - ] + ], + "signingConfigs": [] }, "modules": [ { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 257ddd33ca222d6e5419befe2136678b5a4067c2..fcf3585351b8d6a0f28c78cf8496a3316400e527 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -27,7 +27,7 @@ import Logger from '../common/Logger'; struct Index { private dataPreferences: preferences.Preferences | null = null; private kvManager: distributedKVStore.KVManager | undefined = undefined; - private context = getContext(this) + private context = this.getUIContext().getHostContext()! @Builder NavigationTitle() { @@ -48,7 +48,7 @@ struct Index { .width(328) .height(40) .onClick(() => { - let context = getContext(this) as common.UIAbilityContext; + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; let filesDir = context.filesDir; let file = fs.openSync(filesDir + '/test.txt', fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); let writeLen = fs.writeSync(file.fd, "Try to write str."); @@ -137,8 +137,8 @@ struct Index { }) try { - promptAction.showToast({ - message: getContext(this).resourceManager.getStringSync($r('app.string.message')), + this.getUIContext().getPromptAction().showToast({ + message: this.getUIContext().getHostContext()!.resourceManager.getStringSync($r('app.string.message')), duration: 2000 }); } catch (error) { @@ -149,7 +149,7 @@ struct Index { }) .margin({ bottom: '12' }) - NavRouter() { + Navigation() { Button($r('app.string.tab3')) .width(328) .height(40) @@ -159,7 +159,7 @@ struct Index { Flex({ direction: FlexDirection.Row }) { File(); } - }.title(getContext(this).resourceManager.getStringSync($r('app.string.tab3'))) + }.title(this.getUIContext().getHostContext()!.resourceManager.getStringSync($r('app.string.tab3'))) } } .justifyContent(FlexAlign.End) diff --git a/entry/src/main/ets/view/File.ets b/entry/src/main/ets/view/File.ets index 506f554abde084c16a9de3cd363a46a9f72817f0..a85d0ef26e313ee69a1fe35dae40b2a26aee8d70 100644 --- a/entry/src/main/ets/view/File.ets +++ b/entry/src/main/ets/view/File.ets @@ -25,7 +25,7 @@ export struct File { @State kvStoreList: string = ''; aboutToAppear() { - let context = getContext(this) as common.UIAbilityContext; + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; let filesDir = context.filesDir; let listFileOption: ListFileOptions = { recursion: true,