feat: 移除 H5 URL 中的品牌参数和缓存参数;更新测试用例以反映更改

This commit is contained in:
Booker
2026-05-26 20:20:01 +07:00
parent 2eef27a0e1
commit 1e19f5f5f8
3 changed files with 11 additions and 48 deletions

View File

@@ -15,15 +15,8 @@ const _shellBackground = Color(0xFFF8FBFF);
const _shellAccent = Color(0xFF0089FF);
const _shellSubText = Color(0xFF8E9AB0);
const _resumeCoverDuration = Duration(milliseconds: 700);
const _noCacheHeaders = {
'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
};
const _shellBrandingChannel =
MethodChannel('io.openim.flutter.im_webview_app/shell_branding');
const _shellWebViewCacheChannel =
MethodChannel('io.openim.flutter.im_webview_app/webview_cache');
const _inspectH5SnapshotScript = r'''
(() => {
const toAbsoluteUrl = (value) => {
@@ -468,31 +461,6 @@ class _H5ShellPageState extends State<H5ShellPage> with WidgetsBindingObserver {
}
}
Future<void> _prepareWebViewForFreshLoad() async {
await _configureAndroidNoCache();
try {
await _controller.clearCache();
} catch (_) {
// Some WebView implementations can reject cache operations during setup.
}
}
Future<void> _configureAndroidNoCache() async {
final platformController = _controller.platform;
if (platformController is! AndroidWebViewController) {
return;
}
try {
await _shellWebViewCacheChannel.invokeMethod<void>(
'configureNoCache',
{'webViewId': platformController.webViewIdentifier},
);
} catch (_) {
// Older shells may not expose the native cache channel yet.
}
}
Future<void> _syncShellBranding() {
final payload = jsonEncode({
'name': widget.shellBranding.appName,
@@ -561,12 +529,7 @@ class _H5ShellPageState extends State<H5ShellPage> with WidgetsBindingObserver {
});
}
await _prepareWebViewForFreshLoad();
await _controller.loadRequest(
Uri.parse(url),
headers: _noCacheHeaders,
);
await _controller.loadRequest(Uri.parse(url));
}
Future<NavigationDecision> _handleNavigationRequest(