From 1627219c440f35cdc07418400b8eeee39bccbeb0 Mon Sep 17 00:00:00 2001 From: zhuzhengjun Date: Thu, 25 Jul 2024 17:42:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9setWebContentsDebuggingEnable?= =?UTF-8?q?d=E6=97=A0=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhuzhengjun --- .../ets/components/plugin/webview/InAppWebViewManager.ets | 6 ++++-- .../plugin/webview/in_app_webview/InAppWebView.ets | 3 +++ .../plugin/webview/in_app_webview/OhosWebView.ets | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/InAppWebViewManager.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/InAppWebViewManager.ets index 4a220839..a9d46b20 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/InAppWebViewManager.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/InAppWebViewManager.ets @@ -39,6 +39,8 @@ export class InAppWebViewManager extends ChannelDelegateImpl { public windowAutoincrementId: number = 0 + public debuggingEnabled = false; + constructor(plugin: InAppWebViewFlutterPlugin) { super(new MethodChannel(plugin.messenger!, METHOD_CHANNEL_NAME)); this.plugin = plugin @@ -88,8 +90,8 @@ export class InAppWebViewManager extends ChannelDelegateImpl { break; case "setWebContentsDebuggingEnabled": { - let debuggingEnabled: boolean = call.argument("debuggingEnabled") as boolean; - web_webview.WebviewController.setWebDebuggingAccess(debuggingEnabled) + this.debuggingEnabled = call.argument("debuggingEnabled") as boolean; + web_webview.WebviewController.setWebDebuggingAccess(this.debuggingEnabled) } result.success(true); break; diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets index 38401886..ba6fc497 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets @@ -1014,6 +1014,9 @@ export default class InAppWebView implements InAppWebViewInterface { }) } + isDebuggingEnabled() { + return this.plugin.inAppWebViewManager!.debuggingEnabled + } disposeWebMessageChannels(): void { for (let webMessageChannel of this.webMessageChannels.values()) { diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/OhosWebView.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/OhosWebView.ets index 449b13b1..752a115e 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/OhosWebView.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/OhosWebView.ets @@ -48,6 +48,9 @@ export struct OhosWebView { context.eventHub.on(EventConstant.EVENT_UPDATE_CACHEENABLE, (enable : boolean) => { this.cacheEnabled = enable; }); + + //不知道为什么这个静态方法必须要在aboutToAppear里面设置才能生效? + web_webview.WebviewController.setWebDebuggingAccess(this.inAppWebView!.isDebuggingEnabled()); } aboutToDisappear(): void { -- Gitee