From 3a485ed5c44a19f805e8e356f5584767acc7d4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E5=8D=93=E4=BC=A6?= <2658469835@qq.com> Date: Thu, 8 May 2025 11:32:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E5=BA=9F=E5=BC=83?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3,api=E5=8D=87=E7=BA=A7(16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 21 ++++++++++++++++++--- entry/src/main/ets/pages/Index.ets | 12 ++++++------ entry/src/main/ets/view/File.ets | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/build-profile.json5 b/build-profile.json5 index 9112e92..5511b5d 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -4,17 +4,32 @@ { "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": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "C:\\Users\\Admin\\.ohos\\config\\default_GenerateSandboxFile_xirgBPu-a8S5zAzC12a8lBqEAxQ01B0NNAQXlHNaEG4=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001B5CBF04BFEB16FA88FB0F73E510943BD24B8A0D7EF1E02E280DC961923B40E9809DE2DCE2C9D5E8", + "profile": "C:\\Users\\Admin\\.ohos\\config\\default_GenerateSandboxFile_xirgBPu-a8S5zAzC12a8lBqEAxQ01B0NNAQXlHNaEG4=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\Admin\\.ohos\\config\\default_GenerateSandboxFile_xirgBPu-a8S5zAzC12a8lBqEAxQ01B0NNAQXlHNaEG4=.p12", + "storePassword": "0000001B58BB214FD8013C486C136F9ECC89BA1FEBC312E3C4CE73DEA2BB820D46BFAC6A7B9798D2C943B6" + } + } ] }, "modules": [ diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 257ddd3..fcf3585 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 506f554..a85d0ef 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, -- Gitee From 1a00fd52b118abee4143556bbf24d39fbf48a778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E5=8D=93=E4=BC=A6?= <2658469835@qq.com> Date: Fri, 23 May 2025 15:25:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=E5=88=A0=E9=99=A4=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/build-profile.json5 b/build-profile.json5 index 5511b5d..8578ca7 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -16,21 +16,7 @@ "name": "release" } ], - "signingConfigs": [ - { - "name": "default", - "type": "HarmonyOS", - "material": { - "certpath": "C:\\Users\\Admin\\.ohos\\config\\default_GenerateSandboxFile_xirgBPu-a8S5zAzC12a8lBqEAxQ01B0NNAQXlHNaEG4=.cer", - "keyAlias": "debugKey", - "keyPassword": "0000001B5CBF04BFEB16FA88FB0F73E510943BD24B8A0D7EF1E02E280DC961923B40E9809DE2DCE2C9D5E8", - "profile": "C:\\Users\\Admin\\.ohos\\config\\default_GenerateSandboxFile_xirgBPu-a8S5zAzC12a8lBqEAxQ01B0NNAQXlHNaEG4=.p7b", - "signAlg": "SHA256withECDSA", - "storeFile": "C:\\Users\\Admin\\.ohos\\config\\default_GenerateSandboxFile_xirgBPu-a8S5zAzC12a8lBqEAxQ01B0NNAQXlHNaEG4=.p12", - "storePassword": "0000001B58BB214FD8013C486C136F9ECC89BA1FEBC312E3C4CE73DEA2BB820D46BFAC6A7B9798D2C943B6" - } - } - ] + "signingConfigs": [] }, "modules": [ { -- Gitee