From b2a79e7f214c8269118e406f8dcfec99b92ce6af Mon Sep 17 00:00:00 2001 From: Booker Date: Tue, 26 May 2026 20:53:46 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20WebView=20?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9B=AE=E5=BD=95=E5=90=8E=E7=BC=80=E8=87=B3?= =?UTF-8?q?=20v4=EF=BC=9B=E6=B7=BB=E5=8A=A0=E6=B8=85=E9=99=A4=20WebView=20?= =?UTF-8?q?HTTP=20=E7=BC=93=E5=AD=98=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/io/openim/flutter/openim/MainActivity.kt | 4 ++-- lib/main.dart | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/kotlin/io/openim/flutter/openim/MainActivity.kt b/android/app/src/main/kotlin/io/openim/flutter/openim/MainActivity.kt index 7ad389c..089a7f3 100644 --- a/android/app/src/main/kotlin/io/openim/flutter/openim/MainActivity.kt +++ b/android/app/src/main/kotlin/io/openim/flutter/openim/MainActivity.kt @@ -31,10 +31,10 @@ class MainActivity : FlutterActivity() { private val WEBVIEW_CACHE_CHANNEL = "io.openim.flutter.im_webview_app/webview_cache" private val TAG = "MainActivity" private val MAX_BRANDING_ICON_SIZE = 192 - private val WEBVIEW_DATA_DIRECTORY_SUFFIX = "h5_shell_fresh_profile_v3" + private val WEBVIEW_DATA_DIRECTORY_SUFFIX = "h5_shell_fresh_profile_v4" private val WEBVIEW_STORAGE_RESET_PREFS = "h5_shell_webview_storage" private val WEBVIEW_STORAGE_RESET_KEY = "reset_version" - private val WEBVIEW_STORAGE_RESET_VERSION = 3 + private val WEBVIEW_STORAGE_RESET_VERSION = 4 override fun onCreate(savedInstanceState: android.os.Bundle?) { configureWebViewDataDirectory() diff --git a/lib/main.dart b/lib/main.dart index 711bf58..070b24b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -217,9 +217,18 @@ class _H5ShellPageState extends State { }); } + await _clearWebViewHttpCache(); await _controller.loadRequest(Uri.parse(url)); } + Future _clearWebViewHttpCache() async { + try { + await _controller.clearCache(); + } catch (_) { + // Some WebView implementations can reject cache operations before first use. + } + } + Future _handleNavigationRequest( NavigationRequest request, ) async {