From 118c798e97171ca31da3eef2265e786fe5665568 Mon Sep 17 00:00:00 2001 From: liugang9704 <2745340733@qq.com> Date: Fri, 19 Sep 2025 09:37:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0try/catch?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/entryability/EntryAbility.ets | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 656c020..c7acbe9 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -16,12 +16,18 @@ import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; const DOMAIN = 0x0000; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (error) { + let err = error as BusinessError; + hilog.error(DOMAIN, 'testTag', `setColorMode failed. code=${err.code}, message=${err.message}`); + } hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -40,9 +46,14 @@ export default class EntryAbility extends UIAbility { } hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); }); - let windowClass: window.Window = windowStage.getMainWindowSync(); - let isLayoutFullScreen = true; - windowClass.setWindowLayoutFullScreen(isLayoutFullScreen); + try { + let windowClass: window.Window = windowStage.getMainWindowSync(); + let isLayoutFullScreen = true; + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen); + } catch (error) { + let err = error as BusinessError; + hilog.error(DOMAIN, 'testTag', `setColorMode failed. code=${err.code}, message=${err.message}`); + } } onWindowStageDestroy(): void { -- Gitee From 144c7c7afbf857e312becb61bc5872a228878563 Mon Sep 17 00:00:00 2001 From: liugang9704 <2745340733@qq.com> Date: Mon, 22 Sep 2025 15:26:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/CommentList.ets | 13 +++++++++++++ entry/src/main/resources/base/element/string.json | 4 ++++ entry/src/main/resources/en_US/element/string.json | 4 ++++ entry/src/main/resources/zh_CN/element/string.json | 4 ++++ 4 files changed, 25 insertions(+) diff --git a/entry/src/main/ets/pages/CommentList.ets b/entry/src/main/ets/pages/CommentList.ets index 1162aeb..66d4bb1 100644 --- a/entry/src/main/ets/pages/CommentList.ets +++ b/entry/src/main/ets/pages/CommentList.ets @@ -15,6 +15,8 @@ import { NavigationDialog } from './NavigationDialog'; import { hilog } from '@kit.PerformanceAnalysisKit'; +import { PromptAction } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; class Person { image: ResourceStr = ''; @@ -78,6 +80,9 @@ let personList: Array = [ @Component export struct CommentList { + uiContext: UIContext = this.getUIContext(); + promptAction: PromptAction = this.uiContext.getPromptAction(); + private operateButtonIcons: Resource[] = [ $r('app.media.paper_plane') ] @@ -122,6 +127,14 @@ export struct CommentList { .align(Alignment.Start) .backgroundColor('rgba(0, 0, 0, 0.05)') .fontColor('rgba(0, 0, 0, 0.6)') + .onClick(()=>{ + this.promptAction.openToast({ + message: '仅作UI展示', + duration: 3000, + }).catch((error: BusinessError) => { + hilog.error(0x0000,'CommentList',`openToast error code is ${error.code}, message is ${error.message}`); + }) + }) ForEach(this.operateButtonIcons, (icon: Resource) => { Image(icon) .width(24) diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index d9b880b..bda13fa 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -291,6 +291,10 @@ { "name": "reply", "value": "Reply" + }, + { + "name": "ui_display", + "value": "Only for UI display" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index 579b3b4..9dad291 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -291,6 +291,10 @@ { "name": "reply", "value": "Reply" + }, + { + "name": "ui_display", + "value": "Only for UI display" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index 8a8c5b1..7a3b551 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -291,6 +291,10 @@ { "name": "reply", "value": "回复" + }, + { + "name": "ui_display", + "value": "仅作UI展示" } ] } \ No newline at end of file -- Gitee From ea3759af1f6f4e32aa916348c754d4cf98d1d996 Mon Sep 17 00:00:00 2001 From: liugang9704 <2745340733@qq.com> Date: Mon, 22 Sep 2025 15:26:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/CommentList.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entry/src/main/ets/pages/CommentList.ets b/entry/src/main/ets/pages/CommentList.ets index 66d4bb1..59db2d7 100644 --- a/entry/src/main/ets/pages/CommentList.ets +++ b/entry/src/main/ets/pages/CommentList.ets @@ -129,7 +129,7 @@ export struct CommentList { .fontColor('rgba(0, 0, 0, 0.6)') .onClick(()=>{ this.promptAction.openToast({ - message: '仅作UI展示', + message: $r('app.string.ui_display'), duration: 3000, }).catch((error: BusinessError) => { hilog.error(0x0000,'CommentList',`openToast error code is ${error.code}, message is ${error.message}`); -- Gitee