From f15b688f450ee936be278a9c00f87b206ff68b53 Mon Sep 17 00:00:00 2001 From: "@wanghui187" <348582973@qq.com> Date: Thu, 31 Oct 2024 17:57:00 +0800 Subject: [PATCH 1/2] fix bug Signed-off-by: @wanghui187 <348582973@qq.com> --- templates/cocos2dx_files.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 71cad8ff3..7cf2ec670 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -595,6 +595,8 @@ "cocos/platform/openharmony/modules/CCCanvasRenderingContext2D-openharmony.cpp", "cocos/platform/openharmony/napi/NapiHelper.cpp", "cocos/platform/openharmony/napi/NapiHelper.h", + "cocos/platform/openharmony/napi/NapiValueConverter.cpp", + "cocos/platform/openharmony/napi/NapiValueConverter.h", "cocos/platform/openharmony/napi/NapiInit.cpp", "cocos/platform/openharmony/napi/napi-inl.h", "cocos/platform/openharmony/napi/napi.h", @@ -4212,6 +4214,8 @@ "cocos/scripting/js-bindings/jswrapper/v8/debugger/util.cc", "cocos/scripting/js-bindings/jswrapper/v8/debugger/util.h", "cocos/scripting/js-bindings/jswrapper/v8/debugger/v8_inspector_protocol_json.h", + "cocos/scripting/js-bindings/manual/JavaScriptArkTsBridge.cpp", + "cocos/scripting/js-bindings/manual/JavaScriptArkTsBridge.h", "cocos/scripting/js-bindings/manual/JavaScriptJavaBridge.cpp", "cocos/scripting/js-bindings/manual/JavaScriptJavaBridge.h", "cocos/scripting/js-bindings/manual/JavaScriptObjCBridge.h", -- Gitee From 9ed944673dcd723939867ff1528c4fdba9be532b Mon Sep 17 00:00:00 2001 From: "@wanghui187" <348582973@qq.com> Date: Thu, 7 Nov 2024 19:59:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?webview=20=E6=A6=82=E7=8E=87=E6=80=A7?= =?UTF-8?q?=E7=99=BD=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: @wanghui187 <348582973@qq.com> --- .../entry/src/main/ets/components/CocosWebView.ets | 5 +++++ .../entry/src/main/ets/components/CocosWebView.ets | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/templates/js-template-default/frameworks/runtime-src/proj.openharmony/entry/src/main/ets/components/CocosWebView.ets b/templates/js-template-default/frameworks/runtime-src/proj.openharmony/entry/src/main/ets/components/CocosWebView.ets index b93a477d2..9368735ca 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.openharmony/entry/src/main/ets/components/CocosWebView.ets +++ b/templates/js-template-default/frameworks/runtime-src/proj.openharmony/entry/src/main/ets/components/CocosWebView.ets @@ -75,6 +75,11 @@ export struct CocosWebView { .width(this.viewInfo.w) .height(this.viewInfo.h) .border({ width: 1 }) + .onControllerAttached(() => { + if (this.viewInfo.url != '') { + this.viewInfo.controller.loadUrl(this.viewInfo.url); + } + }) .onPageBegin((event) => { this.workPort?.postMessage("onPageBegin", { viewTag: this.viewInfo.viewTag as number, diff --git a/templates/js-template-link/frameworks/runtime-src/proj.openharmony/entry/src/main/ets/components/CocosWebView.ets b/templates/js-template-link/frameworks/runtime-src/proj.openharmony/entry/src/main/ets/components/CocosWebView.ets index b93a477d2..9368735ca 100644 --- a/templates/js-template-link/frameworks/runtime-src/proj.openharmony/entry/src/main/ets/components/CocosWebView.ets +++ b/templates/js-template-link/frameworks/runtime-src/proj.openharmony/entry/src/main/ets/components/CocosWebView.ets @@ -75,6 +75,11 @@ export struct CocosWebView { .width(this.viewInfo.w) .height(this.viewInfo.h) .border({ width: 1 }) + .onControllerAttached(() => { + if (this.viewInfo.url != '') { + this.viewInfo.controller.loadUrl(this.viewInfo.url); + } + }) .onPageBegin((event) => { this.workPort?.postMessage("onPageBegin", { viewTag: this.viewInfo.viewTag as number, -- Gitee