feat: 更新 WebView 数据目录后缀至 v4;添加清除 WebView HTTP 缓存的方法

This commit is contained in:
Booker
2026-05-26 20:53:46 +07:00
parent 2857047df2
commit b2a79e7f21
2 changed files with 11 additions and 2 deletions

View File

@@ -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()

View File

@@ -217,9 +217,18 @@ class _H5ShellPageState extends State<H5ShellPage> {
});
}
await _clearWebViewHttpCache();
await _controller.loadRequest(Uri.parse(url));
}
Future<void> _clearWebViewHttpCache() async {
try {
await _controller.clearCache();
} catch (_) {
// Some WebView implementations can reject cache operations before first use.
}
}
Future<NavigationDecision> _handleNavigationRequest(
NavigationRequest request,
) async {