From 3f7de0f25538445accfc01f32f0c0520031e2fa4 Mon Sep 17 00:00:00 2001 From: yangxiang <1223109862@qq.com> Date: Wed, 7 May 2025 18:19:13 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=BA=9F=E5=BC=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 4fb607c..bef4718 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -25,8 +25,8 @@ import { FileNameList } from '../model/FileNameModel'; @Entry @Component struct Index { - private sandboxFilesDir: string = getContext(this).filesDir; - private resMgr: resourceManager.ResourceManager = getContext().resourceManager; + private sandboxFilesDir: string = this.getUIContext().getHostContext()!.filesDir; + private resMgr: resourceManager.ResourceManager = this.getUIContext().getHostContext()!.resourceManager; @Styles customButtonStyle() { @@ -37,7 +37,7 @@ struct Index { customToast(str: string) { Logger.info('show file contents:' + str); try { - promptAction.showToast({ + this.getUIContext().getPromptAction().showToast({ message: str, duration: 2000, bottom: '80vp', @@ -56,7 +56,7 @@ struct Index { Button($r('app.string.button_sandbox')) .customButtonStyle() .onClick(() => { - let content = getContext(this).resourceManager + let content = this.getUIContext().getHostContext()!.resourceManager .getStringSync($r('app.string.file_content_sandbox')); FileAccess.transferSandboxPath(this.sandboxFilesDir, content); this.customToast(readFile(this.sandboxFilesDir + '/' + FileNameList[0])); @@ -65,7 +65,7 @@ struct Index { Button($r('app.string.button_splice')) .customButtonStyle() .onClick(() => { - let content = getContext(this).resourceManager + let content = this.getUIContext().getHostContext()!.resourceManager .getStringSync($r('app.string.file_content_splice')); FileAccess.splicePath(content); this.customToast(readFile(this.sandboxFilesDir + '/' + FileNameList[1])); @@ -81,13 +81,13 @@ struct Index { Button($r('app.string.button_create')) .customButtonStyle() .onClick(async () => { - CreateFileByPicker(getContext(this), FileNameList[3]); + CreateFileByPicker(this.getUIContext().getHostContext()!, FileNameList[3]); }) Button($r('app.string.button_write')) .customButtonStyle() .onClick(async () => { - let content = getContext(this).resourceManager + let content = this.getUIContext().getHostContext()!.resourceManager .getStringSync($r('app.string.file_content_picker')); await WriteFileByPicker(content).then((value: string) => { setTimeout(() => { -- Gitee