feat: 移除 H5 URL 中的品牌参数和缓存参数;更新测试用例以反映更改
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user