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 04a4d777d065b4ad166a9beca9440535d35b75a8..38401886bc871dff77989edf50bb81da68926abd 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 @@ -109,6 +109,7 @@ export default class InAppWebView implements InAppWebViewInterface { private pullToRefreshLayout: PullToRefreshLayout | null = null; private viewWidth = 0; private viewHeight= 0; + private curUrl: string | Resource = ""; constructor(context: Context, plugin: InAppWebViewFlutterPlugin, id: number, windowId: number | null | undefined, customSettings: InAppWebViewSettings, userScripts: Array, contextMenu?: Map) { @@ -256,6 +257,7 @@ export default class InAppWebView implements InAppWebViewInterface { } let realUrl = url.startsWith("resources/rawfile/") ? $rawfile(url.replace("resources/rawfile/", "")) : url; let headers = urlRequest.getHeaders(); + this.curUrl = realUrl; if (headers != null) { this.controller.loadUrl(realUrl, this.toWebHeaders(headers)); return; @@ -267,10 +269,15 @@ export default class InAppWebView implements InAppWebViewInterface { if (this.plugin == null) { return; } + this.curUrl = assetFilePath; await this.waitControllerAttached(); this.controller.loadUrl(assetFilePath) } + getLoadUrl(): string | Resource { + return this.curUrl + } + getLoading(): boolean { return this.isLoading } diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets index 1129f339477ce72491cb25c0312f22389e144b9b..71b2ba600c3fdaac04722304f0c17a54c9334e63 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets @@ -204,7 +204,7 @@ export default class InAppWebViewClient { } } onPageEnd = (event: Any) => { - Log.d(TAG, "onPageBegin=" + JSON.stringify(event)) + Log.d(TAG, "onPageEnd=" + JSON.stringify(event)) this.inAppWebView.isLoading = false; this.loadCustomJavaScriptOnPageFinished(this.inAppWebView); InAppWebViewClient.previousAuthRequestFailureCount = 0; 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 b7a47afe5a3c903914ad1753b4e3157f0ce7d8c3..449b13b190bc7fb96c4c402c83261947eb7aee27 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 @@ -78,7 +78,7 @@ export struct OhosWebView { buildWeb() { Web( { - src: "", + src: this.inAppWebView?.getLoadUrl(), controller: this.controller }) .onControllerAttached(this.inAppWebView!.onControllerAttached)