feat: 优化 H5 线路切换逻辑;实现独立 WebView 管理和状态控制
This commit is contained in:
@@ -76,29 +76,11 @@ class AppConfig {
|
||||
}
|
||||
|
||||
static bool shouldRewriteMainFrameUrl(String url) {
|
||||
final uri = Uri.tryParse(url);
|
||||
if (uri == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final host = uri.host.toLowerCase();
|
||||
return (legacyWebHosts.contains(host) && !_isConfiguredH5Host(host)) ||
|
||||
_hasShellParams(uri);
|
||||
return false;
|
||||
}
|
||||
|
||||
static String canonicalizeMainFrameUrl(String url) {
|
||||
final uri = _removeShellParams(Uri.parse(url));
|
||||
final host = uri.host.toLowerCase();
|
||||
if (!legacyWebHosts.contains(host) || _isConfiguredH5Host(host)) {
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
return uri
|
||||
.replace(
|
||||
scheme: 'https',
|
||||
host: canonicalWebHost,
|
||||
)
|
||||
.toString();
|
||||
return url;
|
||||
}
|
||||
|
||||
static int? lineIndexForUrl(String url) {
|
||||
@@ -134,16 +116,6 @@ class AppConfig {
|
||||
);
|
||||
}
|
||||
|
||||
static bool _hasShellParams(Uri uri) {
|
||||
final fragmentParameters = Uri.splitQueryString(uri.fragment);
|
||||
return uri.queryParameters.containsKey('flutter_shell') ||
|
||||
uri.queryParameters.containsKey('shell_cache_bust') ||
|
||||
uri.queryParameters.containsKey('shell_app_name') ||
|
||||
uri.queryParameters.containsKey('shell_app_logo') ||
|
||||
fragmentParameters.containsKey('shell_app_name') ||
|
||||
fragmentParameters.containsKey('shell_app_logo');
|
||||
}
|
||||
|
||||
static int _safeLineIndex(int index, int length) {
|
||||
if (length <= 0 || index < 0 || index >= length) {
|
||||
return 0;
|
||||
@@ -151,10 +123,6 @@ class AppConfig {
|
||||
return index;
|
||||
}
|
||||
|
||||
static bool _isConfiguredH5Host(String host) {
|
||||
return h5Lines.any((line) => line.uri.host.toLowerCase() == host);
|
||||
}
|
||||
|
||||
static bool _isSameLine(Uri lineUri, Uri uri) {
|
||||
if (lineUri.host.toLowerCase() != uri.host.toLowerCase()) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user