From 3a4a62f28b4c012c939b8dbd8339a51fa3bd440b Mon Sep 17 00:00:00 2001 From: lloyd <353627866@qq.com> Date: Fri, 19 Sep 2025 20:07:12 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9F=BA=E4=BA=8EWeb=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=AE=9E=E7=8E=B0=E9=9A=8F=E6=9C=BA=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=91=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/VuePage.ets | 29 ++++++++++++++++++---------- entry/src/main/ets/pages/WebPage.ets | 29 +++++++++++++++++----------- hvigor/hvigor-config.json5 | 2 +- oh-package.json5 | 2 +- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/entry/src/main/ets/pages/VuePage.ets b/entry/src/main/ets/pages/VuePage.ets index b36894e..3bb8942 100755 --- a/entry/src/main/ets/pages/VuePage.ets +++ b/entry/src/main/ets/pages/VuePage.ets @@ -14,23 +14,32 @@ */ import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; import { CommonConstant as Const } from '../common/Constant'; import { NavigatorBean } from '../viewmodel/NavigatorBean'; + const uiContext: UIContext | undefined = AppStorage.get('uiContext'); let context = uiContext!.getHostContext()!; + class LinkClass { messageFromHtml(value: string) { - let res = context.resourceManager.getStringSync($r('app.string.congratulate').id); - uiContext!.showAlertDialog!({ - message: res + value, - confirm: { - value: $r('app.string.web_alert_dialog_button_value'), - action: () => { + try { + let res = context.resourceManager.getStringSync($r('app.string.congratulate').id); + uiContext!.showAlertDialog!({ + message: res + value, + confirm: { + value: $r('app.string.web_alert_dialog_button_value'), + action: () => { + } + }, + cancel: () => { } - }, - cancel: () => { - } - }); + }); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'LinkClass', `getStringSync failed, error code=${err.code}, message=${err.message}`); + } } } diff --git a/entry/src/main/ets/pages/WebPage.ets b/entry/src/main/ets/pages/WebPage.ets index 5690db6..1684ba2 100755 --- a/entry/src/main/ets/pages/WebPage.ets +++ b/entry/src/main/ets/pages/WebPage.ets @@ -13,25 +13,32 @@ * limitations under the License. */ -import { promptAction } from '@kit.ArkUI'; import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; import { CommonConstant as Const } from '../common/Constant'; import { NavigatorBean } from '../viewmodel/NavigatorBean'; + const uiContext: UIContext | undefined = AppStorage.get('uiContext'); let context = uiContext!.getHostContext()!; class LinkClass { messageFromHtml(value: string) { - let res = context.resourceManager.getStringSync($r('app.string.congratulate').id); - uiContext!.showAlertDialog({ - message: res + value, - confirm: { - value: $r('app.string.web_alert_dialog_button_value'), - action: () => { + try { + let res = context.resourceManager.getStringSync($r('app.string.congratulate').id); + uiContext!.showAlertDialog({ + message: res + value, + confirm: { + value: $r('app.string.web_alert_dialog_button_value'), + action: () => { + } + }, + cancel: () => { } - }, - cancel: () => { - } - }); + }); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'LinkClass', `getStringSync failed, error code=${err.code}, message=${err.message}`); + } } } diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 index 64d4de8..5fbdc0a 100755 --- a/hvigor/hvigor-config.json5 +++ b/hvigor/hvigor-config.json5 @@ -1,5 +1,5 @@ { - "modelVersion": "5.0.0", + "modelVersion": "5.0.5", "dependencies": { }, "execution": { diff --git a/oh-package.json5 b/oh-package.json5 index c098d7a..bcff901 100755 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -1,5 +1,5 @@ { - "modelVersion": "5.0.0", + "modelVersion": "5.0.5", "license": "", "devDependencies": {}, "author": "", -- Gitee