feat: 更新 WebView 数据目录,添加持久存储清理逻辑;优化 URL 生成和 H5 路由刷新时的品牌保持
This commit is contained in:
@@ -21,33 +21,14 @@ class AppConfig {
|
||||
final host = environmentHosts.isNotEmpty
|
||||
? environmentHosts.first
|
||||
: 'h5-im.imharry.work';
|
||||
return _withShellBranding(
|
||||
return withFreshShellParams(
|
||||
_normalizeHomeUrl(host),
|
||||
appName: appName,
|
||||
appLogo: appLogo,
|
||||
);
|
||||
}
|
||||
|
||||
static String withFreshShellCacheBust(String url) {
|
||||
final uri = Uri.parse(url);
|
||||
final queryParameters = Map<String, String>.from(uri.queryParameters)
|
||||
..['shell_cache_bust'] = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
|
||||
return uri.replace(queryParameters: queryParameters).toString();
|
||||
}
|
||||
|
||||
static String _normalizeHomeUrl(String host) {
|
||||
final value = host.trim();
|
||||
final normalized =
|
||||
value.startsWith('http://') || value.startsWith('https://')
|
||||
? value
|
||||
: 'https://$value';
|
||||
final uri = Uri.parse(normalized);
|
||||
final path = uri.path.isEmpty ? '/' : uri.path;
|
||||
return uri.replace(path: path).toString();
|
||||
}
|
||||
|
||||
static String _withShellBranding(
|
||||
static String withFreshShellParams(
|
||||
String url, {
|
||||
String? appName,
|
||||
String? appLogo,
|
||||
@@ -77,4 +58,23 @@ class AppConfig {
|
||||
)
|
||||
.toString();
|
||||
}
|
||||
|
||||
static String withFreshShellCacheBust(String url) {
|
||||
final uri = Uri.parse(url);
|
||||
final queryParameters = Map<String, String>.from(uri.queryParameters)
|
||||
..['shell_cache_bust'] = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
|
||||
return uri.replace(queryParameters: queryParameters).toString();
|
||||
}
|
||||
|
||||
static String _normalizeHomeUrl(String host) {
|
||||
final value = host.trim();
|
||||
final normalized =
|
||||
value.startsWith('http://') || value.startsWith('https://')
|
||||
? value
|
||||
: 'https://$value';
|
||||
final uri = Uri.parse(normalized);
|
||||
final path = uri.path.isEmpty ? '/' : uri.path;
|
||||
return uri.replace(path: path).toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user